[Java-ML-support] NullPointerException during NaiveBayesClassifier.buildClassifier()
Status: Beta
Brought to you by:
thomasabeel
From: Tom D. <tom...@gm...> - 2012-11-11 21:29:55
|
I am new to Java-ML, so I apologize if the answer to this is trivial: I'm trying to construct and use a Classifier in the following way: // Construct an instance of the selected classifier Classifier c = constructClassifier(classifier); // This returns a NaiveBayesClassifier ... // Build a training Dataset for the symbol using the historical data Dataset trainingData = buildTrainingDataset(dataArr, sampleIntervalWidth, futureDays); ... // Train the classifier c.buildClassifier(trainingData); // NullPointerException happens here ... // Now, classify against the latest sample DenseInstance latestSample = new DenseInstance(buildSampleDoubleArr(dataArr, dataArr.length - sampleIntervalWidth - 1, sampleIntervalWidth)); ... // Store the result results.put(s, (Double)c.classify(latestSample)); Each time I try this, I seem to be getting a NullPointerException from the innards of AbstractBayesianClassifier with the following stack trace: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at net.sf.javaml.classification.bayes.AbstractBayesianClassifier.calculateClassFreqs(AbstractBayesianClassifier.java:207) at net.sf.javaml.classification.bayes.AbstractBayesianClassifier.buildClassifier(AbstractBayesianClassifier.java:103) at net.sf.javaml.classification.bayes.NaiveBayesClassifier.buildClassifier(NaiveBayesClassifier.java:42) at tdeering.iastate.cs572.ainvestor.engine.Engine.rank(Engine.java:106) Can anyone tell me what I am doing wrong? Am I missing a step where I tell my Classfier about all possible classes? Thanks, Tom |