TPOT: Etching error when using TPOTRegressor
I have a DataFrame called X
and a set of target values โโcalled Y
.
For most of my models, I do something like this (just an example):
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])
I am trying to use TPOT in a similar way:
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 starts up but then gives me an etching error like this:
PicklingError: Can't pickle <type 'instancemethod'>: it not found as __builtin__.instancemethod
Any idea why this is happening / how to get TPOT to play well?
Thank!
+3
source to share
2 answers
Try using: 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])
0
source to share