Skip to content

Threshold metrics calculation fix when unseen labels are present#293

Merged
Jauntbox merged 84 commits intomasterfrom
km/label-trim-metrics
Apr 22, 2019
Merged

Threshold metrics calculation fix when unseen labels are present#293
Jauntbox merged 84 commits intomasterfrom
km/label-trim-metrics

Conversation

@Jauntbox
Copy link
Copy Markdown
Contributor

Related issues
Issue exposed by fixes in #263

Describe the proposed solution
Simple one-line fix to threshold metrics calculation. When the true label score is calculated, it will either come from the list of labels the model was trained on (which may be pruned by DataCutter) or be 0 (eg. if it corresponds to a label the model was not trained on).

Describe alternatives you've considered
n/a

Additional context
Merge #263 first since this PR was branched off of it.
Unit test resides in MultiClassificationModelSelectorTest

Copy link
Copy Markdown
Contributor

@gerashegalov gerashegalov left a comment

Choose a reason for hiding this comment

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

LGTM, minor comment

val label: Label = scoresAndLabels._2.toInt
val trueClassScore: Double = scores(label)
// The label may be unseen during model training, so treat scores for unseen classes as all being zero
val trueClassScore: Double = if (scores.isDefinedAt(label)) scores(label) else 0.0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how about scores.lift(label).getOrElse(0.0)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ahh, I was trying to remember how to do that!

@Jauntbox Jauntbox merged commit 9bc75a9 into master Apr 22, 2019
@Jauntbox Jauntbox deleted the km/label-trim-metrics branch April 22, 2019 18:09
@Jauntbox Jauntbox mentioned this pull request May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants