资源简介
超详细的logistic regression java代码 带数据集,外文网站找了n天找到的
代码片段和文件信息
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
* Created with IntelliJ IDEA.
* User: tpeng
* Date: 6/22/12
* Time: 11:01 PM
* To change this template use File | Settings | File Templates.
*/
public class DataSet {
public static List readDataSet(String file) throws FileNotFoundException {
List dataset = new ArrayList();
Scanner scanner = new Scanner(new File(file));
while(scanner.hasNextLine()) {
String line = scanner.nextLine();
if (line.startsWith(“#“)) {
continue;
}
String[] columns = line.split(“\\s+“);
// skip first column and last column is the label
int i = 1;
int[] data = new int[columns.length-2];
for (i=1; i data[i-1] = Integer.parseInt(columns[i]);
}
int label = Integer.parseInt(columns[i]);
Instance instance = new Instance(label data);
dataset.add(instance);
}
return dataset;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-06-28 09:53 logistic-regression-master\
文件 96 2012-06-28 09:53 logistic-regression-master\README.md
文件 5528 2012-06-28 09:53 logistic-regression-master\dataset.txt
目录 0 2012-06-28 09:53 logistic-regression-master\src\
文件 1216 2012-06-28 09:53 logistic-regression-master\src\DataSet.java
文件 427 2012-06-28 09:53 logistic-regression-master\src\Instance.java
文件 2069 2012-06-28 09:53 logistic-regression-master\src\Logistic.java
评论
共有 条评论