November 2018
Intermediate to advanced
300 pages
7h 42m
English
We will start with a basic linear regression model, implemented with the LinearRegression class. Similar to the classification example, we will initialize a new model instance, pass the parameters and data, and invoke the buildClassifier(Instances) method, as follows:
import weka.classifiers.functions.LinearRegression; ... data.setClassIndex(data.numAttributes() - 2);LinearRegression model = new LinearRegression(); model.buildClassifier(data); System.out.println(model);
The learned model, which is stored in the object, can be provided by calling the toString() method, as follows:
Y1 =
-64.774 * X1 +
-0.0428 * X2 +
0.0163 * X3 +
-0.089 * X4 +
4.1699 * X5 +
19.9327 * X7 +
0.2038 * X8 +
83.9329
The linear regression model ...