機械学習アルゴリズムをJavaで作成してください。
iris_data.csv (150行, 4列)
import java.io.*;
import java.util.*;
import java.nio.file.*;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;
import org.apache.commons.math3.linear.*;

// Read csv file into memory 
Reader reader = Files.newBufferedReader(Paths.get("iris_data.csv"));
CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT);

RealMatrix X = new Array2DRowRealMatrix(150, 4);
double[][] y = new double[150][1];

// Parse the csv file and store data into arrays
int line = 0;
for (CSVRecord csvRecord : csvParser) {
    for (int i = 0; i < 4; i++) {
        X.setEntry(line, i, Double.parseDouble(csvRecord.get(i)));
    }
    y[line][0] = Double.parseDouble(csvRecord.get(4));
    line++;
}

// Train the model
LinearRegression lr = new LinearRegression();
lr.fit(X, y);

// Evaluate the model
double error = lr.score(X, y);
System.out.println("Model accuracy: "+error);