| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectemolib.util.proc.TextDataProcessor
emolib.classifier.Classifier
emolib.classifier.machinelearning.NearestCentroid
public class NearestCentroid
The NearestCentroid is a Rocchio classifier operating in the circumplex.
Once this classifier is fed with a sensible amount of examples for each class, the arithmetic mean of each emotional dimension is computed in order to provide the centroid corresponding to the class. The core of this classifier is based on a 1-NN where the examples are the centroids of the classes.
The NearestCentroid class includes a main method to train the classifier for a future use. Its training dataset is a plain text file where each row represents a training instance. The first numbers indicate the emotional dimensions while the last one represents the affective category.
For more information about this classifier, please refer to (Trilla and Alías, 2009).
 --
 (Trilla and Alías, 2009) Trilla, A. and Alías, F., "Sentiment classification in English
 from sentence-level annotations of emotions regarding models of affect", In Proceedings of the
 10th Annual Conference of the International Speech Communication Association (Interspeech 2009)
 (ISSN: 1990-9772), pp. 516-519, 2009, September, Brighton, UK.
 
KNearestNeighbour| Field Summary | |
|---|---|
| static java.lang.String | PROP_EXTERNAL_FILEProperty to indicate a pre-trained classifier. | 
| static java.lang.String | PROP_NUM_EMO_DIMSProperty to determine the number of emotional dimensions the NearestCentroid deals with. | 
| Constructor Summary | |
|---|---|
| NearestCentroid()Main constructor of this classifier. | |
| Method Summary | |
|---|---|
|  java.lang.String | getCategory(FeatureBox inputFeatures)The function that decides the most appropriate emotional category. | 
|  void | initialize()Method to initialize the Classifier. | 
|  void | load(java.lang.String path)Generic function to load a previously saved classifier. | 
| static void | main(java.lang.String[] args)Main method to train the NearestCentroid classifier. | 
|  void | newProperties(PropertySheet ps)This method is called when this configurable component has new data. | 
|  void | printSynopsis()Prints the synopsis. | 
|  void | register(java.lang.String name,
         Registry registry)Register my properties. | 
|  void | resetExamples()Method to reset the classifier and flush the training examples. | 
|  void | save(java.lang.String path)Generic method to save the fully fledged classifier into a given file path. | 
|  void | setNumberOfEmotionalDimensions(int numDims)Method to set the number of emotional dimensions. | 
|  void | trainingProcedure()Generic training procedure. | 
| Methods inherited from class emolib.classifier.Classifier | 
|---|
| applyClassification, getData, getListOfExampleCategories, getListOfExampleFeatures, inputTrainingExample, train | 
| Methods inherited from class emolib.util.proc.TextDataProcessor | 
|---|
| flush, getName, getPredecessor, setPredecessor, toString | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
public static final java.lang.String PROP_NUM_EMO_DIMS
public static final java.lang.String PROP_EXTERNAL_FILE
| Constructor Detail | 
|---|
public NearestCentroid()
| Method Detail | 
|---|
public void register(java.lang.String name,
                     Registry registry)
              throws PropertyException
Configurable
register in interface Configurableregister in class Classifiername - the name of the componentregistry - the registry for this component
PropertyException
public void newProperties(PropertySheet ps)
                   throws PropertyException
Configurable
newProperties in interface ConfigurablenewProperties in class Classifierps - a property sheet holding the new data
PropertyException - if there is a problem with the properties.public void initialize()
initialize in interface DataProcessorinitialize in class Classifierpublic void setNumberOfEmotionalDimensions(int numDims)
numDims - The number of emotional dimensions.public java.lang.String getCategory(FeatureBox inputFeatures)
Classifier
getCategory in class ClassifierinputFeatures - The input emotional features.
public void trainingProcedure()
Classifier
trainingProcedure in class Classifierpublic void save(java.lang.String path)
Classifier
save in class Classifierpath - The file path to save the classifier.public void load(java.lang.String path)
Classifier
load in class Classifierpath - The path of the file which contains the previously saved
 classifier.public void resetExamples()
Classifier
resetExamples in class Classifier
public static void main(java.lang.String[] args)
                 throws java.lang.Exception
java.lang.Exceptionpublic void printSynopsis()
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||