我有一个名为X的DataFrame和一组名为Y的目标值。
对于我的大多数模型,我都是这样做的(只是一个例子):
from sklearn.linear_model import LassoCV
clf = LassoCV()
score = cross_val_score(estimator = clf, X = X, y = Y, cv = KFold(n_splits = 3, random_state = 100), n_jobs = -1, \
scoring = "neg_mean_squared_error")
np.mean([np.sqrt(-x) for x in score])我正在尝试以类似的方式使用TPOT,如下所示:
from tpot import TPOTRegressor
tpot = TPOTRegressor(generations=20, population_size=100, verbosity=2)
score = cross_val_score(estimator = tpot, X = X, y = Y, cv = KFold(n_splits = 3, random_state = 100), n_jobs = -1, \
scoring = "neg_mean_squared_error")
np.mean([np.sqrt(-x) for x in score])TPOT启动,但随后显示以下酸洗错误:
PicklingError: Can't pickle <type 'instancemethod'>: it's not found as __builtin__.instancemethod你知道为什么会发生这种情况/如何让TPOT更好地发挥作用吗?
谢谢!
发布于 2017-07-10 18:31:59
如果您使用的是Python 2,请尝试:
import dill 这样就可以对lambda函数进行酸洗……对我来说很有效。
在Python 3中,您可能需要:
import dill as pickle发布于 2017-07-25 18:58:04
尝试使用:tpot.fitted_pipeline_
from tpot import TPOTRegressor
tpot = TPOTRegressor(generations=20, population_size=100, verbosity=2)
score = cross_val_score(estimator = tpot.fitted_pipeline_, X = X, y = Y, cv = KFold(n_splits = 3, random_state = 100), n_jobs = -1, \
scoring = "neg_mean_squared_error")
np.mean([np.sqrt(-x) for x in score])https://stackoverflow.com/questions/44813343
复制相似问题