admin管理员组文章数量:1430686
I created a Xgboost regression model with 210 numeric inputs using the pycaret library Originally the input had 6 input features and enabling polynmoial transformation, ended up having 210 features.
code used to create the model
s = setup(X, target = y, session_id = 123,polynomial_features=True, polynomial_degree=4)
# Create and tune XGBoost model
xgboost_model = create_model('xgboost')
#tune model
tuned_xgboost = tune_model(xgboost_model,n_iter=20)
#
booster = tuned_xgboost.get_booster()
original_feature_names = booster.feature_names
if original_feature_names is not None:
onnx_converter_conform_feature_names = [f"f{num}" for num in range(len(original_feature_names))]
booster.feature_names = onnx_converter_conform_feature_names
# Get a sample of our training set.
X_sample = get_config('X_train')[:1].to_numpy()
# use `guess_initial_types` to infer types (this is used internally by `skl2onnx.to_onnx`).
initial_types = guess_initial_types(X_sample, None)
# convert the model.
onnx_model = convert_xgboost(tuned_xgboost, initial_types=initial_types)
onnxmltools.utils.save_model(onnx_model, base_folder+ y_cols+'_'+ date_time_str+'.onnx')
When doing inference , i get errors :
with 6 input features , i get this error :
RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running TreeEnsembleRegressor node.
Name:'TreeEnsembleRegressor'
Status Message: C:\a\_work\1\s\onnxruntime\core\providers\cpu\ml\tree_ensemble_common.h:450
onnxruntime::ml::detail::TreeEnsembleCommon<float,float,float>::ComputeAgg One path in the graph requests feature 207 but input tensor has 6 features
Assuming the prerocessing is not in onnx , when giving 210 features , ends with another error
InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: X for the following indices
index: 1 Got: 210 Expected: 6
Please fix either the inputs/outputs or the model.
Has any one faced similar issues and sorted this?
本文标签: ONNX xgboost regression model errorfeature mismatchStack Overflow
版权声明:本文标题:ONNX xgboost regression model error : feature mismatch - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745557082a2663252.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论