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

Fixed missing feature names for XGBoost #93

Merged
merged 5 commits into from
Jul 30, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Save model to temp directory
  • Loading branch information
akhvorov committed Jul 30, 2019
commit 1d1c824b8e65fce326faa9052b693ea45a88fdf1
16 changes: 6 additions & 10 deletions tests/assemblers/test_xgboost.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import xgboost
import numpy as np
import os
from tests import utils
from m2cgen import assemblers, ast

Expand Down Expand Up @@ -231,21 +232,16 @@ def test_multi_class_best_ntree_limit():


def test_regression_saved_without_feature_names():
import os

base_score = 0.6
estimator = xgboost.XGBRegressor(n_estimators=2, random_state=1,
max_depth=1, base_score=base_score)
utils.train_model_regression(estimator)

filename = "tmp.file"
if os.path.exists(filename):
raise OSError("File is already exist")
estimator.save_model(filename)
estimator = xgboost.XGBRegressor(base_score=base_score)
estimator.load_model(filename)
if os.path.exists(filename):
os.remove(filename)
with utils.tmp_dir() as tmp_dirpath:
filename = os.path.join(tmp_dirpath, "tmp.file")
estimator.save_model(filename)
estimator = xgboost.XGBRegressor(base_score=base_score)
estimator.load_model(filename)

assembler = assemblers.XGBoostModelAssembler(estimator)
actual = assembler.assemble()
Expand Down