|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.classifier.AbstractVectorClassifier
org.apache.mahout.clustering.ClusterClassifier
public class ClusterClassifier
This classifier works with any clustering Cluster. It is initialized with a list of compatible clusters and thereafter it can classify any new Vector into one or more of the clusters based upon the pdf() function which each cluster supports. In addition, it is an OnlineLearner and can be trained. Training amounts to asking the actual model to observe the vector and closing the classifier causes all the models to computeParameters.
Constructor Summary | |
---|---|
ClusterClassifier()
|
|
ClusterClassifier(List<Cluster> models)
The public constructor accepts a list of clusters to become the models |
Method Summary | |
---|---|
Vector |
classify(Vector instance)
Classify a vector returning a vector of numCategories-1 scores. |
double |
classifyScalar(Vector instance)
Classifies a vector in the special case of a binary classifier where AbstractVectorClassifier.classify(Vector) would return a vector with only one element. |
void |
close()
Prepares the classifier for classification and deallocates any temporary data structures. |
List<Cluster> |
getModels()
|
int |
numCategories()
Returns the number of categories for the target variable. |
void |
readFields(DataInput in)
|
void |
train(int actual,
Vector instance)
Updates the model using a particular target variable value and a feature vector. |
void |
train(int actual,
Vector data,
double weight)
Train the models given an additional weight. |
void |
train(long trackingKey,
int actual,
Vector instance)
Updates the model using a particular target variable value and a feature vector. |
void |
train(long trackingKey,
String groupKey,
int actual,
Vector instance)
Updates the model using a particular target variable value and a feature vector. |
void |
write(DataOutput out)
|
Methods inherited from class org.apache.mahout.classifier.AbstractVectorClassifier |
---|
classify, classifyFull, classifyFull, classifyFull, classifyNoLink, classifyScalar, logLikelihood |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClusterClassifier(List<Cluster> models)
models
- a Listpublic ClusterClassifier()
Method Detail |
---|
public Vector classify(Vector instance)
AbstractVectorClassifier
classify
in class AbstractVectorClassifier
instance
- A feature vector to be classified.
public double classifyScalar(Vector instance)
AbstractVectorClassifier
AbstractVectorClassifier.classify(Vector)
would return a vector with only one element. As such,
using this method can void the allocation of a vector.
classifyScalar
in class AbstractVectorClassifier
instance
- The feature vector to be classified.
AbstractVectorClassifier.classify(Vector)
public int numCategories()
AbstractVectorClassifier
numCategories
in class AbstractVectorClassifier
public void write(DataOutput out) throws IOException
write
in interface org.apache.hadoop.io.Writable
IOException
public void readFields(DataInput in) throws IOException
readFields
in interface org.apache.hadoop.io.Writable
IOException
public void train(int actual, Vector instance)
OnlineLearner
train
in interface OnlineLearner
actual
- The value of the target variable. This value should be in the half-open
interval [0..n) where n is the number of target categories.instance
- The feature vector for this example.public void train(int actual, Vector data, double weight)
actual
- the int index of a modeldata
- a data Vectorweight
- a double weighting factorpublic void train(long trackingKey, String groupKey, int actual, Vector instance)
OnlineLearner
train
in interface OnlineLearner
trackingKey
- The tracking key for this training example.groupKey
- An optional value that allows examples to be grouped in the computation of
the update to the model.actual
- The value of the target variable. This value should be in the half-open
interval [0..n) where n is the number of target categories.instance
- The feature vector for this example.public void train(long trackingKey, int actual, Vector instance)
OnlineLearner
train
in interface OnlineLearner
trackingKey
- The tracking key for this training example.actual
- The value of the target variable. This value should be in the half-open
interval [0..n) where n is the number of target categories.instance
- The feature vector for this example.public void close()
OnlineLearner
close
in interface Closeable
close
in interface OnlineLearner
public List<Cluster> getModels()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |