资源简介
一个基于LIBSVM的股票价格预测程序,采用随机森林算法对样本进行训练和预测,使用的编程语言为JAVA。
代码片段和文件信息
package classifiers;
import weka.classifiers.bayes.NaiveBayes;
import weka.classifiers.functions.LibSVM;
import weka.classifiers.functions.Logistic;
import weka.classifiers.functions.MultilayerPerceptron;
import weka.classifiers.meta.AdaBoostM1;
import weka.classifiers.trees.J48;
import weka.classifiers.trees.RandomForest;
import weka.core.Instances;
public class Classifiers {
/**
* 训练Logistic Regression 分类器
*
* @param train
* 训练集
* @return 训练好的分类器
*
* @throws Exception
*/
public static Logistic logistic_regression(Instances train) throws Exception {
System.out.println(“Logistic Regression Training.......“);
Logistic logistic = new Logistic();
logistic.setRidge(0.8);
logistic.buildClassifier(train);
System.out.println(“Logistic Regression Training End.......“);
return logistic;
}
/**
* 训练SVM分类器
*
* @param train
* 训练集
* @return 训练好的分类器
* @throws Exception
*/
public static LibSVM SVM(Instances train) throws Exception {
System.out.println(“SVM Training.......“);
LibSVM libsvm = new LibSVM();
libsvm.setCost(100);
libsvm.buildClassifier(train);
System.out.println(“SVM Training End.......“);
return libsvm;
}
/**
* 训练随机森林分类器
*
* @param train
* 训练集
* @return 训练好的分类器
* @throws Exception
*/
public static RandomForest random_forest(Instances train) throws Exception {
System.out.println(“RandomForest Training.......“);
RandomForest forest = new RandomForest();
forest.setNumTrees(100);
// forest.setMaxDepth(10);
forest.buildClassifier(train);
System.out.println(“RandomForest Training End.......“);
return forest;
}
/**
* 训练朴素贝叶斯分类器
*
* @param train
* 训练集
* @return 训练好的分类器
* @throws Exception
*/
public static NaiveBayes naive_bayes(Instances train) throws Exception {
System.out.println(“Naive Bayes Training.......“);
NaiveBayes bayes = new NaiveBayes();
bayes.buildClassifier(train);
System.out.println(“Naive Bayes Training End.......“);
return bayes;
}
/**
* 训练BP神经网络分类器
*
* @param train
* 训练集
* @return 训练好的分类器
* @throws Exception
*/
public static MultilayerPerceptron BP(Instances train) throws Exception {
System.out.println(“BP Training.......“);
MultilayerPerceptron mlp = new MultilayerPerceptron();
mlp.buildClassifier(train);
System.out.println(“BP Training End.......“);
return mlp;
}
/**
* 训练C4.5决策树分类器
*
* @param train
* 训练集
* @return 训练好的分类器
* @throws Exception
*/
public static J48 decision_tree(Instances train) throws Exception {
System.out.println(“C4.5 Training.......“);
J48 tree = new J48();
tree.buildClassifier(train);
System.out.println(“C4.5 Training End.......“);
return tree;
}
/**
* 训练Adaboost组合分类器
*
* @param train
* 训练集
* @return 训练好的分类器
* @throws Exception
*/
public static AdaBoostM1 Ada_boost(Instances train) throws Exception {
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 455 2015-11-10 22:40 stock-master\.classpath
....... 364 2015-11-10 22:40 stock-master\.project
文件 144 2016-08-09 00:32 stock-master\.settings\org.eclipse.core.resources.prefs
....... 587 2015-11-10 22:40 stock-master\.settings\org.eclipse.jdt.core.prefs
....... 211985 2015-11-10 22:40 stock-master\data\000752.csv
....... 65681 2015-11-10 22:40 stock-master\data\300251.csv
....... 44707 2015-11-10 22:40 stock-master\data\300329.csv
....... 7694 2015-11-10 22:40 stock-master\data\300431.csv
....... 4531 2015-11-10 22:40 stock-master\data\603616.csv
....... 6992343 2015-11-10 22:40 stock-master\data\feature\simple120_3_day.arff
文件 10940099 2016-08-09 00:35 stock-master\data\feature\szzs_simple120_3_day.arff
....... 333842 2015-11-10 22:40 stock-master\data\szzs.csv
....... 341832 2015-11-10 22:40 stock-master\data\szzs_new.csv
文件 352227 2016-08-08 23:15 stock-master\data\table.csv
....... 381303 2015-11-10 22:40 stock-master\lib\javaml-0.1.7.jar
....... 51628 2015-11-10 22:40 stock-master\lib\libsvm.jar
....... 6555904 2015-11-10 22:40 stock-master\lib\weka.jar
....... 372 2015-11-10 22:40 stock-master\README.md
文件 3446 2016-08-09 00:32 stock-master\src\classifiers\Classifiers.java
文件 781 2016-08-09 00:33 stock-master\src\feature\Feature.java
文件 1065 2016-08-09 00:33 stock-master\src\label\RiseFallLabel.java
文件 1071 2016-08-09 00:35 stock-master\src\test\ContinueStop.java
文件 3740 2016-08-09 00:29 stock-master\src\test\Predict.java
文件 890 2016-08-09 00:29 stock-master\src\test\Stop.java
文件 1188 2016-08-09 00:34 stock-master\src\util\Price.java
文件 633 2016-08-09 00:33 stock-master\src\util\ReadWriteFile.java
目录 0 2015-11-10 22:40 stock-master\data\feature
目录 0 2015-11-10 22:40 stock-master\src\classifiers
目录 0 2015-11-10 22:40 stock-master\src\feature
目录 0 2015-11-10 22:40 stock-master\src\label
............此处省略11个文件信息
- 上一篇:android 象棋
- 下一篇:jca457.jar
评论
共有 条评论