我正在尝试使用scikit learn网站上的代码:
http://scikit-learn.org/stable/auto_examples/classification/plot_classifier_comparison.html
我正在使用自己的数据.我的问题是,我有两个以上的功能.如果我想"扩展"2到3或4的功能....
我越来越:
"查询数据维度必须与培训数据维度相匹配"
def machine():
with open("test.txt",'r') as csvr:
reader= csv.reader(csvr,delimiter='\t')
for i,row in enumerate(reader):
if i==0:
pass
elif '' in row[2:]:
pass
else:
liste.append(map(float,row[2:]))
a = np.array(liste)
h = .02
names = ["Nearest Neighbors", "Linear SVM", "RBF SVM", "Decision Tree",
"Random Forest", "AdaBoost", "Naive Bayes", "LDA", "QDA"]
classifiers = [
KNeighborsClassifier(1),
SVC(kernel="linear", C=0.025),
SVC(gamma=2, C=1),
DecisionTreeClassifier(max_depth=5),
RandomForestClassifier(max_depth=5, n_estimators=10, max_features=1),
AdaBoostClassifier(),
GaussianNB(),
LDA(),
QDA()]
X = a[:,:3]
y = np.ravel(a[:,13])
linearly_separable = (X, y)
datasets =[linearly_separable]
figure …Run Code Online (Sandbox Code Playgroud) 我正在使用带有分层CV的scikit-learn来比较一些分类器.我正在计算:准确性,召回,auc.
我用于参数优化GridSearchCV的5 CV.
RandomForestClassifier(warm_start= True, min_samples_leaf= 1, n_estimators= 800, min_samples_split= 5,max_features= 'log2', max_depth= 400, class_weight=None)
Run Code Online (Sandbox Code Playgroud)
是GridSearchCV的best_params.
我的问题,我想我真的很适合.例如:
具有标准差的随机森林(+/-)
- 精度:0.99(+/- 0.06)
- 灵敏度:0.94(+/- 0.06)
- 特异性:0.94(+/- 0.06)
- B_accuracy:0.94(+/- 0.06)
- AUC:0.94(+/- 0.11)
具有标准偏差的Logistic回归(+/-)
- 精度:0.88(+/- 0.06)
- 灵敏度:0.79(+/- 0.06)
- 特异性:0.68(+/- 0.06)
- B_accuracy:0.73(+/- 0.06)
- AUC:0.73(+/- 0.041)
而其他人也看起来像逻辑回归(因此他们看起来并不过分).
我的简历代码是:
for i,j in enumerate(data):
X.append(data[i][0])
y.append(float(data[i][1]))
x=np.array(X)
y=np.array(y)
def SD(values):
mean=sum(values)/len(values)
a=[]
for i in range(len(values)):
a.append((values[i]-mean)**2)
erg=sum(a)/len(values)
SD=math.sqrt(erg)
return SD,mean
for name, clf in zip(titles,classifiers):
# go through all classifiers, compute 10 folds
# the next for loop …Run Code Online (Sandbox Code Playgroud)