机器学习学习笔记

python机器学习调参GridSearchCV入门资料汇总

2017-05-16  本文已影响517人  老周算法
import pandas as pd
from sklearn import svm, datasets
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import classification_report
iris = datasets.load_iris()
parameters = {'kernel':('linear', 'rbf'), 'C':[1, 2, 4], 'gamma':[0.125, 0.25, 0.5 ,1, 2, 4]}
svr = svm.SVC()
clf = GridSearchCV(svr, parameters, n_jobs=-1)
clf.fit(iris.data, iris.target)
cv_result = pd.DataFrame.from_dict(clf.cv_results_)
with open('cv_result.csv','w') as f:
     cv_result.to_csv(f)   
print('The parameters of the best model are: ')
print(clf.best_params_)
y_pred = clf.predict(iris.data)
print(classification_report(y_true=iris.target, y_pred=y_pred))
Paste_Image.png

[Python超参数自动搜索模块GridSearchCV上手]
(http://www.cnblogs.com/nwpuxuezha/p/6618205.html)

【scikit-learn】【RandomForest】【GridSearchCV】二分类应用实例及【ROC】曲线绘制

[scikit-learn一般实例之四:使用管道和GridSearchCV选择降维]
(http://www.cnblogs.com/taceywong/p/5931304.html)

sklearn.grid_search.GridSearchCV官网
http://scikit-learn.org/stable/modules/generated/sklearn.grid_search.GridSearchCV.html#sklearn.grid_search.GridSearchCV
[关于RandomizedSearchCV 和GridSearchCV(区别:参数个数的选择方式)]
(http://www.cnblogs.com/qqhfeng/p/5754920.html)

上一篇下一篇

猜你喜欢

热点阅读