Closed
Description
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
Labels
No labels