Commit cff54d51 authored by Pierre PACI's avatar Pierre PACI Committed by Guolin Ke
Browse files

Added dump_model() to simple_example.py (#911)

The example page state that "simple_example.py" should feature an example of json dump, but that was missing.
parent 67c2bdf9
...@@ -46,6 +46,10 @@ print('Save model...') ...@@ -46,6 +46,10 @@ print('Save model...')
# save model to file # save model to file
gbm.save_model('model.txt') gbm.save_model('model.txt')
# dump model to json format
with open('model.json', 'w') as model:
model.write(gbm.dump_model(num_iteration=gbm.best_iteration))
print('Start predicting...') print('Start predicting...')
# predict # predict
y_pred = gbm.predict(X_test, num_iteration=gbm.best_iteration) y_pred = gbm.predict(X_test, num_iteration=gbm.best_iteration)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment