Skip to content

Instantly share code, notes, and snippets.

@volker48
Created September 21, 2017 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volker48/268e1c4cdb220c5c94f750f11ea07e1d to your computer and use it in GitHub Desktop.
Save volker48/268e1c4cdb220c5c94f750f11ea07e1d to your computer and use it in GitHub Desktop.
XGBoost model dump issue
# coding: utf-8
# In[ ]:
import numpy as np
import pandas as pd
import xgboost as xgb
from scipy.sparse import csr_matrix
# In[ ]:
np.random.seed(1)
# In[ ]:
x_train_dense = (np.random.random((100, 5)) > .5)
x_train_sparse = csr_matrix(x_train_dense)
y_train = np.random.randint(2, size=(100, 1))
# In[ ]:
booster_dense = xgb.train({'objective':'binary:logistic'}, xgb.DMatrix(x_train_dense, y_train), num_boost_round=10)
# In[ ]:
booster_dense.get_dump(dump_format='json')
# In[ ]:
x_train_sparse = csr_matrix(x_train_dense)
# In[ ]:
booster_sparse = xgb.train({'objective':'binary:logistic'}, xgb.DMatrix(x_train_sparse, y_train), num_boost_round=10)
# In[ ]:
booster_sparse.get_dump(dump_format='json')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment