8000 Catboost changes parameter names on save which can give problems · Issue #2225 · catboost/catboost · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Catboost changes parameter names on save which can give problems #2225
Closed
@boennecd

Description

@boennecd

Problem: Catboost changes parameter names using save_model() which can cause an error later depending on the object that is used in load_model()
catboost version: 1.1.1
Operating System: MacOS
CPU: M1

Running

from catboost import CatBoostRegressor
from sklearn import datasets
import tempfile
import os

example = datasets.load_iris()
fit = CatBoostRegressor(max_depth=3, verbose=False).fit(example["data"], example["target"])
print(fit.get_params())

tmp_file = tempfile.NamedTemporaryFile(delete=False)
try:
    fit.save_model(tmp_file.name)
    del fit
    new_fit = CatBoostRegressor(max_depth=3).load_model(tmp_file.name)
    print(new_fit.get_params())
    new_fit.predict(example["data"])
finally:
    tmp_file.close()
    os.remove(tmp_file.name)

gives

{'loss_function': 'RMSE', 'verbose': False, 'max_depth': 3}
{'loss_function': 'RMSE', 'max_depth': 3, 'depth': 3, 'verbose': 0}
# ...
    raise CatBoostError('only one of the parameters ' + (', '.join(synonyms)) + ' should be initialized.')
_catboost.CatBoostError: only one of the parameters depth, max_depth should be initialized.

The issue is that max_depth becomes depth. Even loading on the same object fails

# ... same code as before
try:
    fit.save_model(tmp_file.name)
    fit.load_model(tmp_file.name).predict(example["data"])
finally:
    tmp_file.close()
    os.remove(tmp_file.name)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0