Java, Weka: NaiveBayesUpdateable: cannot handle a number class

I am trying to use Weka's NaiveBayesUpdateable classifier. My data contains both nominal and numerical attributes:

@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 

I need to predict the number of sales (numeric!) Based on other attributes. When I run:

  // 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); 

I get an exception:

  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) 

How can I use a numeric attribute to classify Bayes in Weka?

+3
source share
1 answer

You cannot use the Bayes classifiers in Weka for numerical forecasts. None of them support this.

+1
source

Source: https://habr.com/ru/post/943652/


All Articles