-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-29489][ML][PySpark] ml.evaluation support log-loss #26135
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
Changes from 1 commit
b97e8e8
dadf716
90c8ef2
2b94170
a981f7b
38b901c
f46046c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ import scala.collection.mutable | |
| import org.apache.spark.annotation.Since | ||
| import org.apache.spark.mllib.linalg.{Matrices, Matrix} | ||
| import org.apache.spark.rdd.RDD | ||
| import org.apache.spark.sql.{DataFrame, Row} | ||
| import org.apache.spark.sql.DataFrame | ||
|
|
||
| /** | ||
| * Evaluator for multiclass classification. | ||
|
|
@@ -37,7 +37,7 @@ class MulticlassMetrics @Since("1.1.0") (predictionAndLabels: RDD[_ <: Product]) | |
| /** | ||
| * An auxiliary constructor taking a DataFrame. | ||
| * @param predictionAndLabels a DataFrame with columns: prediction, label, weight(optional) | ||
| * and probability(only for logloss) | ||
| * and probability(only for logLoss) | ||
| */ | ||
| private[mllib] def this(predictionAndLabels: DataFrame) = | ||
| this(predictionAndLabels.rdd.map { r => | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. matching will not work in pyspark, so I have to use |
||
|
|
@@ -241,12 +241,12 @@ class MulticlassMetrics @Since("1.1.0") (predictionAndLabels: RDD[_ <: Product]) | |
| lazy val labels: Array[Double] = tpByClass.keys.toArray.sorted | ||
|
|
||
| /** | ||
| * Returns the log-loss, aka logistic loss or cross-entropy loss. | ||
| * @param eps Log loss is undefined for p=0 or p=1, so probabilities are | ||
| * Returns the logLoss, aka logistic loss or cross-entropy loss. | ||
|
||
| * @param eps LogLoss is undefined for p=0 or p=1, so probabilities are | ||
| * clipped to max(eps, min(1 - eps, p)). | ||
| */ | ||
| @Since("3.0.0") | ||
| def logloss(eps: Double = 1e-15): Double = { | ||
| def logLoss(eps: Double = 1e-15): Double = { | ||
| require(eps > 0 && eps < 0.5, s"eps must be in range (0, 0.5), but got $eps") | ||
| val loss1 = - math.log(eps) | ||
| val loss2 = - math.log(1 - eps) | ||
|
||
|
|
||
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: spaces before paren