Skip to content

Commit f3b95b0

Browse files
author
Kevin Lee
committed
directly take pairwise prob as multiclass prob when nr_class is 2
1 parent 06afca2 commit f3b95b0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

java/libsvm/svm.m4

+7-1
Original file line numberDiff line numberDiff line change
@@ -2428,7 +2428,13 @@ public class svm {
24282428
pairwise_prob[j][i]=1-pairwise_prob[i][j];
24292429
k++;
24302430
}
2431-
multiclass_probability(nr_class,pairwise_prob,prob_estimates);
2431+
if (nr_class == 2)
2432+
{
2433+
prob_estimates[0] = pairwise_prob[0][1];
2434+
prob_estimates[1] = pairwise_prob[1][0];
2435+
}
2436+
else
2437+
multiclass_probability(nr_class,pairwise_prob,prob_estimates);
24322438
24332439
int prob_max_idx = 0;
24342440
for(i=1;i<nr_class;i++)

svm.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -2612,7 +2612,13 @@ double svm_predict_probability(
26122612
pairwise_prob[j][i]=1-pairwise_prob[i][j];
26132613
k++;
26142614
}
2615-
multiclass_probability(nr_class,pairwise_prob,prob_estimates);
2615+
if (nr_class == 2)
2616+
{
2617+
prob_estimates[0] = pairwise_prob[0][1];
2618+
prob_estimates[1] = pairwise_prob[1][0];
2619+
}
2620+
else
2621+
multiclass_probability(nr_class,pairwise_prob,prob_estimates);
26162622

26172623
int prob_max_idx = 0;
26182624
for(i=1;i<nr_class;i++)

0 commit comments

Comments
 (0)