一,sklearn分类器
单一分类器 & 集成分类器 https://www.cnblogs.com/hhh5460/p/5132203.html
使用sklearn https://www.jianshu.com/p/516f009c0875
sklearn通过OneVsRestClassifier实现svm.SVC的多分类 https://blog.csdn.net/xiaodongxiexie/article/details/76229042
二,Grid_Search获取模型最佳参数
https://blog.csdn.net/u012897374/article/details/74999940
三,对OneVsRestClassifier策略的模型执行网格搜索
https://ask.helplib.com/python/post_12965072
当在网格搜索中使用嵌套估计量时,可以使用 __
作为分隔符来确定参数的范围。这种情况下,SVC模型作为名为 estimator
的属性存储在 OneVsRestClassifier
模型中:
from sklearn.datasets import load_iris
from sklearn.multiclass import OneVsRestClassifier
from sklearn.svm import SVC
from sklearn.grid_search import GridSearchCV
from sklearn.metrics import f1_score
iris = load_iris()
model_to_set = OneVsRestClassifier(SVC(kernel="poly"))
parameters = {
"estimator__C": [1,2,4,8],
"estimator__kernel": ["poly","rbf"],
"estimator__degree":[1, 2, 3, 4],
}
model_tunning = GridSearchCV(model_to_set, param_grid=parameters,
score_func=f1_score)
model_tunning.fit(iris.data, iris.target)
print model_tunning.best_score_
print model_tunning.best_params_