MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / classify

Method classify

JSAT/src/jsat/classifiers/svm/extended/CPM.java:267–293  ·  view source on GitHub ↗
(DataPoint data)

Source from the content-addressed store, hash-verified

265 }
266
267 @Override
268 public CategoricalResults classify(DataPoint data)
269 {
270 Vec x = data.getNumericalValues();
271
272 double pos_score = Wp.multiply(x).add(bp).max();
273 double neg_score = Wn.multiply(x).add(bn).max();
274
275 CategoricalResults cr = new CategoricalResults(2);
276 if(neg_score > 0 && pos_score > 0)//ambigious case, lets go with larger magnitude
277 {
278 if(neg_score > pos_score)
279 cr.setProb(0, 1.0);
280 else
281 cr.setProb(1, 1.0);
282 }
283 else if(neg_score > 0)
284 cr.setProb(0, 1.0);
285 else if(pos_score > 0)
286 cr.setProb(1, 1.0);
287 else if(neg_score > pos_score )//not actually how describes in paper, but its ambigious - so lets use larger to tie break
288 //ambig b/c if no model claims ownership, we get a score of 0
289 cr.setProb(0, 1.0);
290 else
291 cr.setProb(1, 1.0);
292 return cr;
293 }
294
295 @Override
296 public double getScore(DataPoint dp)

Callers 1

testCloneMethod · 0.95

Calls 5

setProbMethod · 0.95
getNumericalValuesMethod · 0.80
maxMethod · 0.45
addMethod · 0.45
multiplyMethod · 0.45

Tested by 1

testCloneMethod · 0.76