There is no such thing as multiclass regression. These metrics are for classification problems and don't have meaning for regression.
On Tue, Dec 6, 2016 at 7:55 PM Md. Rezaul Karim < rezaul.ka...@insight-centre.org> wrote: > Hi Sean, > > According to Spark documentation, precision, recall, F1, true positive > rate, false positive rate etc. can be calculated using the MultiMetrics > evaluator for the multiclass classifiers also. For example in *Random > Forest *based classifier or regressor: > > // Get evaluation metrics. > MulticlassMetrics metrics = new > MulticlassMetrics(predictionAndLabels.rdd()); > //System.out.println(metrics.confusionMatrix()); > // System.out.println(metrics.confusionMatrix()); > double precision = metrics.precision(metrics.labels()[0]); > double recall = metrics.recall(metrics.labels()[0]); > double f_measure = metrics.fMeasure(); > double query_label = 2001; // it's a label or class for prediction > double TP = metrics.truePositiveRate(query_label); > double FP = metrics.falsePositiveRate(query_label); > double WTP = metrics.weightedTruePositiveRate(); > double WFP = metrics.weightedFalsePositiveRate(); > > Where the related performance measure statistics is calculated and stored > in '*predictionAndLabels*' RDD as follows: > JavaRDD<Tuple2<Object, Object>> predictionAndLabels = testData.map( > new Function<LabeledPoint, Tuple2<Object, Object>>() { > public Tuple2<Object, Object> call(LabeledPoint p) { > Double prediction = model.predict(p.features()); > return new Tuple2<Object, Object>(prediction, p.label()); > } > } > ); > And *'model'* is a Random Forest model instance trained with multiclass > regression or classification dataset. > > The current implementation of Logistic Regression supports only the binary > classification. But, Linear Regression supports/works on the dataset having > multiclass. > > I was wondering if it's possible to compute the similar metrics using the > Linear Regression based model for multiclass or binary class dataset. > > > > Regards, > _________________________________ > *Md. Rezaul Karim* BSc, MSc > PhD Researcher, INSIGHT Centre for Data Analytics > National University of Ireland, Galway > IDA Business Park, Dangan, Galway, Ireland > Web: http://www.reza-analytics.eu/index.html > <http://139.59.184.114/index.html> > > On 6 December 2016 at 11:37, Sean Owen <so...@cloudera.com> wrote: > > Precision, recall and F1 are metrics for binary classifiers, not > regression models. Can you clarify what you intend to do? > > On Tue, Dec 6, 2016, 19:14 Md. Rezaul Karim < > rezaul.ka...@insight-centre.org> wrote: > > Hi Folks, > > I have the following code snippet in Java that can calculate the precision > in Linear Regressor based model. > > Dataset<Row> predictions = model.transform(testData); > long count = 0; > for (Row r : predictions.select("features", "label", > "prediction").collectAsList()) { > count++; > } > System.out.println("precision: " + (double) (count * 100) / > predictions.count()); > > Now, I would like to compute other evaluation metrics like *Recall *and > *F1-score > *etc. How could I do that? > > > > Regards, > _________________________________ > *Md. Rezaul Karim* BSc, MSc > PhD Researcher, INSIGHT Centre for Data Analytics > National University of Ireland, Galway > IDA Business Park, Dangan, Galway, Ireland > Web: http://www.reza-analytics.eu/index.html > <http://139.59.184.114/index.html> > > >