PinterestOA #2
Bagging Classifier (Bootstrap Aggregating)
Estimated MediumNon-algorithmicStatement and editorial — judging is being prepared
Topics (AI-labelled)SimulationBits & Math
Implement the missing code, denoted by ellipses. You may not modify the pre-existing code.
Your task is to implement parts of a Bagging algorithm from scratch (i.e., without importing any libraries or packages besides those already imported). As a reminder, Bagging classification comprises three major steps:
- Bootstrap the train sample for each base classifier.
- Train each base classifier based on its own bootstrapped samples.
- Assign class labels by majority vote of the base classifiers.
To validate the algorithm implementation, you will need to use it for some classification tasks. You will be given x_train (2D float array), y_train (1D int array of labels), and x_test.
Notes:
- It is guaranteed that all training and test data will be float values.
- In case of a tie in the voting, select the class label with the lower number.
- For bootstrapping:
nindices generated per classifier, wherenis the number of training samples. Each indexigenerated byrandintwith0 <= i < n. Indexes could repeat.seedshould be used only in its initial place.
Editorial
Loading solution…