-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
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
Blocking Issue to convert VotingClassifier in ONNX format. "Not implemented yet" message. #1071
Comments
Just turn of flatten_transform in the VotingClassifier with My example # random forest classifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
# split the data
X_train, X_test, y_train, y_test = train_test_split(X_correct, y_correct, test_size=0.1, random_state=42)
# Initialize the Random Forest model
# model = RandomForestClassifier(n_estimators=100, random_state=42, n_jobs=-1, class_weight='balanced')
clf1 = LogisticRegression(multi_class='multinomial', random_state=1)
clf2 = RandomForestClassifier(n_estimators=100, random_state=1, class_weight='balanced')
clf3 = GaussianNB()
model = VotingClassifier(estimators=[('lr', clf1), ('rf', clf2), ('gnb', clf3)], voting='hard', flatten_transform=False) |
Here's the revised message with improved clarity and corrected English: I need to load a VotingClassifier model, which combines XGBoost and NaiveBayes, saved in the ".sav" format and convert it to ONNX format. Since I don't have access to the dataset to retrain the model, I'm directly opening it using joblib and attempting the conversion. The XGBoost version used for training the model was 1.4.2. However, I encountered several problems during the conversion:
This problem was resolved by directly modifying the library and changing the parameter name to match the one compatible with the version of XGBOOST.
How to solve it ? |
I think it is an issue for onnxmltools. Which version are you using? |
The version is onnxmltools 1.12.0. |
I can confirm that this issue still occurs
I can confirm that the issue showing |
Hello, I ran in the same issue while trying to load an already trained voting classifier using three |
It turns out that the issue is indeed solved by changing flatten_transform, i.e., adding |
Are you unblocked or do you still need this feature? |
I am unblocked thanks! |
I'm trying to convert a model that has been saved in .sav in onnx format. The model is a VotingClassifier (XGBOOST and NaiveBayes). I got the error
Traceback (most recent call last): File "/mnt/c/Users/project/convert_onnx.py", line 29, in <module> onnx_model = convert_sklearn(model,"gbdt_model", File "/mnt/c/Users/project/env/lib/python3.10/site-packages/skl2onnx/convert.py", line 208, in convert_sklearn onnx_model = convert_topology( File "/mnt/c/Users/project/env/lib/python3.10/site-packages/skl2onnx/common/_topology.py", line 1532, in convert_topology topology.convert_operators(container=container, verbose=verbose) File "/mnt/c/Users/project/env/lib/python3.10/site-packages/skl2onnx/common/_topology.py", line 1350, in convert_operators self.call_converter(operator, container, verbose=verbose) File "/mnt/c/Users/project/env/lib/python3.10/site-packages/skl2onnx/common/_topology.py", line 1133, in call_converter conv(self.scopes[0], operator, container) File "/mnt/c/Users/project/env/lib/python3.10/site-packages/skl2onnx/common/_registration.py", line 27, in __call__ return self._fct(*args) File "/mnt/c/Users/project/env/lib/python3.10/site-packages/skl2onnx/operator_converters/voting_classifier.py", line 143, in convert_voting_classifier raise NotImplementedError(NotImplementedError: flatten_transform==True is not implemented yet. You may raise an issue at https://github.com/onnx/sklearn-onnx/issues.
Is there a workaround to this problem ? It's a a blocking issue because by default flatten_transform=True. Thank you.
The code is as follow:
The text was updated successfully, but these errors were encountered: