public class NaiveBayesClassifier extends AbstractClassifier
| Constructor and Description |
|---|
NaiveBayesClassifier()
构造一个空白的贝叶斯分类器,通常准备用来进行训练
|
NaiveBayesClassifier(NaiveBayesModel naiveBayesModel)
由训练结果构造一个贝叶斯分类器,通常用来加载磁盘中的分类器
|
| Modifier and Type | Method and Description |
|---|---|
double[] |
categorize(Document document)
预测分类
|
AbstractModel |
getModel()
获取训练后的模型,可用于序列化保存或预测.
|
NaiveBayesModel |
getNaiveBayesModel()
获取训练结果
|
Map<String,Double> |
predict(String text)
预测分类
|
protected BaseFeatureData |
selectFeatures(IDataSet dataSet)
统计特征并且执行特征选择,返回一个FeatureStats对象,用于计算模型中的概率
|
void |
train(IDataSet dataSet)
训练模型
|
classify, classify, enableProbability, label, predict, train, train, trainpublic NaiveBayesClassifier(NaiveBayesModel naiveBayesModel)
naiveBayesModel - public NaiveBayesClassifier()
public NaiveBayesModel getNaiveBayesModel()
public void train(IDataSet dataSet)
IClassifierdataSet - 训练数据集public AbstractModel getModel()
IClassifierpublic Map<String,Double> predict(String text) throws IllegalArgumentException, IllegalStateException
IClassifiertext - 文本IllegalArgumentException - 参数错误IllegalStateException - 未训练模型public double[] categorize(Document document) throws IllegalArgumentException, IllegalStateException
IClassifierIllegalArgumentExceptionIllegalStateExceptionprotected BaseFeatureData selectFeatures(IDataSet dataSet)
dataSet - Copyright © 2014–2021 码农场. All rights reserved.