Imagine you ask several friends for advice instead of just one. Why might their combined advice be better? Similarly, why do ensemble models often outperform a single model?
Think about how combining different opinions can reduce mistakes.
Ensembles combine predictions from multiple models, which helps cancel out individual errors and leads to better accuracy. They do not necessarily use deeper networks or more data, and they do not ignore weaker models but rather weigh all predictions.
You have 5 models each with variance 0.04 and zero covariance between them. What is the variance of the average prediction from these 5 models?
Variance of average of independent variables is variance divided by number of variables.
Variance of average = variance / number of models = 0.04 / 5 = 0.008.
What is the output of the following Python code that averages predictions from three models?
predictions = [[0.2, 0.8], [0.3, 0.7], [0.1, 0.9]] avg_pred = [sum(x)/len(x) for x in zip(*predictions)] print([round(p, 2) for p in avg_pred])
Calculate average for each class probability across models.
For class 0: (0.2+0.3+0.1)/3=0.2; for class 1: (0.8+0.7+0.9)/3=0.8.
You want to reduce both bias and variance in your model predictions. Which ensemble method is best suited for this?
Think about which method focuses on correcting errors and improving weak learners.
Boosting reduces bias by sequentially correcting errors and also reduces variance by combining models. Bagging mainly reduces variance. Simple averaging identical models does not reduce bias. Single deep networks may have high variance or bias.
Consider this code that tries to ensemble predictions by majority vote. What is the bug causing incorrect output?
import numpy as np preds = [[1,0,1],[0,1,1],[1,1,0]] ensemble_pred = [np.argmax(np.bincount(preds)) for i in range(len(preds[0]))] print(ensemble_pred)
Check what data np.bincount receives inside the list comprehension.
The code calls np.bincount on the entire list of predictions instead of the list of predictions at each position, so counts are wrong and majority vote fails.