输入:语音的50种深层特征
大小:20000+个样本
求解器:亚当
输出类别:10(数字0至9)
隐藏层和神经元:3和100,100,100
代码:
X_train, X_test, y_train, y_test = train_test_split(Combineddatafeatures,
Combineddatalabels, test_size=0.1, random_state=1)
clf = MLPClassifier(solver='adam',hidden_layer_sizes=(100,100,100))
clf.fit(np.array(X_train), np.array(y_train))
predicted_values = clf.predict(X_test)
from sklearn.metrics import accuracy_score
score = accuracy_score(y_test,predicted_values)
print(score)
当前精度: 0.5693142575234337
如何提高样品的准确性(20262,50形状)(?) 通过微调
答案 0 :(得分:0)
进行参数调整的一种方法是使用sklearn的GridSearchCV
方法:link
它将测试您将给出的所有参数组合并输出最佳组合。
from sklearn.model_selection import GridSearchCV
X_train, X_test, y_train, y_test = train_test_split(Combineddatafeatures,
Combineddatalabels, test_size=0.1, random_state=1)
clf = MLPClassifier(solver='adam',hidden_layer_sizes=(100,100,100))
params = {
'hidden_layer_sizes' : [(100, 100, 100), (125, 125, 125)] # Every combination you want to try
}
gscv = GridSearchCV(clf, params, verbose=1)
gscv.fit(np.array(X_train), np.array(y_train))
print(gscv.best_params_)
predicted_values = gscv.predict(X_test)
from sklearn.metrics import accuracy_score
score = accuracy_score(y_test,predicted_values)
print(score)