以下の内容はhttps://paper.hatenadiary.jp/entry/2016/10/21/022552より取得しました。


pythonで分類問題のハイパーパラメータをグリッドサーチで見つける

内容が薄いのでコードのみ。 sklearn.__vsrsion__==0.18である必要あり。

from sklearn.pipeline import Pipeline
from sklearn.decomposition import PCA, NMF
from sklearn.preprocessing import PolynomialFeatures
from sklearn.feature_selection import SelectKBest, chi2
from sklearn.model_selection import GridSearchCV

pipeline = Pipeline([
    ('poly_feat', PolynomialFeatures(2)),
    ('reduce_dim', PCA()),
    ('clf', slm.Ridge()),
])

params = dict(reduce_dim__n_components=[2, 5, 10],
              clf__alpha=[0.1, 10, 100])

grid_search = GridSearchCV(pipeline, param_grid=params).fit(train_X, train_y)
prd = grid_search.predict(test_X)



以上の内容はhttps://paper.hatenadiary.jp/entry/2016/10/21/022552より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14