Skip to content

Commit

Permalink
Making CPM implement binary score interface
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardRaff committed May 30, 2017
1 parent 823f28a commit adcc1d4
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion JSAT/src/jsat/classifiers/svm/extended/CPM.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.concurrent.ExecutorService;
import jsat.DataSet;
import jsat.classifiers.*;
import jsat.classifiers.calibration.BinaryScoreClassifier;
import jsat.distributions.Distribution;
import jsat.distributions.LogUniform;
import jsat.distributions.Uniform;
Expand All @@ -43,6 +44,11 @@
* hyper-planes to create a non-linear classifier. Increasing the number of
* hyper-planes increases training/prediction time, but also increases the
* amount of non-linearity the model can tolerate.<br>
* <br>
* While the CPM implements the {@link BinaryScoreClassifier} interface, the CPM
* decision algorithm does not completely lend itself to producing a natural
* score in this manner. For this reason you may observe unusual behavior from
* the CPM if you rely on this interface, compared with other approaches.
*
*
* <br>See: Kantchelian, A., Tschantz, M. C., Huang, L., Bartlett, P. L.,
Expand All @@ -52,7 +58,7 @@
* from <a href="http://dl.acm.org/citation.cfm?id=2969033.2969189">here</a>
* @author Edward Raff <[email protected]>
*/
public class CPM implements Classifier, Parameterized
public class CPM implements BinaryScoreClassifier, Classifier, Parameterized
{
private static final long serialVersionUID = 3171068484917637037L;

Expand Down Expand Up @@ -286,6 +292,17 @@ else if(neg_score > pos_score )//not actually how describes in paper, but its am
return cr;
}

@Override
public double getScore(DataPoint dp)
{
Vec x = dp.getNumericalValues();

double pos_score = Wp.multiply(x).add(bp).max();
double neg_score = Wn.multiply(x).add(bn).max();

return pos_score-neg_score;
}

@Override
public boolean supportsWeightedData()
{
Expand Down

0 comments on commit adcc1d4

Please sign in to comment.