Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Stacking Ensembles and Meta-Learners | Section
Tree-Based Ensemble Methods

Stacking Ensembles and Meta-Learners

Desliza para mostrar el menú

Stacking is an advanced ensemble technique where predictions from multiple base models are used as input features for a higher-level model, called a meta-learner. The meta-learner learns how to best combine the base models' outputs to improve overall performance.

Note
Definition

Meta-learner is a model that takes the predictions of base models as input and learns how to combine them for the final prediction.

Note
Definition

Stacking generalization is the process of training a meta-learner on the outputs of base models to generalize better than any single model.

1234567891011121314151617181920212223242526272829303132
from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.ensemble import StackingClassifier from sklearn.tree import DecisionTreeClassifier from sklearn.linear_model import LogisticRegression from sklearn.svm import SVC # Load dataset X, y = load_iris(return_X_y=True) X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) # Define base models base_estimators = [ ('dt', DecisionTreeClassifier(random_state=42)), ('lr', LogisticRegression(max_iter=1000, random_state=42)), ('svc', SVC(probability=True, random_state=42)) ] # Define meta-learner meta_learner = LogisticRegression(max_iter=1000, random_state=42) # Build stacking ensemble stacking_clf = StackingClassifier( estimators=base_estimators, final_estimator=meta_learner, cv=5 ) # Train and evaluate stacking_clf.fit(X_train, y_train) score = stacking_clf.score(X_test, y_test) print(f"Stacking ensemble accuracy: {score:.2f}")

In the code above, the base models generate predictions that are then used by the meta-learner to make the final decision. This approach can capture patterns that individual models might miss.

question mark

Which statement best describes the role of a meta-learner in a stacking ensemble

Selecciona la respuesta correcta

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 13

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

Stacking Ensembles and Meta-Learners

Stacking is an advanced ensemble technique where predictions from multiple base models are used as input features for a higher-level model, called a meta-learner. The meta-learner learns how to best combine the base models' outputs to improve overall performance.

Note
Definition

Meta-learner is a model that takes the predictions of base models as input and learns how to combine them for the final prediction.

Note
Definition

Stacking generalization is the process of training a meta-learner on the outputs of base models to generalize better than any single model.

1234567891011121314151617181920212223242526272829303132
from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.ensemble import StackingClassifier from sklearn.tree import DecisionTreeClassifier from sklearn.linear_model import LogisticRegression from sklearn.svm import SVC # Load dataset X, y = load_iris(return_X_y=True) X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) # Define base models base_estimators = [ ('dt', DecisionTreeClassifier(random_state=42)), ('lr', LogisticRegression(max_iter=1000, random_state=42)), ('svc', SVC(probability=True, random_state=42)) ] # Define meta-learner meta_learner = LogisticRegression(max_iter=1000, random_state=42) # Build stacking ensemble stacking_clf = StackingClassifier( estimators=base_estimators, final_estimator=meta_learner, cv=5 ) # Train and evaluate stacking_clf.fit(X_train, y_train) score = stacking_clf.score(X_test, y_test) print(f"Stacking ensemble accuracy: {score:.2f}")

In the code above, the base models generate predictions that are then used by the meta-learner to make the final decision. This approach can capture patterns that individual models might miss.

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 13
some-alt