-
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making CPM implement binary score interface
- Loading branch information
1 parent
823f28a
commit adcc1d4
Showing
1 changed file
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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., | ||
|
@@ -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; | ||
|
||
|
@@ -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() | ||
{ | ||
|