We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Per customers requirement, we need to add support for saving/loading model on HDFS in XGBoost, and LightGBM.
Current workaround:
def save_model(model, path): if is_local_path(path): model.saveModel(path) else: file_name = str(uuid.uuid1()) file_name = append_suffix(file_name, path) temp_path = os.path.join(tempfile.gettempdir(), file_name) try: model.saveModel(temp_path) put_local_file_to_remote(temp_path, path) finally: os.remove(temp_path) def load_model(path, class_num): model = None if is_local_path(path): model = XGBClassifierModel.loadModel(path, class_num) else: file_name = str(uuid.uuid1()) file_name = append_suffix(file_name, path) temp_path = os.path.join(tempfile.gettempdir(), file_name) get_remote_file_to_local(path, temp_path) try: model = XGBClassifierModel.loadModel(temp_path, class_num) finally: os.remove(temp_path) return model eta = 0.1 max_depth = 6 num_round =200 params.update({"eta": eta, "max_depth": max_depth, "num_round": num_round}) classifier = XGBClassifier(params) xgbmodel = classifier.fit(train) save_model(xgbmodel, "hdfs:///user/kai/zcg/model/xgb.model") xgbmodel = load_model("hdfs:///user/kai/zcg/model/xgb.model", 2) xgbmodel.setFeaturesCol("features") predicts = xgbmodel.transform(test).drop("features") predicts.cache() predicts.show(5, False) predicts.unpersist(blocking=True)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Per customers requirement, we need to add support for saving/loading model on HDFS in XGBoost, and LightGBM.
Current workaround:
The text was updated successfully, but these errors were encountered: