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

ignoring cardinality in modelinsights serialization #474

Merged
merged 3 commits into from
May 11, 2020
Merged
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: 5 additions & 1 deletion core/src/main/scala/com/salesforce/op/ModelInsights.scala
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,15 @@ case object ModelInsights {
{ case x: EvalMetric => JString(x.entryName) }
)
)
val featureDistributionSerializer = FieldSerializer[FeatureDistribution](
FieldSerializer.ignore("cardEstimate")
)
Serialization.formats(typeHints) +
EnumEntrySerializer.json4s[ValidationType](ValidationType) +
EnumEntrySerializer.json4s[ProblemType](ProblemType) +
new SpecialDoubleSerializer +
evalMetricsSerializer
evalMetricsSerializer +
featureDistributionSerializer
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,8 @@ class ModelInsightsTest extends FlatSpec with PassengerSparkFixtureTest with Dou
i.featureName shouldEqual o.featureName
i.featureType shouldEqual o.featureType
i.derivedFeatures.zip(o.derivedFeatures).foreach { case (ii, io) => ii.corr shouldEqual io.corr }
i.distributions.foreach { i => i.cardEstimate should not be None}
o.distributions.foreach { o => o.cardEstimate shouldEqual None}
Copy link
Contributor

Choose a reason for hiding this comment

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

the test could be more obvious asserting that the pre-serialization object has cardEstimate. And that it loses cardEstimates per requirement after serialization. As opposed to just checking the post-serialization state.

However, I verified that the test fails without your main change, so we should be ok to merge it this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gerashegalov I updated the counter part of this test case

RawFeatureFilterResultsComparison.compareSeqMetrics(i.metrics, o.metrics)
RawFeatureFilterResultsComparison.compareSeqDistributions(i.distributions, o.distributions)
RawFeatureFilterResultsComparison.compareSeqExclusionReasons(i.exclusionReasons, o.exclusionReasons)
Expand Down Expand Up @@ -968,4 +970,5 @@ class ModelInsightsTest extends FlatSpec with PassengerSparkFixtureTest with Dou
"second" -> classOf[SingleMetric]
)
}

}