best iteration and feature importance information is lost after serialization · Issue #2294 · catboost/catboost · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saved trained model using .cbm format. The problem is when I a load model back and I want to call model.get_best_iteration() it return None. model.feature_importance_ also returned None. Here is my code
params = {
'iterations' : 10000,
'early_stopping_rounds' : 1000,
'loss_function' : 'Logloss',
'eval_metric' : 'F1',
'task_type' : 'GPU',
'gpu_ram_part' : 0.3,
'train_dir' : 'model/catboost_info',
}
model = CatBoostClassifier(**params)
print('fit the model...')
start = time.time()
model.fit(
X=train_data,
use_best_model=True,
eval_set=valid_data,
)
train_time = time.time() - start
print('done training...')
print('save the model and train time..')
model.save_model('model/catboost.cbm')
print('load model and train time...')
cat = CatBoostClassifier()
cat.load_model('model/catboost.cbm')
with open('dump/catboost_train_time.pickle', 'rb') as f:
train_time = pickle.load(f)
print('finish..')
print(f'train time : {train_time / 60}')
print(f'last iteration: {cat.get_best_iteration()}')
The text was updated successfully, but these errors were encountered:
get_best_iteration() and other metrics-related information serialization is now fixed as a part of #1166 and included in the release 1.2.3 . feature_importance_ is still not serialized, it is technically easy to implement but can increase a model size somewhat. But if more people want this than not we can do it.
andrey-khropov
changed the title
How to properly save/load model
best iteration and feature importance information is lost after serialization
Mar 9, 2024
Uh oh!
There was an error while loading. Please reload this page.
Hi
I am really new to catboost. I would like some clarification about saving/loading model.
The way I save/load model, I did it as in here : https://catboost.ai/en/docs/concepts/python-usages-examples#load-from-file
I saved trained model using .cbm format. The problem is when I a load model back and I want to call
model.get_best_iteration()
it returnNone
.model.feature_importance_
also returnedNone
. Here is my codeThe text was updated successfully, but these errors were encountered: