Hard Voting Classifier

Tree Models & Ensembles DS practice problem on Onlearn.

Difficulty: medium.

Topics: Understanding Ensemble Learning via Hard Voting, Mode Calculation, Tie-breaking Strategies, Estimator Parallelization, Multimodal Prediction Arrays, Weighted vs Unweighted Voting, Supervised Learning, Ensemble Methods, Statistical Inference, Classification Theory, Model Evaluation, Bagging Techniques, Bias-Variance Tradeoff, Majority Voting Rules, Weak vs Strong Learners, Classifier Aggregation.

Implement a 'HardVotingClassifier' class that takes a list of pre trained estimator objects. The class should have a 'predict' method that accepts a feature matrix X, collects predictions from all estimators, and returns the majority class label for each sample. If there is a tie, default to the lowest class label index.