grid search

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了grid search相关的知识,希望对你有一定的参考价值。

sklearn.metrics.make_scorer(score_funcgreater_is_better=Trueneeds_proba=Falseneeds_threshold=False**kwargs)[source]?

>>> from sklearn.metrics import fbeta_score, make_scorer >>> ftwo_scorer = make_scorer(fbeta_score, beta=2) >>> ftwo_scorer make_scorer(fbeta_score, beta=2) >>> from sklearn.model_selection import GridSearchCV >>> from sklearn.svm import LinearSVC >>> grid = GridSearchCV(LinearSVC(), param_grid={‘C‘: [1, 10]}, ... scoring=ftwo_scorer)

fbeta_score 可以自定义。
 
>>> from sklearn.metrics import fbeta_score
>>> y_true = [0, 1, 2, 0, 1, 2]
>>> y_pred = [0, 2, 1, 0, 0, 1]
>>> fbeta_score(y_true, y_pred, average=‘macro‘, beta=0.5)
 

以上是关于grid search的主要内容,如果未能解决你的问题,请参考以下文章

了解 sklearn grid_search

grid search 超参数寻优

grid search

grid-search建模过程中自动调优

Grid Search学习

代码翻译