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?