本文整理了Java中weka.classifiers.bayes.NaiveBayes.buildClassifier()
方法的一些代码示例,展示了NaiveBayes.buildClassifier()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NaiveBayes.buildClassifier()
方法的具体详情如下:
包路径:weka.classifiers.bayes.NaiveBayes
类名称:NaiveBayes
方法名:buildClassifier
[英]Generates the classifier.
[中]生成分类器。
代码示例来源:origin: stackoverflow.com
nB.buildClassifier(train);
代码示例来源:origin: nz.ac.waikato.cms.weka/DTNB
m_NB.buildClassifier(m_theInstances);
代码示例来源:origin: nz.ac.waikato.cms.weka/distributedWekaBase
@Test
public void testScoreWithClassifier() throws Exception {
Instances train = new Instances(new BufferedReader(new StringReader(
CorrelationMatrixMapTaskTest.IRIS)));
train.setClassIndex(train.numAttributes() - 1);
NaiveBayes bayes = new NaiveBayes();
bayes.buildClassifier(train);
WekaScoringMapTask task = new WekaScoringMapTask();
task.setModel(bayes, train, train);
assertEquals(0, task.getMissingMismatchAttributeInfo().length());
assertEquals(3, task.getPredictionLabels().size());
for (int i = 0; i < train.numInstances(); i++) {
assertEquals(3, task.processInstance(train.instance(i)).length);
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
trainingData = Filter.useFilter(instances, m_remove);
m_estimator.buildClassifier(trainingData);
代码示例来源:origin: Waikato/weka-trunk
trainingData = Filter.useFilter(instances, m_remove);
m_estimator.buildClassifier(trainingData);
代码示例来源:origin: stackoverflow.com
public class Run {
public static void main(String[] args) throws Exception {
ConverterUtils.DataSource source1 = new ConverterUtils.DataSource("./data/train.arff");
Instances train = source1.getDataSet();
// setting class attribute if the data format does not provide this information
// For example, the XRFF format saves the class attribute information as well
if (train.classIndex() == -1)
train.setClassIndex(train.numAttributes() - 1);
ConverterUtils.DataSource source2 = new ConverterUtils.DataSource("./data/test.arff");
Instances test = source2.getDataSet();
// setting class attribute if the data format does not provide this information
// For example, the XRFF format saves the class attribute information as well
if (test.classIndex() == -1)
test.setClassIndex(train.numAttributes() - 1);
// model
NaiveBayes naiveBayes = new NaiveBayes();
naiveBayes.buildClassifier(train);
// this does the trick
double label = naiveBayes.classifyInstance(test.instance(0));
test.instance(0).setClassValue(label);
System.out.println(test.instance(0).stringValue(4));
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/distributedWekaBase
@Test
public void testScoreWithClassifierSomeMissingFields() throws Exception {
Instances train = new Instances(new BufferedReader(new StringReader(
CorrelationMatrixMapTaskTest.IRIS)));
train.setClassIndex(train.numAttributes() - 1);
NaiveBayes bayes = new NaiveBayes();
bayes.buildClassifier(train);
WekaScoringMapTask task = new WekaScoringMapTask();
Remove r = new Remove();
r.setAttributeIndices("1");
r.setInputFormat(train);
Instances test = Filter.useFilter(train, r);
task.setModel(bayes, train, test);
assertTrue(task.getMissingMismatchAttributeInfo().length() > 0);
assertTrue(task.getMissingMismatchAttributeInfo().equals(
"sepallength missing from incoming data\n"));
assertEquals(3, task.getPredictionLabels().size());
for (int i = 0; i < test.numInstances(); i++) {
assertEquals(3, task.processInstance(test.instance(i)).length);
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/DTNB
m_NB.buildClassifier(m_theInstances);
内容来源于网络,如有侵权,请联系作者删除!