我想知道是否有任何sklearn分类器的选项,以适应使用一些超参数,并在改变一些超参数后,通过节省计算(适合)成本来改装模型。在分类中的scikit学习改装/部分适合选项
让我们说,Logistic回归是适合使用C=1e5
(logreg=linear_model.LogisticRegression(C=1e5)
),我们仅仅改变C
到C=1e3
。我想保存一些计算,因为只有一个参数被改变。
我想知道是否有任何sklearn分类器的选项,以适应使用一些超参数,并在改变一些超参数后,通过节省计算(适合)成本来改装模型。在分类中的scikit学习改装/部分适合选项
让我们说,Logistic回归是适合使用C=1e5
(logreg=linear_model.LogisticRegression(C=1e5)
),我们仅仅改变C
到C=1e3
。我想保存一些计算,因为只有一个参数被改变。
是的,有一个叫warm_start
技术,它从文件引用,意思是:
warm_start:BOOL,默认:假
当设置为True,重新使用以前的呼叫解决方案以适合初始化,否则, 只是抹去以前的解决方案。无用于线性求解器。
如文档here中所描述的,它在LogisticRegression
的可用:
sklearn.linear_model.LogisticRegression(..., warm_start=False, n_jobs=1)
所以具体的,你的情况,你会做到以下几点:
from sklearn.linear_model import LogisticRegression
# create an instance of LogisticRegression with warm_start=True
logreg= LogisticRegression(C=1e5, warm_start=True)
# you can access the C parameter's value as follows
logreg.C
# it's set to 100000.0
# ....
# train your model here by calling logreg.fit(..)
# ....
# reset the value of the C parameter as follows
logreg.C = 1e3
logreg.C
# now it's set to 1000.0
# ....
# re-train your model here by calling logreg.fit(..)
# ....
据我一直能够快速检查,它也可用于以下:
据我所知,贝叶斯超参数优化是最快的方法:https://github.com/fmfn/BayesianOptimization 。你可以为此创建一个新的问题,也许人们会有更好的想法。 – MedAli