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


If you are using Python 2 try:

import dill  

      

So lambda functions can be pickled ... worked for me ...



in Python 3 you might need:

import dill as pickle

      

+1


source


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







All Articles