public class LinearRegressionExample {
public static void main(String[] args) throws Exception {
// 加载数据集
DataSource source = new DataSource(path/to/your/dataset.arff);
Instances data = source.getDataSet();
if (data.classIndex() == 1)
data.setClassIndex(data.numAttributes() 1);
// 创建线性回归模型
LinearRegression model = new LinearRegression();
// 训练模型
model.buildClassifier(data);
// 输出模型信息
System.out.println(model);
}
}
5、学习资源
官方文档:查看相关库的官方文档。
教程和书籍:《HandsOn Machine Learning with Java》等书籍。
在线课程:Coursera、Udemy等平台上的Java AI课程。