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

Proper UID for Raw Feature Filter #276

Merged
merged 1 commit into from
Apr 10, 2019
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
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"
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not use the UID method?

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 guess it's better to have it be the same (!?) not important really, since there is only one.

}

/**
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