optimas-org / optimas

Optimization at scale, powered by libEnsemble
https://optimas.readthedocs.io
Other
22 stars 13 forks source link

Task column missing from ExplorationDiagnostics.history dataframe #223

Open VadimBim opened 2 months ago

VadimBim commented 2 months ago

Hi ! I am using the latest release, 0.6.0, installed with pip.

When trying to execute the first cell from the Analyzing results notebook with the exploration directory obtained from Multitask optimization example I encountered the following error message:

Traceback (most recent call last):
  File "multitask_lpa_fbpic_waket/debug.py", line 3, in <module>
    diags = ExplorationDiagnostics(
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "miniforge3/envs/wake-t/lib/python3.11/site-packages/optimas/diagnostics/exploration_diagnostics.py", line 70, in __init__
    exploration = self._create_exploration(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "miniforge3/envs/wake-t/lib/python3.11/site-packages/optimas/diagnostics/exploration_diagnostics.py", line 105, in _create_exploration
    return Exploration(
           ^^^^^^^^^^^^
  File "miniforge3/envs/wake-t/lib/python3.11/site-packages/optimas/explorations/base.py", line 126, in __init__
    self._load_history(history, resume)
  File "miniforge3/envs/wake-t/lib/python3.11/site-packages/optimas/explorations/base.py", line 493, in _load_history
    self.attach_evaluations(history)
  File "miniforge3/envs/wake-t/lib/python3.11/site-packages/optimas/explorations/base.py", line 405, in attach_evaluations
    raise ValueError(
ValueError: The given data contains the fields ['ax_trial_type', 'ax_arm_name', 'task', 'ax_trial_index'], which are unknown to the generator. If this is expected, ignore them by setting `ignore_unrecognized_parameters=True`.

With the latest version of optimas from GitHub it worked because ignore_unrecognized_parameters=True in self.attach_evaluations line 502 file optimas/explorations/base.py. However, diags.history DataFrame doesn't contain a task column, which is of interest for me.

I managed to obtain this column as follows:

import numpy as np
from optimas.utils.other import convert_to_dataframe

history = np.load("./exploration/exploration_history_after_sim_24.npy")
evaluations = convert_to_dataframe(history)
evaluations['task']

I find it more convenient if this column would be included directly in diags.history. What do you think?

RemiLehe commented 1 month ago

@delaossa Would you know how to fix this issue?