GokuMohandas / Made-With-ML

Learn how to design, develop, deploy and iterate on production-grade ML applications.
https://madewithml.com
MIT License
37.07k stars 5.88k forks source link

Silly question: LabelEncoder #216

Closed knosing closed 1 year ago

knosing commented 1 year ago

While creating the LabelEncoder class, I couldnt understand why return self in class method fit(self,y)? My understanding is that when we call this method, the object variables are updated so no need for self? Please correct me if I'm wrong, just trying to reason myself with each step of the code.

    def fit(self, y):
        classes = np.unique(y)
        for i, class_ in enumerate(classes):
            self.class_to_index[class_] = i
        self.index_to_class = {v: k for k,v in self.class_to_index.items()}
        self.classes = list(self.class_to_index.keys())
        return self #Why?
knosing commented 1 year ago

I got it, for method chaining this is a standard form. Anyways, thanks a lot for this course. Learning a lot of new things!

GokuMohandas commented 1 year ago

Hey @knosing, I apologize for delay (outside of the country this month). But yup you got it and glad you're enjoying the material! I should have some major additions (and standardizations as the space matures) by March/April next year so look out for those updates!