Scikit-optimize: AttributeError: 'str' object has no attribute 'decode'

Created on 2 Jan 2021  路  6Comments  路  Source: scikit-optimize/scikit-optimize

Hey! having a wonky issue, can't seem to find any place to check what to do.

My Error:

Fitting 3 folds for each of 5 candidates, totalling 15 fits
joblib.externals.loky.process_executor._RemoteTraceback:
"""
Traceback (most recent call last):
File "C:\Optimization\OptimEnv\env369\lib\site-packages\joblib\externals\loky\process_executor.py", line 431, in _process_worker
r = call_item()
File "C:\Optimization\OptimEnv\env369\lib\site-packages\joblib\externals\loky\process_executor.py", line 285, in __call__
return self.fn(self.args, *self.kwargs)
File "C:\Optimization\OptimEnv\env369\lib\site-packages\joblib_parallel_backends.py", line 595, in __call__
return self.func(args, *kwargs)
File "C:\Optimization\OptimEnv\env369\lib\site-packages\joblib\parallel.py", line 263, in __call__
for func, args, kwargs in self.items]
File "C:\Optimization\OptimEnv\env369\lib\site-packages\joblib\parallel.py", line 263, in
for func, args, kwargs in self.items]
File "C:\Optimization\OptimEnv\env369\lib\site-packages\sklearn\model_selection_validation.py", line 531, in _fit_and_score
estimator.fit(X_train, y_train, *fit_params)
File "C:\Optimization\OptimEnv\env369\lib\site-packages\sklearn\pipeline.py", line 335, in fit
self._final_estimator.fit(Xt, y, *
fit_params_last_step)
File "C:\Optimization\OptimEnv\env369\lib\site-packages\sklearn\gaussian_process_gpr.py", line 249, in fit
bounds))
File "C:\Optimization\OptimEnv\env369\lib\site-packages\sklearn\gaussian_process_gpr.py", line 504, in _constrained_optimization
_check_optimize_result("lbfgs", opt_res)
File "C:\Optimization\OptimEnv\env369\lib\site-packages\sklearn\utils\optimize.py", line 243, in _check_optimize_result
).format(solver, result.status, result.message.decode("latin1"))
AttributeError: 'str' object has no attribute 'decode'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "Script_v01.py", line 261, in
gpr_BCV.fit(X,y)
File "C:\Optimization\OptimEnv\env369\lib\site-packages\skopt\searchcv.py", line 694, in fit
groups=groups, n_points=n_points_adjusted
File "C:\Optimization\OptimEnv\env369\lib\site-packages\skopt\searchcv.py", line 579, in _step
self._fit(X, y, groups, params_dict)
File "C:\Optimization\OptimEnv\env369\lib\site-packages\skopt\searchcv.py", line 423, in _fit
for parameters in parameter_iterable
File "C:\Optimization\OptimEnv\env369\lib\site-packages\joblib\parallel.py", line 1054, in __call__
self.retrieve()
File "C:\Optimization\OptimEnv\env369\lib\site-packages\joblib\parallel.py", line 933, in retrieve
self._output.extend(job.get(timeout=self.timeout))
File "C:\Optimization\OptimEnv\env369\lib\site-packages\joblib_parallel_backends.py", line 542, in wrap_future_result
return future.result(timeout=timeout)
File "C:\Users\Nuno\AppData\Local\Programs\Python\Python37\lib\concurrent\futures_base.py", line 428, in result
return self.__get_result()
File "C:\Users\Nuno\AppData\Local\Programs\Python\Python37\lib\concurrent\futures_base.py", line 384, in __get_result
raise self._exception
AttributeError: 'str' object has no attribute 'decode'


My call:
`param_RBF = {
'model':[GaussianProcessRegressor(kernel=1RBF(length_scale_bounds='fixed'))],
#'model__length_scale':Real(0.1,10),
#'model':[GaussianProcessRegressor(kernel=RBF())],
'model__alpha':Real(0,.5),
#'model__alpha':Categorical([0,.05,.1,.2]),
'model__n_restarts_optimizer':Integer(2,50),
#'model__normalize_y':Categorical([True]),
}
param_MAT = {
'model':[GaussianProcessRegressor(kernel=1
Matern(length_scale_bounds='fixed'))],
#'model':[GaussianProcessRegressor(kernel=1*Matern())],
'model__alpha':Real(0,.5),
#'model__alpha':Categorical([0,.05,.1,.2]),
'model__n_restarts_optimizer':Integer(2,50),
'model__normalize_y':Categorical([False]),

pipe_gpr = Pipeline([
('model',GaussianProcessRegressor())])

gpr_BCV = BayesSearchCV(pipe_gpr,
# (parameter space, # of evaluations)
[(param_RBF, 10), (param_MAT, 10)],verbose=1,n_jobs=-1,n_iter=repeats,n_points=s_pts,cv=kflds,scoring='neg_mean_absolute_error')
gpr_BCV.fit(X,y)
plot_convergence(gpr_BCV.optimizer_results_)

`
I'm on a windows, and these are the packages i have currently. Python 3.7.4
cycler==0.10.0
joblib==1.0.0
kiwisolver==1.3.1
matplotlib==3.3.3
numpy==1.19.3
pandas==1.1.5
Pillow==8.0.1
pp==1.6.4.4
pyaml==20.4.0
pyparsing==2.4.7
python-dateutil==2.8.1
pytz==2020.5
PyYAML==5.3.1
scikit-learn==0.23.1
scikit-optimize==0.8.1
scipy==1.6.0
seaborn==0.11.1
six==1.15.0
threadpoolctl==2.1.0

Any pointers?

Most helpful comment

Hi,

I see the problem is in scipy 1.6.0 (it was released 12/31/2020), reverting to, say, scipy 1.5.3 fixes this, may be considered as a temporary solution.

All 6 comments

Hi,

I see the problem is in scipy 1.6.0 (it was released 12/31/2020), reverting to, say, scipy 1.5.3 fixes this, may be considered as a temporary solution.

Hi,

I see the problem is in scipy 1.6.0 (it was released 12/31/2020), reverting to, say, scipy 1.5.3 fixes this, may be considered as a temporary solution.

Thank you! indeed!

I ran into the same problem, and it seems this is introduced by Scipy fixing this issue https://github.com/scipy/scipy/issues/13001 .

I would assume this can be fixed by removing the decode argument. Hope this helps.

I had the same issue and downgrading to Scipy 1.5.2 solves the problem, thanks !!

Some where an attempt is being made to decode an object that is already decoded. Maybe putting a check might be a quick fix. Dropping the .decode('utf-8'). I think in python 3 all string an inherently Unicode but in Python 2 you had to specify unicode(''upgraded to Python 3'').

Looks like this is an issue of compatibility between scikit-learn<=23.2 and scipy>=1.6.0 (see this issue). Maybe the requirements should be raised to require scikit-learn>23.2 ?

Was this page helpful?
0 / 5 - 0 ratings