spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sethah <...@git.apache.org>
Subject [GitHub] spark pull request #15435: [SPARK-17139][ML] Add model summary for Multinomi...
Date Wed, 04 Jan 2017 19:04:20 GMT
Github user sethah commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15435#discussion_r94521336
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
---
    @@ -1095,6 +1131,89 @@ private[classification] class MultiClassSummarizer extends Serializable
{
     }
     
     /**
    + * :: Experimental ::
    + * Summary of multi-classification algorithms.
    + *
    + * @param predictions  [[DataFrame]] produced by model.transform().
    + * @param predictionCol  Name for column of prediction in `predictions`.
    + * @param labelCol  Name for column of label in `predictions`.
    + */
    +@Experimental
    +@Since("2.1.0")
    +class MulticlassSummary private[ml] (
    +    @transient val predictions: DataFrame,
    +    val predictionCol: String,
    +    val labelCol: String) extends Serializable {
    +
    +  @transient private val multinomialMetrics = {
    +    new MulticlassMetrics(
    +      predictions.select(
    +        col(predictionCol),
    +        col(labelCol).cast(DoubleType))
    +        .rdd.map { case Row(prediction: Double, label: Double) => (prediction, label)
})
    +  }
    +
    +  /** Returns false positive rate for each label. */
    +  @Since("2.1.0")
    +  @transient lazy val falsePositiveRateByLabel: Array[Double] = {
    +    multinomialMetrics.labels.map(label => multinomialMetrics.falsePositiveRate(label))
    +  }
    +
    +  /** Returns precision for each label. */
    +  @Since("2.1.0")
    +  @transient lazy val precisionByLabel: Array[Double] = {
    +    multinomialMetrics.labels.map(label => multinomialMetrics.precision(label))
    +  }
    +
    +  /** Returns recall for each label. */
    +  @Since("2.1.0")
    +  @transient lazy val recallByLabel: Array[Double] = {
    +    multinomialMetrics.labels.map(label => multinomialMetrics.recall(label))
    +  }
    +
    +  /**
    +   * Returns f-measure for each label.
    +   * @param beta the beta parameter.
    --- End diff --
    
    This description is not helpful. Let's either put nothing, or say something like "parameter
which controls the balance between precision and recall in the f-measure"


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message