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

Metadata changes for sensitive feature information #457

Merged
merged 18 commits into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
Cleaning up tests per PR comments
  • Loading branch information
MWYang committed Jan 24, 2020
commit 26f30fb00a9b24b78e88891766b0f4094d4a973b
51 changes: 26 additions & 25 deletions core/src/test/scala/com/salesforce/op/ModelInsightsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ class ModelInsightsTest extends FlatSpec with PassengerSparkFixtureTest with Dou
},
Seq("f1", "f0").map(name => name -> FeatureHistory(originFeatures = Seq(name), stages = Seq())).toMap,
Map(
"f0" -> Seq(SensitiveNameInformation(0.0, Seq.empty[GenderDetectionResults], 0.0, 0.0, 1.0, "f0", None, false))
"f0" -> Seq(SensitiveNameInformation(0.0, Seq.empty[GenderDetectionResults], 0.0, 0.0, 1.0, "f0", None))
)
)

Expand Down Expand Up @@ -709,32 +709,33 @@ class ModelInsightsTest extends FlatSpec with PassengerSparkFixtureTest with Dou
"""include sensitive feature information
|even for sensitive features that are removed from output vector and output vector metadata""".stripMargin in {
// Copy metadata from above but add new feature that was removed in vectorizing to sensitive info
val f_notInMeta = Feature[Text]("f_notInMeta", false, null, Seq(), "test")
val newMeta = OpVectorMetadata(
"fv",
val f_notInMeta = Feature[Text]("f_notInMeta", isResponse = false, null, Seq(), "test")
val newFeatureName = "fv"
val newColumnMeta = OpVectorColumnMetadata(
parentFeatureName = Seq("f1"),
parentFeatureType = Seq(classOf[Real].getName),
grouping = None,
indicatorValue = None
) +: Array("f2", "f3").map { name =>
OpVectorColumnMetadata(
parentFeatureName = Seq("f1"),
parentFeatureType = Seq(classOf[Real].getName),
grouping = None,
indicatorValue = None
) +: Array("f2", "f3").map { name =>
OpVectorColumnMetadata(
parentFeatureName = Seq("f0"),
parentFeatureType = Seq(classOf[PickList].getName),
grouping = Option("f0"),
indicatorValue = Option(name)
)
},
Seq("f1", "f0").map(name => name -> FeatureHistory(originFeatures = Seq(name), stages = Seq())).toMap,
Map(
"f0" -> Seq(SensitiveNameInformation(
0.0, Seq.empty[GenderDetectionResults], 0.0, 0.0, 1.0, "f0", None, false
)),
"f_notInMeta" -> Seq(SensitiveNameInformation(
1.0, Seq.empty[GenderDetectionResults], 0.0, 0.0, 1.0, "f_notInMeta", None, true
))
parentFeatureName = Seq("f0"),
parentFeatureType = Seq(classOf[PickList].getName),
grouping = Option("f0"),
indicatorValue = Option(name)
)
}
val newFeatureHistory = Seq("f1", "f0").map(
name => name -> FeatureHistory(originFeatures = Seq(name), stages = Seq())
).toMap
val newSensitiveInfo = Map(
"f0" -> Seq(SensitiveNameInformation(
0.0, Seq.empty[GenderDetectionResults], 0.0, 0.0, 1.0, "f0", None
)),
"f_notInMeta" -> Seq(SensitiveNameInformation(
1.0, Seq.empty[GenderDetectionResults], 0.0, 0.0, 1.0, "f_notInMeta", None, actionTaken = true
))
)
val newMeta = OpVectorMetadata(newFeatureName, newColumnMeta, newFeatureHistory, newSensitiveInfo)

val labelSum = ModelInsights.getLabelSummary(Option(lbl), Option(summary))

Expand All @@ -749,7 +750,7 @@ class ModelInsightsTest extends FlatSpec with PassengerSparkFixtureTest with Dou
f_notInMeta_butInInsights.derivedFeatures.size shouldBe 0
f_notInMeta_butInInsights.sensitiveInformation match {
case Seq(SensitiveNameInformation(
probName, genderDetectResults, probMale, probFemale, probOther, name, mapKey, actionTaken
probName, genderDetectResults, probMale, probFemale, probOther, _, _, actionTaken
)) =>
actionTaken shouldBe true
probName shouldBe 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class OPVectorMetadataTest extends PropSpec with TestCommon with PropertyChecks
)
val arrVecColTupleGen: Gen[Array[OpVectorColumnTuple]] = Gen.containerOf[Array, OpVectorColumnTuple](vecColTupleGen)

val sensitiveGen: Gen[SensitiveTuple] = for {
val sensitiveNameGen: Gen[SensitiveTuple] = for {
featureName <- genName
mapKey <- Gen.option(genName)
actionTaken <- Gen.oneOf[Boolean](Seq(false, true))
Expand All @@ -94,7 +94,7 @@ class OPVectorMetadataTest extends PropSpec with TestCommon with PropertyChecks
name <- genName
arr <- arrVecColTupleGen
histories <- featHistTupleGen
sensitiveCols <- Gen.containerOf[Seq, SensitiveTuple](sensitiveGen)
sensitiveCols <- Gen.containerOf[Seq, SensitiveTuple](sensitiveNameGen)
} yield {
(name, arr, histories, sensitiveCols)
}
Expand Down