I want to build a FHE-compliant model using a fitted scikit-learn model. In my case, the model is a RandomForestClassifier having 100 estimators and a max depth of 80.
By invoking the from_sklearn_model function, I get stuck during the onnx conversion with Hummingbird convert method.
In convert_decision_ensemble_tree_common function there’s a loop invoking get_parameters_for_gemm_common function 100 times. The number of nodes of my model for each iteration on tree_param variable is around 250 000. After computing some metrics, the time and space complexity is not feasible to process my model.
What non-standard configuration could I set to improve code execution performance to import a production level pre-trained model? any pieces of advice?
The way we use tree based model is by converting the inference into 2 matrices. The first matrix is (n_splits, n_features) and the second is (n_terminal_nodes, n_splits). We actually use hummingbird-ml to do the conversion you can probably check there what’s the limitations.
What kind of machine are you trying to run this? You will probably need a LOT of ram due to the germ approach.
Yes, RAM becomes a constraint when working with such a complex tree-based model. Apart from vertical scaling, would you recommend exploring other approaches, such as using a different strategy or generating the ONNX model with another library?
I would highly recommend to either retrain or convert your model to XGBoost instead of Random Forest. It uses much lower depth and so has much lower nodes for similar or better accuracy results.