-
Notifications
You must be signed in to change notification settings - Fork 359
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
[SW-2646] Calculate Metrics on Arbitrary Dataset #2745
base: master
Are you sure you want to change the base?
Conversation
89d3df6
to
e679aea
Compare
ml/src/test/scala/ai/h2o/sparkling/ml/metrics/BinomialMetricsTestSuite.scala
Outdated
Show resolved
Hide resolved
|
||
override protected def getPredictionValues(dataType: DataType, domain: Array[String], row: Row): Array[Double] = { | ||
dataType match { | ||
case StructType(fields) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: matching like StructType(Array(firstField, secondField))
would also ensure the field counts and avoid calling by index later on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, the original approach is more readable. The pattern for the suggested approach would be:
StructType(Array(StructField(_, StringType, _, _), StructField(_, StructType(Array(StructField(_, DoubleType, _, _), StructField(_, DoubleType, _, _))), _, _)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following "long" predicate appears several times in code. Would it be possible to define an auxiliary function that describes the condition and use it, e.g.
def isSomeSpecialType(fields: Array[StructField]): Boolean = fields(0).dataType == StringType && fields(1).dataType.isInstanceOf[StructType] && fields(1).dataType.asInstanceOf[StructType].fields.forall(_.dataType == DoubleType) && fields(1).dataType.asInstanceOf[StructType].fields.length == 2
scoring/src/main/scala/ai/h2o/sparkling/ml/metrics/H2OBinomialMetrics.scala
Outdated
Show resolved
Hide resolved
scoring/src/main/scala/ai/h2o/sparkling/ml/metrics/H2OBinomialMetrics.scala
Outdated
Show resolved
Hide resolved
scoring/src/main/scala/ai/h2o/sparkling/ml/metrics/MetricCalculation.scala
Outdated
Show resolved
Hide resolved
LGTM, great piece of work 👍 |
@krasinski thanks for your review, much appreciated! I've tried address the vast majority of your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
override protected def getPredictionValues(dataType: DataType, domain: Array[String], row: Row): Array[Double] = { | ||
dataType match { | ||
case StructType(fields) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following "long" predicate appears several times in code. Would it be possible to define an auxiliary function that describes the condition and use it, e.g.
def isSomeSpecialType(fields: Array[StructField]): Boolean = fields(0).dataType == StringType && fields(1).dataType.isInstanceOf[StructType] && fields(1).dataType.asInstanceOf[StructType].fields.forall(_.dataType == DoubleType) && fields(1).dataType.asInstanceOf[StructType].fields.length == 2
No description provided.