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

Saving pkl model changes default encoding #5313

Closed
sh1ng opened this issue Feb 16, 2020 · 3 comments · Fixed by #5314
Closed

Saving pkl model changes default encoding #5313

sh1ng opened this issue Feb 16, 2020 · 3 comments · Fixed by #5314

Comments

@sh1ng
Copy link
Contributor

sh1ng commented Feb 16, 2020

xgboost 1.0.0rc2

import xgboost as xgb
import numpy as np
import pickle
import locale


def makeXy():
    np.random.seed(1)
    X = np.random.randn(10, 10)
    y = [0, 1] * int(10 / 2)
    return X, y


X, y = makeXy()

dm = xgb.DMatrix(X, label=y)

param = {
    "objective": "binary:logistic",
    'eval_metric': 'auc',
}

model = xgb.train(param, dm, 1)

print(locale.getpreferredencoding(False))

with open("model.pkl", 'wb') as f:
    pickle.dump(obj=model, file=f)

print(locale.getpreferredencoding(False))
UTF-8
ANSI_X3.4-1968

I'm not quite sure, but could it be related to dmlc-core and changing locale?

@sh1ng
Copy link
Contributor Author

sh1ng commented Feb 17, 2020

Thanks

@sh1ng
Copy link
Contributor Author

sh1ng commented Feb 17, 2020

@trivialfis are you also going to merge it into release_1 branch?

@trivialfis
Copy link
Member

It's merged there.

@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants