用随机森林分类
分类方法有很多种,什么多分类逻辑回归,KNN,决策树,SVM,随机森林等, 比较好用的且比较好理解的还是随机森林,现在比较常见的有python和R的实现。原理就不解释了,废话不多说,show me the code import csv import numpy as np from sklearn.ensemble import RandomForestRegressor from sklearn import preprocessing from sklearn.utils import shuffle from sklearn.metrics import mean_squared_error, explained_variance_score def load_dataset(filename): file_reader = csv.reader(open(filename,'rt'), delimiter=',') X, y = [], [] for row in file_reader: X.append(row[0:4]) y.append(row[-1]) # Extract feature names feature_names = np.array(X[0]) return np.array(X[1:]).astype(np.float32),np.array