Class MultiClassNaiveBayes
- java.lang.Object
-
- eu.h2020.helios_social.core.info_control.classifier.MultiClassNaiveBayes
-
- All Implemented Interfaces:
java.io.Serializable
public class MultiClassNaiveBayes extends java.lang.Object implements java.io.SerializableMulti-class Naive Bayes text classifier- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MultiClassNaiveBayes()Creates MultiClassNaiveBayes classifierMultiClassNaiveBayes(int maxSamples)Create MultiClassNaiveBayes classifierMultiClassNaiveBayes(int maxSamples, int maxTextLength)Create MultiClassNaiveBayes classifierMultiClassNaiveBayes(int maxSamples, int maxTextLength, double alpha)Creates MultiClassNaiveBayes classifier
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSample(java.lang.String category, java.lang.String text)Adds training sample for the classifierjava.util.List<Classification>classify(java.lang.String text)Classifies the input textvoidremoveCategory(java.lang.String category)Removes a category from the training datavoidreset()Resets the classifier into initial state
-
-
-
Constructor Detail
-
MultiClassNaiveBayes
public MultiClassNaiveBayes()
Creates MultiClassNaiveBayes classifier
-
MultiClassNaiveBayes
public MultiClassNaiveBayes(int maxSamples)
Create MultiClassNaiveBayes classifier- Parameters:
maxSamples- the maximum number of training samples
-
MultiClassNaiveBayes
public MultiClassNaiveBayes(int maxSamples, int maxTextLength)Create MultiClassNaiveBayes classifier- Parameters:
maxSamples- the maximum number of training samplesmaxTextLength- the maximum length of input text for the classifier
-
MultiClassNaiveBayes
public MultiClassNaiveBayes(int maxSamples, int maxTextLength, double alpha)Creates MultiClassNaiveBayes classifier- Parameters:
maxSamples- the maximum number of training samplesmaxTextLength- the maximum length of input text for the classifieralpha- the additional smoothing term. For the so-called Lidstone smoothing alpha < 1.0 and for Laplace smoothing alpha == 1.
-
-
Method Detail
-
addSample
public void addSample(@NonNull java.lang.String category, @NonNull java.lang.String text)Adds training sample for the classifier- Parameters:
category- the classified category of the text. It corresponds to context idtext- the input text.
-
removeCategory
public void removeCategory(@NonNull java.lang.String category)Removes a category from the training data- Parameters:
category- the category (i.e. context id)
-
classify
public java.util.List<Classification> classify(@NonNull java.lang.String text)
Classifies the input text- Parameters:
text- the input text to be classified- Returns:
- the list of possible classifications with probability values
-
reset
public void reset()
Resets the classifier into initial state
-
-