Aumenta l'accuratezza e la robustezza del modello con i Model Ensemble. Esplora tecniche come bagging, boosting, stacking e applicazioni nel mondo reale.
A Model Ensemble is a strategic approach in machine learning where predictions from multiple individual models are combined to produce a final output that is often more accurate and robust than any single model could achieve alone. Much like a committee of experts deliberating to reach a better decision than a single individual, a model ensemble leverages the strengths of diverse architectures to mitigate errors. This technique is widely used to improve performance in complex tasks, reduce the risk of overfitting, and handle the inherent bias-variance tradeoff found in statistical modeling.
The core principle behind a model ensemble is "diversity." By training multiple models—often referred to as "base learners" or "weak learners"—on different subsets of training data or using different algorithms, the ensemble ensures that the errors made by one model are likely corrected by others. In the context of deep learning, this often involves running multiple neural networks in parallel during inference.
Common methods for combining these predictions include:
Model ensembles are essential in high-stakes environments where maximizing accuracy is paramount and computational resources allow for running multiple models.
While complex ensemble strategies can be built using libraries like Scikit-learn, you can create a basic inference ensemble for computer vision by simply loading multiple models and processing the same input. The following example demonstrates how to load two distinct Ultralytics YOLO models to generate predictions on the same image.
from ultralytics import YOLO
# Load two different model variants to create a diverse ensemble
model_a = YOLO("yolo26n.pt") # Nano model (Speed focused)
model_b = YOLO("yolo26s.pt") # Small model (Higher accuracy)
# Perform inference on an image with both models
# In production, results are typically merged programmatically
results_a = model_a("https://ultralytics.com/images/bus.jpg")
results_b = model_b("https://ultralytics.com/images/bus.jpg")
print(f"Model A detected {len(results_a[0].boxes)} objects.")
print(f"Model B detected {len(results_b[0].boxes)} objects.")
It is helpful to differentiate a standard model ensemble from a Mixture of Experts (MoE), a term often seen in modern Large Language Model (LLM) research.
The primary advantage of using a model ensemble is the boost in performance. Ensembles frequently dominate leaderboards in data science challenges like Kaggle competitions because they can model complex patterns that single models miss. However, this comes with a cost: deploying ensembles requires more memory and compute power.
For teams looking to manage these resource demands efficiently, the Ultralytics Platform offers tools to train, track, and benchmark different model architectures. By comparing performance metrics easily, developers can decide if the accuracy gain from an ensemble justifies the extra infrastructure required for deployment in edge AI scenarios.