Skip to content
Advertisement

do i need to use exactly same attribute names to properties in custom preprocessing class which inherit scikit learn BaseEstimator?

when writing custom classes inherit from BaseEstimator of the sklearn throwing AttributeError: object has no attribute . but that attribute is present and has values.

JavaScript

print(null) execute or null. then it throws the above attribute error. traceback shows that this error happens in getattr() in sklearn base.

JavaScript

I found that this is caused by attributes that assign to different property names ex: self.row = row_wise. what’s happening here? and can I use different property names to assign attribute values?

Advertisement

Answer

do i need to use exactly same attribute names to properties in custom preprocessing class which inherit scikit learn BaseEstimator?

Yes. See this part of the docs:

All scikit-learn estimators have get_params and set_params functions. The get_params function takes no arguments and returns a dict of the __init__ parameters of the estimator, together with their values.

(Source.)

In other words, if you have a parameter to __init__ called variables, then it expects self.variables to be a valid variable.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement