Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use scikit-learn’s AdaBoostClassifier to build an ensemble that trains a sequence of classifiers, giving more weight to examples earlier classifiers get wrong. The simplest starting point is the default decision stump; then tune the number of boosting rounds and learning rate with cross-validation, and evaluate the final model on held-out data.

How AdaBoost works in scikit-learn

AdaBoost is a meta-estimator: it fits a classifier to the training data, then fits additional classifiers while adjusting sample weights so later learners focus more on examples misclassified earlier. The fitted ensemble combines the learners’ contributions to make predictions. The scikit-learn API documentation describes this process.

By default, AdaBoostClassifier uses a DecisionTreeClassifier with max_depth=1. This one-split tree is called a decision stump. Stumps are intentionally simple weak learners; boosting combines many of them rather than relying on one complex tree.

How to implement AdaBoost in Python

This Iris example shows the basic workflow: stratified train/test split, model fitting, prediction, and two classification metrics. The split, seed, and model settings are tutorial choices, not universal recommendations or a performance guarantee.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Lab Notebook Chemistry Laboratory Notebook for Science Students and Researchers – 105 Pages, 8.5 x 11 Inch – Perfect Bound Composition Book for Scientific Experiments, and Research Documentation
  • 【Ideal for Laboratory】 This lab notebook is designed for professionals and students alike, Perfect for recording experiment data, research notes, and scientific observations, helping you stay organized throughout your experiments.
  • 【High-Quality Paper】The laboratory notebook With 105 pages of thick, high-quality paper, this notebook prevents ink bleed-through, ensuring your notes stay neat and legible.
  • 【Durable and Practical】Bound with a strong, flexible cover that can withstand daily use in any lab environment, ensuring long-lasting durability.
  • 【Versatile Layout】 Features a blank grid format, providing you with plenty of space for detailed observations, sketches, and calculations.
  • 【Standard size】 8.5 x 11 Inch, 5 x 5 grid ruled (5 squares per inch) , Easy to carry in backpacks or lab bags, this chemistry laboratory notebook is an ideal choice for scientists, researchers, and students.
from sklearn.datasets import load_iris
from sklearn.ensemble import AdaBoostClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, classification_report

X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, stratify=y, random_state=42
)

model = AdaBoostClassifier(
    n_estimators=100,
    learning_rate=0.5,
    random_state=42,
)
model.fit(X_train, y_train)
pred = model.predict(X_test)
print(accuracy_score(y_test, pred))
print(classification_report(y_test, pred))

In current scikit-learn versions, the base-model parameter is named estimator; older examples may use the previous name, base_estimator. To supply a custom learner, use AdaBoostClassifier(estimator=...). It must support sample weighting and expose suitable classes_ and n_classes_ attributes. Check the API requirements for the installed version.

How to tune n_estimators and learning_rate

n_estimators sets the maximum number of boosting rounds. learning_rate scales each classifier’s contribution. The API documentation notes a trade-off between these controls: changing one can affect the useful setting of the other. A perfect fit can also cause training to stop before the maximum number of rounds is reached.

  1. Start with a simple base learner, usually the default stump.
  2. Choose a small grid of n_estimators and learning_rate values that is practical for your data and compute budget.
  3. Compare combinations with cross-validation on the training portion, using a metric that reflects the task and costs of errors.
  4. Select settings from validation results, then evaluate the chosen configuration once on a reserved test set for a final estimate.

Set random_state when the estimator exposes randomness and reproducible runs matter. A fixed seed makes a run repeatable under the same environment and data; it does not make a validation result representative by itself.

How to evaluate AdaBoostClassifier

Accuracy is useful when classes are reasonably balanced and error types have similar consequences. When those assumptions do not hold, choose a metric that matches the goal:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Tuun Fuplan Lab Notebook/Laboratory Notebook - (.25" Grid Format), Laboratory Notebook Quad Ruled Science Lab Book for Chemistry, Physics, 8" x 10", Spiral Bound, Flexible Cover, Blue
  • PROFESSIONAL DESIGN - Lab notebook each page features 1/4 grid and signature blocks. Pages printed front and back, perfect for precise drawings and detailed notes.
  • DURABLE COVER - LABORATORY NOTEBOOK is printed on the flexible cover. The flexible cover design ensures your notebook can withstand daily use and transport. Sturdy spiral-bound binding allows the notebook to lay flat, making it easy to write and view.
  • FEATURES - 8" x 10"|User Data|Documentation Guidelines|Table of Contents|Project Pages|.
  • LARGE CAPACITY - Contains 120 pages, providing ample space for all your important notes. Whether you are an engineer, student, researcher, or inventor, our high-quality engineering notebook is the perfect choice for recording and organizing critical information.
  • PREMIUM PAPER - This laboratory log book with thick 100gsm acid-free paper, ensuring your notes are preserved without fading or yellowing over time and prevent ink bleed-through.
  • Balanced accuracy gives each class equal weight in the average recall.
  • Precision, recall, and F1 help assess positive predictions and missed cases, particularly when class frequencies or error costs differ.
  • ROC AUC evaluates ranking across thresholds; use it when ranking quality is relevant.
  • Log loss evaluates probability predictions and penalizes confident errors.

Scikit-learn provides cross_val_score for cross-validation and staged methods—staged_predict, staged_predict_proba, staged_decision_function, and staged_score—to examine predictions or scores as the ensemble grows. These can help identify whether adding rounds improves validation performance or instead increases cost without a useful gain. Keep model selection separate from the final test-set estimate to avoid tuning to the test data. The scikit-learn ensemble guide demonstrates cross-validation with AdaBoost.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Multiclass, regression, and model comparisons

The scikit-learn user guide identifies AdaBoost.SAMME for multiclass classification. For regression, use AdaBoostRegressor, which implements AdaBoost.R2; it is a different estimator and task from the classifier example above. See the ensemble user guide for the documented variants.

When comparing AdaBoost with another ensemble, evaluate both on the same data splits and appropriate metrics. Useful comparison points include:

  • Sequential training versus methods that can train learners in parallel.
  • Sensitivity to noisy or mislabeled examples.
  • Whether the alternative base estimator meets AdaBoost’s sample-weight requirements.
  • How easy it is to inspect individual weak learners and their weights.
  • Training and prediction cost at the chosen model size.
  • Probability calibration and performance under the metric that matters for the application.

There is no dataset-independent winner established by these considerations alone. Scikit-learn’s examples demonstrate behavior on their particular datasets, not a general accuracy, speed, or uplift guarantee.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.