You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by kundan kumar <ii...@gmail.com> on 2016/09/05 10:28:51 UTC
Unable to get raw probabilities after clearing model threshold
Hi,
I am unable to get the raw probabilities despite of clearing the threshold.
Its still printing the predicted label.
Can someone help resolve this issue.
Here is the code snippet.
LogisticRegressionWithSGD lrLearner = new LogisticRegressionWithSGD();
LogisticRegressionModel model = lrLearner.run(labeledPointTrain.rdd());
model.clearThreshold();
JavaRDD<Tuple2<Object, Object>> predictionAndLabels = labeledPointTrain.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());
}
}
);
predictionAndLabels.foreach(new VoidFunction<Tuple2<Object, Object>>(){
@Override
public void call(Tuple2<Object, Object> pred) throws Exception {
logger.error("PREDICTION:" + pred._1() + " ACTUAL LABEL:" + pred._2());
}
});
Thanks,
Kundan
Re: Unable to get raw probabilities after clearing model threshold
Posted by kundan kumar <ii...@gmail.com>.
Sorry, my bad.
The issue got resolved.
Thanks,
Kundan
On Mon, Sep 5, 2016 at 3:58 PM, kundan kumar <ii...@gmail.com> wrote:
> Hi,
>
> I am unable to get the raw probabilities despite of clearing the
> threshold. Its still printing the predicted label.
>
> Can someone help resolve this issue.
>
> Here is the code snippet.
>
> LogisticRegressionWithSGD lrLearner = new LogisticRegressionWithSGD();
> LogisticRegressionModel model = lrLearner.run(labeledPointTrain.rdd());
> model.clearThreshold();
> JavaRDD<Tuple2<Object, Object>> predictionAndLabels =
> labeledPointTrain.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());
> }
> }
> );
>
>
> predictionAndLabels.foreach(new VoidFunction<Tuple2<Object, Object>>(){
>
> @Override
> public void call(Tuple2<Object, Object> pred) throws Exception {
> logger.error("PREDICTION:" + pred._1() + " ACTUAL LABEL:" + pred._2());
>
> }
> });
>
>
>
> Thanks,
> Kundan
>