Skip to content

Instantly share code, notes, and snippets.

@lucasastorian
Last active October 12, 2021 13:43
Show Gist options
  • Select an option

  • Save lucasastorian/2919fee08aece037d8af0946b0cd7a26 to your computer and use it in GitHub Desktop.

Select an option

Save lucasastorian/2919fee08aece037d8af0946b0cd7a26 to your computer and use it in GitHub Desktop.
feature_importances = pd.DataFrame(columns=['mean', 'std'])
for feature in features:
# Calculate an array of OOS CV scores (placeholder function)
cv_scores = get_cv_scores(rf, X[feature], y, sample_weights)
# Set the mean and std OOS score for each feature
feature_importances[feature, 'mean'] = cv_scores.mean()
feature_importances[feature, 'std'] = cv_scores.std() * cv_scores.shape[0]**-.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment