gpt4 book ai didi

python-3.x - 如何将python xgboost模型转换为pmml?

转载 作者:行者123 更新时间:2023-12-03 19:31:25 27 4
gpt4 key购买 nike

如何将 python xgboost 模型转换为 pmml ?

reg = XGBRegressor(learning_rate=0.1, n_estimators=30, max_depth=4, min_child_weight=4, gamma=0.1,
subsample=0.9, colsample_bytree=0.8, objective='binary:logistic', reg_alpha=1,
scale_pos_weight=1, seed=27)
param_test = [{
'max_depth': [i for i in range(1, 3)],
'gamma': [i / 10.0 for i in range(0, 10)],
'n_estimators': [i for i in range(2, 14, 2)],
}]
gsearch = GridSearchCV(reg, param_grid=param_test, scoring='neg_mean_squared_error', n_jobs=4, iid=False, cv=5)
gsearch.fit(x_train, y_train)
best_model = gsearch.best_estimator_

最佳答案

请参阅 SkLear2PMML 包:https://github.com/jpmml/sklearn2pmml

首先,定义一个新的 pmml 管道,并将您的 XGBRegressor 插入其中。然后,使用 GridSearchCV 拟合 pmml 管道学习者。最后,导出 GridSearchCV.best_estimator_ - 这应该是优化的 pmml 管道 - 使用 sklearn2pmml.sklearn2pmml 转换为 PMML 数据格式函数调用:

pmml_pipeline = PMMLPipeline([
("regressor", XGBRegressor())
])
tuner = GridSearchCV(pmml_pipeline, ...)
tuner.fit(X, y)
sklearn2pmml(tuner.best_estimator_, "xgbregressor-pipeline.pmml")

另请参阅以下演示文稿的幻灯片 #26: https://www.slideshare.net/VilluRuusmann/converting-scikitlearn-to-pmml

关于python-3.x - 如何将python xgboost模型转换为pmml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54124818/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com