Skip to content

[BUG]: compare_models with fit_kwargs bug - still not working #4094

@tiefenthaler

Description

@tiefenthaler

Issue Description

Installed Version:

import pycaret
pycaret.__version__
3.4.0

As already described here: [BUG]: compare_models with fit_kwargs bug] #2537 it is not possible to properly pass fit_kwards to compare_models. See more details in #2537

Reproducible Example

from pycaret.datasets import get_data
data = get_data('hepatitis')

from pycaret.classification import *
s = setup(data, target = 'Class', session_id = 123)

compare_models(fit_kwargs = {'sample_weight' : {0 : 1, 1 : 2}}, errors = 'raise')

Expected Behavior

It should work seamlessly.

Actual Results

TypeError: _fit_one() got an unexpected keyword argument 'class_weight'

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/pycaret/internal/pycaret_experiment/supervised_experiment.py](https://localhost:8080/#) in compare_models(self, include, exclude, fold, round, cross_validation, sort, n_select, budget_time, turbo, errors, fit_kwargs, groups, experiment_custom_tags, probability_threshold, verbose, parallel, caller_params)
    811             except Exception as ex:
    812                 if errors == "raise":
--> 813                     raise RuntimeError(
    814                         f"create_model() failed for model {model}. {type(ex).__name__}: {ex}"
    815                     )

RuntimeError: create_model() failed for model lr. TypeError: _fit_one() got an unexpected keyword argument 'class_weight'

Installed Versions

import pycaret
pycaret.__version__
3.4.0

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