Skip to content

Commit

Permalink
Proper UID for Raw Feature Filter (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
tovbinm authored Apr 10, 2019
1 parent 7d6ec61 commit 0bab1d4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,9 @@ object RawFeatureFilter {
// scoring sets since they will not be reliable. Currently, this is set to the same as the minimum training size.
val minScoringRowsDefault = 500

val stageName = classOf[RawFeatureFilter[_]].getSimpleName

val uid = s"${stageName}_100000000000"
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ import org.json4s.{DefaultFormats, Formats}

import scala.util.Try

trait RawFeatureFilterFormats {
implicit val jsonFormats: Formats = DefaultFormats +
new SpecialDoubleSerializer +
EnumEntrySerializer.json4s[CorrelationType](CorrelationType) +
EnumEntrySerializer.json4s[FeatureDistributionType](FeatureDistributionType)
}

/**
* Contains configuration and results from RawFeatureFilter
*
Expand All @@ -62,7 +55,15 @@ case class RawFeatureFilterResults
exclusionReasons: Seq[ExclusionReasons] = Seq.empty
)

trait RawFeatureFilterFormats {
implicit val jsonFormats: Formats = DefaultFormats +
new SpecialDoubleSerializer +
EnumEntrySerializer.json4s[CorrelationType](CorrelationType) +
EnumEntrySerializer.json4s[FeatureDistributionType](FeatureDistributionType)
}

object RawFeatureFilterResults extends RawFeatureFilterFormats {

/**
* RawFeatureFilterResults to json
*
Expand All @@ -77,8 +78,7 @@ object RawFeatureFilterResults extends RawFeatureFilterFormats {
* @param json json
* @return raw feature filter results
*/
def fromJson(json: String): Try[RawFeatureFilterResults] =
Try { Serialization.read[RawFeatureFilterResults](json) }
def fromJson(json: String): Try[RawFeatureFilterResults] = Try { Serialization.read[RawFeatureFilterResults](json) }

}

Expand Down Expand Up @@ -116,10 +116,7 @@ object RawFeatureFilterConfig extends RawFeatureFilterFormats {
* @return Map[String, Map[String, Any] ]
*/
def toStageInfo(config: RawFeatureFilterConfig): Map[String, Map[String, Any]] = {
val stageName = "rawFeatureFilter"
val uid = "rawFeatureFilter"
Map(stageName -> Map("uid" -> uid, "params" -> toStringMap(config))
)
Map(RawFeatureFilter.stageName -> Map("uid" -> RawFeatureFilter.uid, "params" -> toStringMap(config)))
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class ModelInsightsTest extends FlatSpec with PassengerSparkFixtureTest with Dou
// check that raw feature filter config is correctly serialized and deserialized

def getRawFeatureFilterConfig(modelInsights: ModelInsights): Map[String, String] = {
modelInsights.stageInfo("rawFeatureFilter") match {
modelInsights.stageInfo(RawFeatureFilter.stageName) match {
case configInfo: Map[String, Map[String, String]] =>
configInfo.getOrElse("params", Map.empty[String, String])
case _ => Map.empty[String, String]
Expand Down

0 comments on commit 0bab1d4

Please sign in to comment.