I have implemented a logistic regression for a classification problem. I get the same value for precision, recall and F1 score. Is it ok to have the same value? I also got this problem in implementing decision trees and random forest. There also I got same value for precision, recall and F1 score.
// Run training algorithm to build the model.
final LogisticRegressionModel model = new LogisticRegressionWithLBFGS()
.setNumClasses(13).
run(data.rdd());
//Compute raw scores on the test set.
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());
}
}
);
// Get evaluation metrics.
MulticlassMetrics metrics = new MulticlassMetrics(predictionAndLabels.rdd());
double precision = metrics.precision();
System.out.println("Precision = " + precision);
double recall = metrics.recall();
System.out.println("Recall = " + recall);
double FScore = metrics.fMeasure();
System.out.println("F Measure = " + FScore);
I am also facing the same problem. I have tried decision tree, random forest and GBT. Every time, I get the same precision, recall and F1 score. The accuracy is also the same (calculated through confusion matrix).
So, I am using my own formulas and written code to get the accuracy, precision, recall, and F1 score measures.