Github user avulanov commented on the pull request:

    https://github.com/apache/spark/pull/1155#issuecomment-70714725
  
    @tolgap As documentation suggests, `MulticlassMetrics` accepts 
`predictionAndLabels`, an RDD of (prediction, label) pairs, where `prediction` 
is the predicted class/label, `label` is the actual class/label.
    
    For example:
    
        import org.apache.spark.mllib.util.MLUtils
        import org.apache.spark.mllib.classification.ANNClassifier
        import org.apache.spark.mllib.evaluation.MulticlassMetrics
        
        /* load mnist data */
        val data = MLUtils.loadLibSVMFile(sc, "mnist_file_in_svm_format")
        val split = data.randomSplit(Array(0.9, 0.1), 11L)
        val training = split(0)
        val test = split(1)
        /* train ANN with hidden layer of 32 neurons */
        /* (input and output layer sizes will be derived from the data) */
        val model = ANNClassifier.train(train, Array[Int](32), 40, 1.0, 1e-4)
        val predictionAndLabels = test.map( lp => (model.predict(lp.features), 
lp.label))
        val metrics = new MulticlassMetrics(predictionAndLabels)
        println("Accuracy:" + metrics.precision)



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