Closed
Description
If I initialize an SGDClassifier object and try to access its 'predict_proba' method (not calling it, just referencing it), it throws NotFittedError
E.g.
from sklearn.linear_model import SGDClassifier
classifier = SGDClassifier()
classifier.predict_proba
# no parentheses on function
throws:
NotFittedError Traceback (most recent call last)
<ipython-input-6-02b9a01573f0> in <module>()
----> 1 a.predict_proba
~/anaconda3/lib/python3.6/site-packages/sklearn/linear_model/stochastic_gradient.py in predict_proba(self)
832 http://jmlr.csail.mit.edu/papers/volume2/zhang02c/zhang02c.pdf
833 """
--> 834 self._check_proba()
835 return self._predict_proba
836
~/anaconda3/lib/python3.6/site-packages/sklearn/linear_model/stochastic_gradient.py in _check_proba(self)
790
791 def _check_proba(self):
--> 792 check_is_fitted(self, "t_")
793
794 if self.loss not in ("log", "modified_huber"):
~/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py in check_is_fitted(estimator, attributes, msg, all_or_any)
766
767 if not all_or_any([hasattr(estimator, attr) for attr in attributes]):
--> 768 raise NotFittedError(msg % {'name': type(estimator).__name__})
769
770
NotFittedError: This SGDClassifier instance is not fitted yet. Call 'fit' with appropriate arguments before using this method.
However, the method is not being used, just referenced, which shouldn't cause an error.
Metadata
Metadata
Assignees
Labels
No labels