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

[pyspark] Document model format. #8186

Closed
trivialfis opened this issue Aug 21, 2022 · 2 comments
Closed

[pyspark] Document model format. #8186

trivialfis opened this issue Aug 21, 2022 · 2 comments
Labels

Comments

@trivialfis
Copy link
Member

https://discuss.xgboost.ai/t/save-pyspark-model-load-it-on-other-language/2894

@trivialfis trivialfis added the doc label Aug 21, 2022
@DavidMaister
Copy link

Hey, I managed to solve this so I'll share how I've solved.

  • The SparkXGBClassifier saving the model, saves a directory with parquet files.
  • Read these folder with parquet files on pyspark, write these object as json.
  • In python, load this json and we want to change the format because it doesnt work the original one.
import json
f = open('pyspark_raw_json.json')
pyspark_raw_json = json.load(f)
with open('pyspark_json_converted.json', 'w', encoding='utf-8') as f:
    json.dump(json.loads(list(pyspark_raw_json.values())[0]), f)
  • Then I am able to load the model in xgboost
loaded_model = xgb.XGBClassifier()
loaded_model.load_model('pyspark_model_converted.json')

@wbo4958
Copy link
Contributor

wbo4958 commented Sep 2, 2022

I think we need to change the "save" to the model that xgboost can use directly. Let me resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants