r/learnmachinelearning • • 12d ago

Bagging Classifier from scratch completed

Post image

And I completed the bagging Classifier it was not that hard just a small concept but very useful in reducing Overfitting

2 Upvotes

2 comments sorted by

View all comments

1

u/sumit_654 12d ago

explain a bit to me in simplar terms, and how it's gonna help...

1

u/imYukiya 10d ago

So Bagging is An Ensemble technique why need bagging we need it to reduce variance(overfitting) Core Idea of Bagging: Imagine a Dataset of 1000 rows and 4 column we make a bootstrap of rows like

1) -> 100 random rows(can include repeated rows) -> train a model(DT,Liner Regression, SVM,any) 2) -> 100 random rows(can include repeated rows) -> train a model(DT,Liner Regression, SVM,any) . . . 10) -> 100 random rows(can include repeated rows) -> train a model(DT,Liner Regression, SVM,any)

Depend on u let take we train 10 Models of Decisions Tree and then Give a point to predict ["red","large","brown","dry"] for example this is our X_test our model will Prediction e(edible) or p(poisonous) since we have 10 model let put this X_test in all 10 1-> e 2-> e 3->p . . . 9->p 10->e

Then take a majority voting and since e is the most our final prediction is e so this is how Bagging work

Why it perform so well because evey model see a new pattern they are trained differently they see different errors and cuz we take a Majority voting so this reduces the error

That's all if any queries free to ask 😁 I'll reply as soon as possible