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

Fix flaky ModelInsight tests #395

Merged
merged 7 commits into from
Aug 30, 2019
Merged
Changes from 5 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
10 changes: 5 additions & 5 deletions core/src/test/scala/com/salesforce/op/ModelInsightsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ class ModelInsightsTest extends FlatSpec with PassengerSparkFixtureTest with Dou
}
}

val tol = 0.03
val tol = 0.1
it should "correctly return the descaled coefficient for linear regression, " +
"when standardization is on" in {

Expand All @@ -755,8 +755,8 @@ class ModelInsightsTest extends FlatSpec with PassengerSparkFixtureTest with Dou
val bigCoeffSum = orginalbigCoeff * math.sqrt(smallFeatureVariance) / labelStd + descaledbigCoeff
val absError2 = math.abs(originalsmallCoeff * math.sqrt(bigFeatureVariance) / labelStd - descaledsmallCoeff)
val smallCoeffSum = originalsmallCoeff * math.sqrt(bigFeatureVariance) / labelStd + descaledsmallCoeff
absError / bigCoeffSum < tol shouldBe true
absError2 / smallCoeffSum < tol shouldBe true
2 * absError / bigCoeffSum < tol shouldBe true
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand your fix correctly that you double the left-hand side the test would also be fixed by:

absError should be < tol * smallCoeffSum

Copy link
Contributor

Choose a reason for hiding this comment

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

at any rate please use "should be < tol" as it seems to read more clear.

Copy link
Collaborator

Choose a reason for hiding this comment

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

that would also provide a better error message ;) cool!

2 * absError2 / smallCoeffSum < tol shouldBe true
}

it should "correctly return the descaled coefficient for logistic regression, " +
Expand All @@ -771,8 +771,8 @@ class ModelInsightsTest extends FlatSpec with PassengerSparkFixtureTest with Dou
val bigCoeffSum = orginalbigCoeff * math.sqrt(smallFeatureVariance) + descaledbigCoeff
val absError2 = math.abs(originalsmallCoeff * math.sqrt(mediumFeatureVariance) - descaledsmallCoeff)
val smallCoeffSum = originalsmallCoeff * math.sqrt(mediumFeatureVariance) + descaledsmallCoeff
absError / bigCoeffSum < tol shouldBe true
absError2 / smallCoeffSum < tol shouldBe true
2 * absError / bigCoeffSum < tol shouldBe true
2 * absError2 / smallCoeffSum < tol shouldBe true
}

it should "correctly return moments calculation and cardinality calculation for numeric features" in {
Expand Down