gpt4 book ai didi

Java,维卡 : NaiveBayesUpdateable: Cannot handle numeric class

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:09:30 29 4
gpt4 key购买 nike

我正在尝试使用 Weka 的 NaiveBayesUpdateable 分类器。我的数据包含名义属性和数字属性:

  @relation cars
@attribute country {FR, UK, ...}
@attribute city {London, Paris, ...}
@attribute car_make {Toyota, BMW, ...}
@attribute price numeric %% car price
@attribute sales numeric %% number of cars sold

我需要根据其他属性预测销售额(数字!)。当我运行时:

    // Train classifier
ArffLoader loader = new ArffLoader();
loader.setFile(new File(trainFileName));
Instances structure = loader.getStructure();
structure.setClassIndex(structure.numAttributes() - 1);

// train NaiveBayes
NaiveBayesUpdateable nb = new NaiveBayesUpdateable();
nb.setUseKernelEstimator(true);
nb.buildClassifier(structure);

我得到异常:

  Exception in thread "main" weka.core.UnsupportedAttributeTypeException: weka.classifiers.bayes.NaiveBayesUpdateable: Cannot handle numeric class!
at weka.core.Capabilities.test(Capabilities.java:954)
at weka.core.Capabilities.test(Capabilities.java:1110)
at weka.core.Capabilities.test(Capabilities.java:1023)
at weka.core.Capabilities.testWithFail(Capabilities.java:1302)
at weka.classifiers.bayes.NaiveBayes.buildClassifier(NaiveBayes.java:213)
at foo.bar.IncrementalClassifier.trainEvalPredict(IncrementalClassifier.java:65)
at foo.bar.IncrementalClassifier.main(IncrementalClassifier.java:36)

如何在 Weka 中使用数字属性进行贝叶斯分类?

最佳答案

您不能使用 Weka 中的贝叶斯分类器进行数值预测。他们都不支持这一点。

关于Java,维卡 : NaiveBayesUpdateable: Cannot handle numeric class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15956537/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com