huawei-noah / HEBO

Bayesian optimisation & Reinforcement Learning library developped by Huawei Noah's Ark Lab
3.24k stars 584 forks source link

[BUG] Demo example fails to run #42

Closed hgl71964 closed 1 year ago

hgl71964 commented 1 year ago

Hi,

I pull the repo and install via

cd HEBO
pip install -e .

then I run the Demo example, but it fails to execute with the following error

Traceback (most recent call last):
  File "/HEBO/HEBO/benchmarks/default-bench.py", line 17, in <module>
    opt.observe(rec, obj(rec))
  File "/HEBO/HEBO/hebo/optimizers/hebo.py", line 206, in observe
    self.X   = self.X.append(XX, ignore_index = True)
  File "/HEBO/HEBO/venv/lib/python3.9/site-packages/pandas/core/generic.py", line 5989, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'append'

My guess is there is some data conversion wrong. Could anyone fix that?

Thanks!

Dacarpe03 commented 1 year ago

Hi, I get the same error when executing the example

AttributeError                            Traceback (most recent call last)
Cell In[12], line 15
     13 for i in range(3):
     14     rec_x = hebo_seq.suggest(n_suggestions=1)
---> 15     hebo_seq.observe(rec_x, obj(rec_x))
     16     print('After %d iterations, best obj is %.2f' % (i, opt.y.min()))

File ~/miniconda3/envs/bo-drl-2hp-env/lib/python3.10/site-packages/hebo/optimizers/hebo.py:201, in HEBO.observe(self, X, y)
    199 XX       = X.iloc[valid_id]
    200 yy       = y[valid_id].reshape(-1, 1)
--> 201 self.X   = self.X.append(XX, ignore_index = True)
    202 self.y   = np.vstack([self.y, yy])

File ~/miniconda3/envs/bo-drl-2hp-env/lib/python3.10/site-packages/pandas/core/generic.py:5989, in NDFrame.__getattr__(self, name)
   5982 if (
   5983     name not in self._internal_names_set
   5984     and name not in self._metadata
   5985     and name not in self._accessors
   5986     and self._info_axis._can_hold_identifiers_and_holds_name(name)
   5987 ):
   5988     return self[name]
-> 5989 return object.__getattribute__(self, name)

AttributeError: 'DataFrame' object has no attribute 'append'

I think it is because append is deprecated from pandas v.1.4.0 and completely removed from pandas v2.0.0

Thank you

StephanAkkerman commented 1 year ago

This is fixed in 0.3.5, run pip install git+https://github.com/huawei-noah/HEBO.git#subdirectory=HEBO to get the latest version