Skip to content

Commit

Permalink
Update calculations.py for sklearn <1.0.0
Browse files Browse the repository at this point in the history
Where calculations.py called functions from sklearn like "cross_val_score" and "mean_absolute_error", pandas data frames were being given as inputs to those functions. I am not sure what Sklearn's new update did not like about it, but changing those pandas data frames to numpy arrays with .to_numpy() fixed the problem and gave the correct values.
  • Loading branch information
JDM288 committed Nov 20, 2021
1 parent 07daf95 commit 8f47354
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ppscore/calculation.py
Expand Up @@ -62,7 +62,7 @@ def _calculate_model_cv_score_(
# Cross-validation is stratifiedKFold for classification, KFold for regression
# CV on one core (n_job=1; default) has shown to be fastest
scores = cross_val_score(
model, feature_input, target_series, cv=cross_validation, scoring=metric
model, feature_input, target_series.to_numpy(), cv=cross_validation, scoring=metric
)

return scores.mean()
Expand All @@ -83,7 +83,7 @@ def _normalized_mae_score(model_mae, naive_mae):
def _mae_normalizer(df, y, model_score, **kwargs):
"In case of MAE, calculates the baseline score for y and derives the PPS."
df["naive"] = df[y].median()
baseline_score = mean_absolute_error(df[y], df["naive"]) # true, pred
baseline_score = mean_absolute_error(df[y].to_numpy(), df["naive"].to_numpy()) # true, pred

ppscore = _normalized_mae_score(abs(model_score), baseline_score)
return ppscore, baseline_score
Expand Down

0 comments on commit 8f47354

Please sign in to comment.