Issue
I am a bit confused about what exactly every function within this pipeline does. Can someone explain how this pipeline works? I know roughly how, but some clarification would be immensely helpful.
Why is capital 'X' used in def
transform(self, X)
?What's the point of
get_feature_names
and__init__
specifically?
Code:
class custom_fico(BaseEstimator,TransformerMixin):
def __init__(self):
self.feature_names = ['fico']
def fit(self,x,y=None):
return self
def transform(self,X):
k = X['FICO.Range'].str.split('-',expand = True).astype(float)
fico = 0.5 * (k[0] + k[1])
return pd.DataFrame({'fico':fico})
def get_feature_names(self):
return self.feature_names
Solution
1- try this link. Very helpful to understand everything and it makes everything clear. https://medium.com/@shivangisareen/pipelining-in-python-7edd2382f67d
2- I think that its not necessary to use capital X. I think you can use anything else and still work but in this case the code writer just chose capital x.
3- and lastly, the init method is similar to constructors in C++ and Java . Constructors are used to initialize the object's state. The task of constructors is to initialize(assign values) to the data members of the class when an object of class is created.
If you need any further help, the community is here for you!
Answered By - Ahmed Hamouda
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.