Skip to content

Commit

Permalink
use new getNativeModel method in get_surrogate_booster_pyspark to sim…
Browse files Browse the repository at this point in the history
…plify erroranalysis code
  • Loading branch information
imatiach-msft committed Jun 9, 2022
1 parent e79a0a9 commit 84cdfc9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions erroranalysis/erroranalysis/_internal/surrogate_error_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

# imports required for pyspark support
try:
import glob

import pyspark.sql.functions as F
from synapse.ml.lightgbm import LightGBMClassifier, LightGBMRegressor
except ImportError:
Expand Down Expand Up @@ -293,15 +291,9 @@ def get_surrogate_booster_pyspark(filtered_df, analyzer, max_depth,
diff_data = diff_data.drop(PREDICTION)
model = create_surrogate_model_pyspark(analyzer, diff_data, max_depth,
num_leaves, min_child_samples)
# TODO: update lightgbm in pyspark to get around file requirement
model_path = "./models/lgbmclassifier.model"
model.saveNativeModel(model_path)
model_file = glob.glob(model_path + '/*.txt')[0]
with open(model_file) as f:
contents = f.read()
model_str = model.getNativeModel()
booster_args = {'objective': analyzer.model_task}

lgbm_booster = Booster(params=booster_args, model_str=contents)
lgbm_booster = Booster(params=booster_args, model_str=model_str)
return lgbm_booster, diff_data.to_koalas()


Expand Down
2 changes: 1 addition & 1 deletion erroranalysis/erroranalysis/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
name = 'erroranalysis'
_major = '0'
_minor = '3'
_patch = '2'
_patch = '3'
version = '{}.{}.{}'.format(_major, _minor, _patch)

0 comments on commit 84cdfc9

Please sign in to comment.