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

Method classify

JSAT/src/jsat/classifiers/DDAG.java:41–72  ·  view source on GitHub ↗
(DataPoint data)

Source from the content-addressed store, hash-verified

39 }
40
41 @Override
42 public CategoricalResults classify(DataPoint data)
43 {
44 CategoricalResults cr = new CategoricalResults(predicting.getNumOfCategories());
45
46 //Use a priority que so that we always pick the two lowest value class labels, makes indexing into the oneVsOne array simple
47 PriorityQueue<Integer> options = new PriorityQueue<Integer>(predicting.getNumOfCategories());
48 for(int i = 0; i < cr.size(); i++)
49 options.add(i);
50
51
52 CategoricalResults subRes;
53 int c1, c2;
54 //We will now loop through and repeatedly pick two combinations, and eliminate the loser, until there is one winer
55 while(options.size() > 1)
56 {
57 c1 = options.poll();
58 c2 = options.poll();
59
60 subRes = oneVone[c1][c2-c1-1].classify(data);
61
62 if(subRes.mostLikely() == 0)//c1 wins, c2 no longer a candidate
63 options.add(c1);
64 else//c2 wins, c1 no onger a candidate
65 options.add(c2);
66 }
67
68 cr.setProb(options.peek(), 1.0);
69
70
71 return cr;
72 }
73
74 @Override
75 public DDAG clone()

Callers 1

testCloneMethod · 0.95

Calls 9

sizeMethod · 0.95
mostLikelyMethod · 0.95
setProbMethod · 0.95
getNumOfCategoriesMethod · 0.80
pollMethod · 0.80
peekMethod · 0.80
sizeMethod · 0.65
classifyMethod · 0.65
addMethod · 0.45

Tested by 1

testCloneMethod · 0.76