Once several classifiers are trained, you still have to turn their separate answers into one. Hard voting counts class votes. Soft voting averages predicted probabilities, so a confident model can outweigh two lukewarm ones.
Implement hard_vote(predictions) and soft_vote(probabilities, weights=None). Both return one predicted class per sample.
predictions has shape (n_models, n_samples) and holds integer class labels.probabilities has shape (n_models, n_samples, n_classes); weights is an optional length-n_models array.n_samples.Open one at a time. Each gives away a little more than the last.
For hard voting, np.unique(column, return_counts=True) lists labels in sorted order, so np.argmax over the counts already breaks ties toward the smallest label.
For soft voting, average over the model axis first (weighted if weights are given, divided by their sum), then take argmax over the class axis.
No results yet
Run your code to check it against the examples, or submit to run every test.