Ich verwende Scikit-Learn mit einem geschichteten Lebenslauf, um einige Klassifikatoren zu vergleichen. < /p>
Ich habe für das ParameteroptimierungsgridSearchCV mit einem 5 cv. < /p>
verwendetRandomForestClassifier(warm_start= True, min_samples_leaf= 1, n_estimators= 800, min_samples_split= 5,max_features= 'log2', max_depth= 400, class_weight=None)
< /code>
sind die Best_params aus der GridSearchCV. Zum Beispiel: < /p>
Zufälliger Wald mit Standardabweichung (+/-) < /p>
[*] Genauigkeit: 0,99 (+/- 0,06)
[*] Empfindlichkeit: 0,94 (+/- 0,06)
[*] Spezifität: 0,94 (+/- 0,06)
[*] b_accuracy: 0.94 (+/- 0,06)
[*] AUC: 0.94 (+/- 0,11)
< /ul>
Logistische Regression mit Standardabweichung (+/-) < /p>
[*] Genauigkeit: 0,88 (+/- 0,06)
[*] Empfindlichkeit: 0,79 (+/- 0,06)
[*] Spezifität: 0,68 (+/- 0,06)
[*] b_accuracy: 0,73 (+/- 0,06)
[*] AUC: 0,73 (+/- 0,041)
< /blockquote>
Und die anderen sehen ebenfalls wie logistische Regression aus (so sehen sie nicht übereingestaltet aus). < /p>
Mein Code für CV ist: < /p>
for i,j in enumerate(data):
X.append(data[0])
y.append(float(data[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-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 should be 1 tab indent more, coudlnt realy format it here, sorry
pre,sen,spe,ba,area=[],[],[],[],[]
for train_index, test_index in skf:
#print train_index, test_index
#get the index from all train_index and test_index
#change them to list due to some errors
train=train_index.tolist()
test=test_index.tolist()
X_train=[]
X_test=[]
y_train=[]
y_test=[]
for i in train:
X_train.append(x)
for i in test:
X_test.append(x)
for i in train:
y_train.append(y)
for i in test:
y_test.append(y)
#clf=clf.fit(X_train,y_train)
#predicted=clf.predict_proba(X_test)
#... other code, calculating metrics and so on...
print name
print("precision: %0.2f \t(+/- %0.2f)" % (SD(pre)[1], SD(pre)[0]))
print("sensitivity: %0.2f \t(+/- %0.2f)" % (SD(sen)[1], SD(pre)[0]))
print("specificity: %0.2f \t(+/- %0.2f)" % (SD(spe)[1], SD(pre)[0]))
print("B_accuracy: %0.2f \t(+/- %0.2f)" % (SD(ba)[1], SD(pre)[0]))
print("AUC: %0.2f \t(+/- %0.2f)" % (SD(area)[1], SD(area)[0]))
print "\n"
< /code>
Wenn ich die Scores = cross_validation.cross_val_score (clf, x, y, cv = 10, Scoring = 'Accuracy') < /code> Methode, i verwende, i. Erhalten Sie diese "Überanpassungs" -Werte nicht. Vielleicht stimmt in der CV -Methode, die ich verwende, etwas nicht? Aber es ist nur für RF ... < /p>
Ich habe meine eigene aufgrund der Verzögerung der Spezifitätsbewertungsfunktion in der cross_val_function gemacht. < /P>
Zufallswald ist überpassend ⇐ Python
-
- Similar Topics
- Replies
- Views
- Last post