小编Tha*_*ana的帖子

在 Apache Spark Logistic 回归算法中获得相同的精度、召回率和 F 分数值

我已经为分类问题实现了逻辑回归。我在精度、召回率和 F1 分数上得到相同的值。具有相同的值可以吗?我在实现决策树和随机森林时也遇到了这个问题。在那里我也得到了相同的精度、召回率和 F1 分数。

// 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 = …
Run Code Online (Sandbox Code Playgroud)

apache-spark performance-measuring

4
推荐指数
1
解决办法
6982
查看次数

在Java中打印JavaPairRDD &lt;Double,Double&gt;的值

我将Spark决策树模型中描述的结果带到了JavaPairRDD中,如下所示。有人可以帮我打印JavaPairRDD预言和标签的值吗?

JavaPairRDD<Double, Double> predictionAndLabel =
                testData.mapToPair(new PairFunction<LabeledPoint, Double, Double>() {
                    @Override
                    public Tuple2<Double, Double> call(LabeledPoint p) {
                        return new Tuple2(model.predict(p.features()), p.label());
                    }
                });
Run Code Online (Sandbox Code Playgroud)

java machine-learning decision-tree apache-spark rdd

1
推荐指数
1
解决办法
5074
查看次数

有效地比较python中的两组

我有两个大整数集set1set2. 谁能告诉我下面哪一个更有效?

例子:

if(set1 == set2)
Run Code Online (Sandbox Code Playgroud)

或者

if(len(set1)==len(set2))
Run Code Online (Sandbox Code Playgroud)

python performance set

-3
推荐指数
2
解决办法
2万
查看次数