Created
March 26, 2023 11:54
-
-
Save john-adeojo/942a5ffb7d49d4c5c2d48cd0924298bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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