Skip to content

Commit

Permalink
add top_bottom filter to numerai_corr, add np.abs to max_feature_corr…
Browse files Browse the repository at this point in the history
…elation (#15)

* add top_bottom filter to numerai_corr, add np.abs to max_feature_correlation

* move np abs in max_feature_correlation
  • Loading branch information
cshanes authored Dec 13, 2023
1 parent ef97386 commit 6d9d357
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions numerai_tools/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,15 @@ def numerai_corr(
pd.Series - the resulting correlation scores for each column in predictions
"""
targets -= targets.mean()
targets, predictions = filter_sort_index(
targets, predictions, max_filtered_index_ratio
)
if top_bottom is not None and top_bottom > 0:
predictions = filter_top_bottom(predictions, top_bottom)
targets, predictions = filter_sort_index(
targets, predictions, (1 - top_bottom / len(targets))
)
else:
targets, predictions = filter_sort_index(
targets, predictions, max_filtered_index_ratio
)
predictions = tie_kept_rank__gaussianize__pow_1_5(predictions)
targets = power(targets.to_frame(), 1.5)[targets.name]
scores = predictions.apply(lambda sub: pearson_correlation(targets, sub))
Expand Down Expand Up @@ -423,6 +429,7 @@ def max_feature_correlation(
feature_correlations = features.apply(
lambda f: pearson_correlation(f, s, top_bottom)
)
feature_correlations = np.abs(feature_correlations)
max_feature = feature_correlations.idxmax()
max_corr = feature_correlations[max_feature]
return max_feature, max_corr

0 comments on commit 6d9d357

Please sign in to comment.