Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions numerblox/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ def per_era_corrs(
return dataf.groupby(dataf[self.era_col]).apply(
lambda d: self._normalize_uniform(d[pred_col].fillna(0.5)).corr(
d[target_col]
)
),
include_groups=False,
)

def mean_std_sharpe(
Expand Down Expand Up @@ -207,7 +208,8 @@ def max_feature_exposure(
) -> np.float64:
"""Maximum exposure over all features."""
max_per_era = dataf.groupby(self.era_col).apply(
lambda d: d[dataf.feature_cols].corrwith(d[pred_col]).abs().max()
lambda d: d[dataf.feature_cols].corrwith(d[pred_col]).abs().max(),
include_groups=False,
)
max_feature_exposure = max_per_era.mean(skipna=True)
return max_feature_exposure
Expand Down
3 changes: 2 additions & 1 deletion numerblox/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def __init__(
def transform(self, dataf: NumerFrame) -> NumerFrame:
feature_names = self.feature_names if self.feature_names else dataf.feature_cols
neutralized_preds = dataf.groupby(dataf.meta.era_col).apply(
lambda x: self.normalize_and_neutralize(x, [self.pred_name], feature_names)
lambda x: self.normalize_and_neutralize(x, [self.pred_name], feature_names),
include_groups=False,
)
dataf.loc[:, self.new_col_name] = MinMaxScaler().fit_transform(
neutralized_preds
Expand Down