Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何将python xgboost模型转换为pmml?_Python 3.x_Regression_Xgboost_Pmml - Fatal编程技术网

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

Python 3.x 如何将python xgboost模型转换为pmml?,python-3.x,regression,xgboost,pmml,Python 3.x,Regression,Xgboost,Pmml,如何将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,

如何将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_

请参阅SKLear2PML软件包:

首先,定义一个新的pmml管道,并将XGBRegressionor插入其中。然后,使用
GridSearchCV
learner安装pmml管道。最后,使用
sklearn2pmml.sklearn2pmml
函数调用将
GridSearchCV.best\u estimator\u
导出为pmml数据格式,该格式应为优化的pmml管道:

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

另请参见以下演示的幻灯片#26:

我尝试了这种方法,但它的错误如下:估算器PMMLPipeline的参数gamma无效(steps=[('regressor',XGBRegressor(基本分数=0.5,助推器=gbtree,colsample=bylevel=1,colsample=bytree=0.8,gamma=0.1,学习率=0.1,最大增量=0,最大深度=4,最小子权重=4,缺失=nan,n估计数=30,n作业=1,n读取=None,目标为二元逻辑,随机状态=0,注册α=1,注册λ=1,标度位置权重=1,种子=27,silent=True,subsample=0.9))])。使用
估计器检查可用参数列表。get_params().keys()
。错误消息“估计器(PMML)管道的参数伽马无效”这意味着您必须为所有网格搜索参数名称预先添加一个步骤标识符。例如,
max_depth
应该变成
regressor\uu max_depth
,依此类推。谢谢,我还有一个问题,当我试图转换为pmml时,出现了一个错误,如:RuntimeError:JPMML SkLearn转换应用程序失败。Java可执行文件应已将有关故障的更多信息打印到其标准输出和/或标准错误流中。我想知道如何修复此问题错误为:
Java.lang.UnsupportedClassVersionError:org/jpmml/sklearn/Main:Unsupported major.minor version 52.0
。这意味着您的
Java.exe
version上不支持Java(1.)8类文件。请卸载当前的
Java.exe
,然后安装最新的。有关此错误的详细信息,请参阅: