Generating logistic regression models
Weka has a class named Logistic, which can be used for building and using a multinomial logistic regression model with a ridge estimator. Although the original logistic regression does not deal with instance weights, the algorithm in Weka has been modified to handle the instance weights.
In this recipe, we will use Weka to generate a logistic regression model on the iris dataset.
How to do it...
We will be generating a logistic regression model from the
iris
dataset, which can be found in thedata
directory in the installed folder of Weka.Our code will have two instance variables: one will be containing the data instances of the iris dataset, and the other will be the logistic regression classifier:
Instances iris = null; Logistic logReg ;
We will be using a method to load and read the dataset, as well as to assign its class attribute (the last attribute of theÂ
iris.arff
file):public void loadArff(String arffInput){ &...