Since you didn’t provide all relevant information, I’ll take a shot in the dark:
I’m assuming that you’re using Weka version 3.7.5 and I found the following source code for Logistic.java
online
public double [] distributionForInstance(Instance instance) throws Exception {
// line 710
m_ReplaceMissingValues.input(instance);
instance = m_ReplaceMissingValues.output();
...
}
Assuming you didn’t pass null
for instance
, this only leaves m_ReplaceMissingValues
. That member is initialized when the method Logistic.buildClassifier(Instances train)
is called:
public void buildClassifier(Instances train) throws Exception {
...
// missing values
m_ReplaceMissingValues = new ReplaceMissingValues();
m_ReplaceMissingValues.setInputFormat(train);
train = Filter.useFilter(train, m_ReplaceMissingValues);
...
}
It looks like you’ve never trained your classifier Logistic
on any data after you created the object in the line
Classifier cls = (Classifier) Utils.forName(Classifier.class, classname, tmpOptions);
1
solved Nullpointer exception while using Weka classifier