Skip to content

Can not call need_retrain when best model is Ensemble #799

Open
@a88zach

Description

@a88zach

When the best model is Ensemble, and you reload the model from a results path, calling need_retrain on the model results in the following error

File "/Users/zachtindall/Documents/repos/ml-build/.venv/lib/python3.11/site-packages/supervised/automl.py", line 565, in need_retrain
    return self._need_retrain(X, y, sample_weight, decrease)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zachtindall/Documents/repos/ml-build/.venv/lib/python3.11/site-packages/supervised/base_automl.py", line 2479, in _need_retrain
    metric = self._best_model.get_metric()

If I call load manually on the model after it has been initialized, then it works as intended.

Example

        auto_ml = AutoML(
            results_path=self._results_path,
        )

        auto_ml.load(self._results_path)

        need_retrain = auto_ml.need_retrain(
            x_test, y_test, sample_weight=sample_weight, decrease=decrease
        )

I wouldn't expect that load would need to be called manually, since other methods like predict can be called right after initializing a model from a results path

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions