Skip to content

Instantly share code, notes, and snippets.

@john-adeojo
Created March 26, 2023 11:54
Show Gist options
  • Save john-adeojo/942a5ffb7d49d4c5c2d48cd0924298bd to your computer and use it in GitHub Desktop.
Save john-adeojo/942a5ffb7d49d4c5c2d48cd0924298bd to your computer and use it in GitHub Desktop.
from sklearn.linear_model import LinearRegression
# Create a list of the tuned models with names
models = [
('xgb', xgb_tuner.best_estimator_),
('rf', rf_tuner.best_estimator_),
('ridge', ridge_tuner.best_estimator_)
]
# Create the stacking model
stacking_regressor = StackingRegressor(
estimators=models,
final_estimator=LinearRegression(),
cv=5,
n_jobs=-1
)
# Fit the stacking model on your training data
stacking_regressor.fit(X_train, y_train)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment