Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CrossFitEstimator.score #63

Merged
merged 2 commits into from
Jul 22, 2024
Merged

Implement CrossFitEstimator.score #63

merged 2 commits into from
Jul 22, 2024

Conversation

FrancescMartiEscofetQC
Copy link
Contributor

@FrancescMartiEscofetQC FrancescMartiEscofetQC commented Jul 19, 2024

This PR is just for the sake of completeness.

Checklist

  • Added a CHANGELOG.rst entry

@FrancescMartiEscofetQC FrancescMartiEscofetQC marked this pull request as ready for review July 19, 2024 08:22
Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.00%. Comparing base (9e00603) to head (108f4f3).
Report is 27 commits behind head on main.

Files with missing lines Patch % Lines
metalearners/cross_fit_estimator.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #63      +/-   ##
==========================================
+ Coverage   94.99%   95.00%   +0.01%     
==========================================
  Files          15       15              
  Lines        1498     1503       +5     
==========================================
+ Hits         1423     1428       +5     
  Misses         75       75              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

y, self.predict(X, is_oos, oos_method), sample_weight=sample_weight
)
elif self._estimator_type == "regressor":
return r2_score(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason why you chose R2, rather than e.g. the RMSE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just because it looks like it is the convention in sklearn, see this and this.
I think they do it because the R2 has as known range whether the RMSE depends a lot on the data but I just followed their rule, R2 for regressors and accuracy for classifiers.

) -> float:
"""Return the coefficient of determination of the prediction if the estimator is
a regressor or the mean accuracy if it is a classifier."""
if self._estimator_type == "classifier":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you happen to know what the trade-off between doing this and using sklearn's is_classifier is here?

E.g.

if is_classifier(self):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None, I just didn't think about it 😅 . I think it's better to use the sklearn methods.
108f4f3

Copy link
Collaborator

@kklein kklein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

@FrancescMartiEscofetQC FrancescMartiEscofetQC merged commit 95e2cfe into main Jul 22, 2024
15 of 16 checks passed
@FrancescMartiEscofetQC FrancescMartiEscofetQC deleted the score_cfe branch July 22, 2024 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants