3
我想從Weka使用NaiveBayesUpdateable分類器。我的數據包含名義和數字屬性:Java,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的貝葉斯分類?
如果我在'N'長度爲'k'的區間中分割數值屬性的值,我可以使用名義屬性,其中'n'是一個類名,像這樣:'@attribute class {1,2,3 ,...,N}'? Weka中這個'N'有多大? – 2013-04-11 19:50:05
你可以和它一樣大,只要你真的喜歡。請注意,在這種情況下不推薦這樣做,因爲您明確預測了數字量。 – 2013-04-12 08:06:01
你會推薦什麼算法來預測數字質量? – 2013-04-12 09:30:52