-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-16831] [Python] Fixed bug in CrossValidator.avgMetrics #14456
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,6 +166,8 @@ class CrossValidator(Estimator, ValidatorParams): | |
>>> evaluator = BinaryClassificationEvaluator() | ||
>>> cv = CrossValidator(estimator=lr, estimatorParamMaps=grid, evaluator=evaluator) | ||
>>> cvModel = cv.fit(dataset) | ||
>>> cvModel.avgMetrics[0] | ||
0.5 | ||
>>> evaluator.evaluate(cvModel.transform(dataset)) | ||
0.8333... | ||
|
||
|
@@ -234,7 +236,7 @@ def _fit(self, dataset): | |
model = est.fit(train, epm[j]) | ||
# TODO: duplicate evaluator to take extra params from input | ||
metric = eva.evaluate(model.transform(validation, epm[j])) | ||
metrics[j] += metric | ||
metrics[j] += metric/nFolds | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may fail style checks but we'll see There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK looks fine actually. Would it be possible to add a little bit to the test above this to demonstrate that the result is correct now? just testing the value of the first element of metrics for example.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done (2 commits because I made a typo.) |
||
|
||
if eva.isLargerBetter(): | ||
bestIndex = np.argmax(metrics) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I assume this would have printed 1.5 before