scikit-optimize icon indicating copy to clipboard operation
scikit-optimize copied to clipboard

Bug Latin Hypercube sampling

Open MaAl13 opened this issue 1 year ago • 0 comments

If i run the Latin Hypercube sampling with the basic lines of code:

from skopt.sampler import Lhs
from skopt.space import Space
space = Space([(1,2),(3,4)])
lhs = Lhs(criterion="maximin", iterations=10000)
initial_population = lhs.generate(space.dimensions, 5)

I run into the error

Traceback (most recent call last): File "", line 1, in File "/Users/malmansto/anaconda3/envs/fem-cycle-model/lib/python3.10/site-packages/skopt/sampler/lhs.py", line 89, in generate h_opt = space.inverse_transform(h_opt) File "/Users/malmansto/anaconda3/envs/fem-cycle-model/lib/python3.10/site-packages/skopt/space/space.py", line 999, in inverse_transform columns.append(dim.inverse_transform(Xt[:, start])) File "/Users/malmansto/anaconda3/envs/fem-cycle-model/lib/python3.10/site-packages/skopt/space/space.py", line 528, in inverse_transform inv_transform = super(Integer, self).inverse_transform(Xt) File "/Users/malmansto/anaconda3/envs/fem-cycle-model/lib/python3.10/site-packages/skopt/space/space.py", line 168, in inverse_transform return self.transformer.inverse_transform(Xt) File "/Users/malmansto/anaconda3/envs/fem-cycle-model/lib/python3.10/site-packages/skopt/space/transformers.py", line 309, in inverse_transform X = transformer.inverse_transform(X) File "/Users/malmansto/anaconda3/envs/fem-cycle-model/lib/python3.10/site-packages/skopt/space/transformers.py", line 275, in inverse_transform return np.round(X_orig).astype(np.int) File "/Users/malmansto/anaconda3/envs/fem-cycle-model/lib/python3.10/site-packages/numpy/init.py", line 305, in getattr # raise AttributeError(former_attrs[attr]) AttributeError: module 'numpy' has no attribute 'int'. np.int was a deprecated alias for the builtin int. To avoid this error in existing code, use int by itself. Doing this will not modify any behavior and is safe. When replacing np.int, you may wish to use e.g. np.int64 or np.int32 to specify the precision. If you wish to review your current use, check the release note link for additional information. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'inf'?

This is fixed when commenting out 197 - 321 in the init.py file. Maybe you can fix that

MaAl13 avatar May 12 '23 12:05 MaAl13