Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save best_score and best_iteration values into the file with model #1166

Closed
LSinev opened this issue Feb 3, 2020 · 2 comments
Closed

Save best_score and best_iteration values into the file with model #1166

LSinev opened this issue Feb 3, 2020 · 2 comments
Labels

Comments

@LSinev
Copy link

LSinev commented Feb 3, 2020

Problem: not saving model correctly
catboost version: 0.21
python 3.7.6
Operating System: Win 10
CPU: i7
Commandline:

python test.py

result:

{} None
{} None

test.zip (with saved model files)

test.py:

import pickle
import pandas as pd
from catboost import Pool, CatBoostRegressor
from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split
boston = load_boston()
X = boston.data
y = boston.target
X = pd.DataFrame(X, columns=boston.feature_names)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=1/10, random_state=1)
X_train, X_val, y_train, y_val = train_test_split(X_train, y_train, test_size=1/9)
c = CatBoostRegressor(early_stopping_rounds=50, verbose=0)
c.fit(
    Pool(X_train, y_train),
    eval_set=Pool(X_val, y_val),
)
c.save_model('model.cbm')
with open('model.pkl', 'wb') as f:
    pickle.dump(c, f, pickle.HIGHEST_PROTOCOL)
c_load = CatBoostRegressor()
c_load.load_model('model.cbm')
with open('model.pkl', 'rb') as f:
    c_load_pkl = pickle.load(f)    
print(c_load.get_best_score(), c_load.get_best_iteration())
print(c_load_pkl.get_best_score(), c_load_pkl.get_best_iteration())
@annaveronika annaveronika changed the title Something wrong with model save Save best_score and best_iteration values into the file with model Feb 12, 2020
@zhuoyue0515
Copy link

@LSinev Hi, did they solve this or did you find a way?

@LSinev
Copy link
Author

LSinev commented Oct 22, 2020

Didn't find a way. The problem still exists.

catboost version: 0.24
python 3.7.9
Operating System: Win 10

result:

{} None
{} None

catboost024_test.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants