Github user dbtsai commented on a diff in the pull request:
https://github.com/apache/spark/pull/7884#discussion_r39476407
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
---
@@ -501,22 +529,27 @@ class LogisticRegressionModel private[ml] (
* corresponding joint dataset.
*/
private[classification] class MultiClassSummarizer extends Serializable {
- private val distinctMap = new mutable.HashMap[Int, Long]
+ private val distinctMap = new mutable.HashMap[Int, Double]
private var totalInvalidCnt: Long = 0L
/**
* Add a new label into this MultilabelSummarizer, and update the
distinct map.
* @param label The label for this data point.
+ * @param weight The weight of this instances.
* @return This MultilabelSummarizer
*/
- def add(label: Double): this.type = {
+ def add(label: Double, weight: Double = 1.0): this.type = {
+ require(weight >= 0.0, s"instance weight, ${weight} has to be >= 0.0")
+
+ if (weight == 0.0) return this
+
if (label - label.toInt != 0.0 || label < 0) {
totalInvalidCnt += 1
this
}
else {
- val counts: Long = distinctMap.getOrElse(label.toInt, 0L)
- distinctMap.put(label.toInt, counts + 1)
+ val counts: Double = distinctMap.getOrElse(label.toInt, 0.0)
--- End diff --
I have this information available now. `histogram` function will return
array of `weightSum`, and we need another api for getting `counts`. Let's do
it in follow-up JIRA. In fact, we should move MultiClassSummarizer out to use
it elsewhere.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]