Github user zhengruifeng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11303#discussion_r53736887
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/mllib/evaluation/MulticlassMetricsSuite.scala
 ---
    @@ -51,6 +51,9 @@ class MulticlassMetricsSuite extends SparkFunSuite with 
MLlibTestSparkContext {
         val f2measure0 = (1 + 2 * 2) * precision0 * recall0 / (2 * 2 * 
precision0 + recall0)
         val f2measure1 = (1 + 2 * 2) * precision1 * recall1 / (2 * 2 * 
precision1 + recall1)
         val f2measure2 = (1 + 2 * 2) * precision2 * recall2 / (2 * 2 * 
precision2 + recall2)
    +    val unweighted_kappa = 0.47058823529411764
    --- End diff --
    
    The three number are obtained via sklearn and ml_metrics.
    
    In [4]: from sklearn.metrics import cohen_kappa_score
    
    In [5]: from ml_metrics import quadratic_weighted_kappa, 
linear_weighted_kappa, kappa
    
    In [6]: preds = [0, 0, 0, 1, 1, 1, 1, 2, 2]
    
    In [7]: labels = [0, 1, 0, 0, 1, 1, 1, 2, 0]
    
    In [8]: cohen_kappa_score(preds, labels)
    Out[8]: 0.47058823529411781
    
    In [9]: quadratic_weighted_kappa(preds, labels)
    Out[9]: 0.3571428571428571
    
    In [10]: linear_weighted_kappa(preds, labels)
    Out[10]: 0.4193548387096774
    
    In [11]: kappa(preds, labels)
    Out[11]: 0.47058823529411764


---
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]

Reply via email to