Support class Passive Aggressive (SPA) is a multi class generalization of PassiveAggressive. It works in the same philosophy, and can obtain better multi class accuracy then PA used with a meta learner. SPA is more sensitive to small values for the {@link #setC(double) aggressiveness p
| 32 | * @author Edward Raff |
| 33 | */ |
| 34 | public class SPA extends BaseUpdateableClassifier implements Parameterized, SimpleWeightVectorModel |
| 35 | { |
| 36 | |
| 37 | private static final long serialVersionUID = 3613279663279244169L; |
| 38 | private Vec[] w; |
| 39 | private double[] bias; |
| 40 | private double C = 1; |
| 41 | private boolean useBias = false; |
| 42 | private PassiveAggressive.Mode mode; |
| 43 | |
| 44 | /** |
| 45 | * Creates a new Passive Aggressive learner that does 10 epochs and uses |
| 46 | * PA2. |
| 47 | */ |
| 48 | public SPA() |
| 49 | { |
| 50 | this(10, PassiveAggressive.Mode.PA2); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Creates a new Passive Aggressive learner |
| 55 | * |
| 56 | * @param epochs the number of training epochs to use during batch training |
| 57 | * @param mode which version of the update to perform |
| 58 | */ |
| 59 | public SPA(int epochs, PassiveAggressive.Mode mode) |
| 60 | { |
| 61 | setEpochs(epochs); |
| 62 | setMode(mode); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Sets whether or not the implementation will use an implicit bias term |
| 67 | * appended to the inputs or not. |
| 68 | * @param useBias {@code true} to add an implicit bias term, {@code false} |
| 69 | * to use the data as given |
| 70 | */ |
| 71 | public void setUseBias(boolean useBias) |
| 72 | { |
| 73 | this.useBias = useBias; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Returns true if an implicit bias term will be added, false otherwise |
| 78 | * @return true if an implicit bias term will be added, false otherwise |
| 79 | */ |
| 80 | public boolean isUseBias() |
| 81 | { |
| 82 | return useBias; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Set the aggressiveness parameter. Increasing the value of this parameter |
| 87 | * increases the aggressiveness of the algorithm. It must be a positive |
| 88 | * value. This parameter essentially performs a type of regularization on |
| 89 | * the updates |
| 90 | * <br> |
| 91 | * An infinitely large value is equivalent to being completely aggressive, |
nothing calls this directly
no outgoing calls
no test coverage detected