I am trying to implement a nested regression model separately which I got as an output from TPOT. The output of TPOT is:
RandomForestRegressor(XGBRegressor(XGBRegressor(**args1), **args2), **args3)
My code is so far:
from xgboost import XGBRegressor
from sklearn.ensemble import RandomForestRegressor
xgb1 = XGBRegressor(**args1)
xgb2 = XGBRegressor(**args2)
rf = RandomForestRegressor(**args3)
I am not sure how I can combine them properly in the order of TPOT's answer.
TPOT Classifier and Regressor make available a scikit-learn Pipeline object that already does that for you.
If you look at the TPOT API both
TPOTClassifierandTPOTRegressorexpose an attributefitted_pipeline_which will hold the best scikit-learn Pipeline TPOT could find. An example of a scikit-learn Pipeline:You can either dump it for later load, so you don't have to retrain your model, or you can simply export the best pipeline using TPOT Classifier and Regressor built-in function to export your optimized Pipeline as Python Code so you can re-fit your model:
If for some reason you only have that output posted in the question, you can recreate the scikit-learn Pipeline like this: