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 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
absError / (2 * 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.

Why did you hardcode this change instead of adjusting the tolerance? Is there a reason for a factor of 2 here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i think back when i wrote this test you suggested abs(x_1 - x_2) / 2 * (x_1 + x_2) as one way to compute how close x_1 is to x_2, or did I misremember?

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggested difference / avg. value, which is abs(x_1 - x_2) * 2 / (x_1 + x_2). It probably makes more sense to change it to that, but you should probably increase the overall tolerance too to cut down on flakiness.

absError2 / (2 * 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
absError / (2 * bigCoeffSum) < tol shouldBe true
absError2 / (2 * smallCoeffSum) < tol shouldBe true
}

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