public class LinearBinaryCategorizer extends AbstractDiscriminantBinaryCategorizer<Vectorizable> implements VectorInputEvaluator<Vectorizable,java.lang.Boolean>, ThresholdBinaryCategorizer<Vectorizable>
LinearBinaryCategorizer class implements a binary
categorizer that is implemented by a linear function. More formally, the
classifier is parameterized by a weight vector (w) and a bias (b) and
computes the output for a given input (x) as:
f(x) = w * x + b
The categorization is done by:
f(x) >= 0| Modifier and Type | Field and Description |
|---|---|
protected double |
bias
The bias term.
|
static double |
DEFAULT_BIAS
The default bias is 0.0.
|
protected Vector |
weights
The weight vector.
|
BINARY_CATEGORIES| Constructor and Description |
|---|
LinearBinaryCategorizer()
Creates a new instance of LinearBinaryCategorizer.
|
LinearBinaryCategorizer(LinearBinaryCategorizer other)
Creates a new copy of a LinearBinaryCategorizer.
|
LinearBinaryCategorizer(Vector weights,
double bias)
Creates a new instance of LinearBinaryCategorizer with the given weights
and bias.
|
| Modifier and Type | Method and Description |
|---|---|
LinearBinaryCategorizer |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
double |
evaluateAsDouble(Vector input)
A convenience method for evaluating a Vector object as a double, thus
avoiding the convertToVector call from Vectorizable.
|
double |
evaluateAsDouble(Vectorizable input)
Categorizes the given input vector as a double by:
weights * input + bias
|
double |
getBias()
Gets the bias term.
|
int |
getInputDimensionality()
Gets the expected dimensionality of the input vector to the evaluator,
if it is known.
|
double |
getThreshold()
Gets the threshold, which is the negative of the bias.
|
Vector |
getWeights()
Gets the weight vector.
|
void |
setBias(double bias)
Sets the bias term.
|
void |
setThreshold(double threshold)
Sets the threshold, which is the negative of the bias.
|
void |
setWeights(Vector weights)
Sets the weight vector.
|
java.lang.String |
toString() |
evaluate, evaluateWithDiscriminantgetCategoriesequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitevaluateWithDiscriminantgetCategoriespublic static final double DEFAULT_BIAS
protected Vector weights
protected double bias
public LinearBinaryCategorizer()
public LinearBinaryCategorizer(Vector weights, double bias)
weights - The weight vector.bias - The bias term.public LinearBinaryCategorizer(LinearBinaryCategorizer other)
other - The LinearBinaryCategorizer to copy.public LinearBinaryCategorizer clone()
AbstractCloneableSerializableObject class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone() to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone() as the basis for your implementation.clone in interface CloneableSerializableclone in class AbstractCloneableSerializablepublic double evaluateAsDouble(Vectorizable input)
evaluateAsDouble in interface DiscriminantBinaryCategorizer<Vectorizable>input - The input vector to categorize.public double evaluateAsDouble(Vector input)
input - The input value to convert to a vector.public int getInputDimensionality()
VectorInputEvaluatorgetInputDimensionality in interface VectorInputEvaluator<Vectorizable,java.lang.Boolean>public double getThreshold()
getThreshold in interface ThresholdBinaryCategorizer<Vectorizable>public void setThreshold(double threshold)
setThreshold in interface ThresholdBinaryCategorizer<Vectorizable>threshold - the threshold, which is the negative of the bias.public Vector getWeights()
public void setWeights(Vector weights)
weights - The weight vector.public double getBias()
public void setBias(double bias)
bias - The bias term.public java.lang.String toString()
toString in class java.lang.Object