Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot persist an EvolutionarySearchCV object #47

Open
gefero opened this issue Jan 29, 2018 · 0 comments
Open

Cannot persist an EvolutionarySearchCV object #47

gefero opened this issue Jan 29, 2018 · 0 comments

Comments

@gefero
Copy link

gefero commented Jan 29, 2018

I am trying to persist with joblib several EvolutionarySearchCV objects.
I have used this code:

`ev_search = []
it = 0
import warnings
import time
from sklearn.externals import joblib

t0 = time.time()

with warnings.catch_warnings():
warnings.simplefilter("ignore")
for n, mod, par in zip(names, mods, params):
print('Estimating ', n ,'...', sep='')
ev = EvolutionaryAlgorithmSearchCV(estimator=mod,
params=par,
scoring="roc_auc",
cv=kf,
verbose=0,
population_size=100,
gene_mutation_prob=0.10,
gene_crossover_prob=0.5,
tournament_size=3,
generations_number=10,
n_jobs=4)
ev.fit(X_train, y_train)
ev_search.append(ev)
#with open('./models_final/evv_' + n + '.pkl', 'wb') as f:
# pickle.dump(ev, f)
joblib.dump(ev, ('./models_final/evv_' + n + '.pkl'))
#print('Time elapsed:', str(t0 - time.time()))
print('Saved ', n ,' to disk', sep='')
print('----------------')
print('')
`

When I try to load it

x = joblib.load('./models_final/evv_XGBoost.pkl')

I get this error:

`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in ()
----> 1 x = joblib.load('./models_final/evv_XGBoost.pkl')

~/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/numpy_pickle.py in load(filename, mmap_mode)
576 return load_compatibility(fobj)
577
--> 578 obj = _unpickle(fobj, filename, mmap_mode)
579
580 return obj

~/anaconda3/lib/python3.6/site-packages/sklearn/externals/joblib/numpy_pickle.py in _unpickle(fobj, filename, mmap_mode)
506 obj = None
507 try:
--> 508 obj = unpickler.load()
509 if unpickler.compat_mode:
510 warnings.warn("The file '%s' has been generated with a "

~/anaconda3/lib/python3.6/pickle.py in load(self)
1048 raise EOFError
1049 assert isinstance(key, bytes_types)
-> 1050 dispatchkey[0]
1051 except _Stop as stopinst:
1052 return stopinst.value

~/anaconda3/lib/python3.6/pickle.py in load_global(self)
1336 module = self.readline()[:-1].decode("utf-8")
1337 name = self.readline()[:-1].decode("utf-8")
-> 1338 klass = self.find_class(module, name)
1339 self.append(klass)
1340 dispatch[GLOBAL[0]] = load_global

~/anaconda3/lib/python3.6/pickle.py in find_class(self, module, name)
1390 return _getattribute(sys.modules[module], name)[0]
1391 else:
-> 1392 return getattr(sys.modules[module], name)
1393
1394 def load_reduce(self):

AttributeError: module 'deap.creator' has no attribute 'Individual'`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant