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

Class OneVSOne

JSAT/src/jsat/classifiers/OneVSOne.java:25–220  ·  view source on GitHub ↗

A One VS One classifier extends binary decision classifiers into multi-class decision classifiers. This is done by creating a binary-classification problem for every possible pair of classes, and then classifying by taking the result of all possible combinations and choosing the class that got the m

Source from the content-addressed store, hash-verified

23 * @author Edward Raff
24 */
25public class OneVSOne implements Classifier, Parameterized
26{
27
28 private static final long serialVersionUID = 733202830281869416L;
29 /**
30 * Main binary classifier
31 */
32 @ParameterHolder
33 protected Classifier baseClassifier;
34 /**
35 * Uper-diagonal matrix of classifiers sans the first index since a
36 * classifier vs itself is useless. First index is the first dimensions is
37 * the first class, 2nd index + the value of the first + 1 is the opponent
38 * class
39 */
40 protected Classifier[][] oneVone;
41 private boolean concurrentTrain;
42 protected CategoricalData predicting;
43
44 /**
45 * Creates a new One-vs-One classifier
46 * @param baseClassifier the binary classifier to extend
47 */
48 public OneVSOne(Classifier baseClassifier)
49 {
50 this(baseClassifier, false);
51 }
52
53 /**
54 * Creates a new One-vs-One classifier
55 * @param baseClassifier the binary classifier to extend
56 * @param concurrentTrain <tt>true</tt> to have training of individual
57 * classifiers occur in parallel, <tt>false</tt> to have them use their
58 * native parallel training method.
59 */
60 public OneVSOne(Classifier baseClassifier, boolean concurrentTrain)
61 {
62 this.baseClassifier = baseClassifier;
63 this.concurrentTrain = concurrentTrain;
64 }
65
66 /**
67 * Controls whether or not training of the several classifiers occurs concurrently or sequentually.
68 * @param concurrentTrain <tt>true</tt> to have training of individual
69 * classifiers occur in parallel, <tt>false</tt> to have them use their
70 * native parallel training method.
71 */
72 public void setConcurrentTraining(boolean concurrentTrain)
73 {
74 this.concurrentTrain = concurrentTrain;
75 }
76
77 /**
78 *
79 * @return <tt>true</tt> if training of individual
80 * classifiers occur in parallel, <tt>false</tt> they use their
81 * native parallel training method.
82 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected