I trained a prediction model with Scikit Learn in Python (Random Forest Regressor) and I want to extract somehow the weights of each feature to create an excel tool for manual prediction.
The only thing that I found is the
model.feature_importances_ but it doesn't help.
Is there any way to achieve it?
def performRandomForest(X_train, y_train, X_test, y_test): '''Perform Random Forest Regression''' from sklearn.ensemble import RandomForestRegressor model = RandomForestRegressor() model.fit( X_train , y_train ) #make predictions expected = y_test predicted = model.predict( X_test ) #summarize the fit of the model mse = np.mean(( predicted - expected )** 2) accuracy = ( model.score ( X_train , y_train )) return model, mse, accuracy
At the moment, I use the
model.predict([features]) to do it, but I need it in an excel file.
decision trees, so you won't get one equation like you do with linear regression. Instead you will get a bunch of
if, then, elselogic and many final equations to turn the final leaves into numerical values. Even if you can visualize the tree and pull out all of the logic, this all seems like a big mess. If you are working in excel, maybe think about just training your model in excel using Azure. However, I would probably just call the python from within excel. $\endgroup$