mla/base/base.py predict function
therickli opened this issue · 2 comments
therickli commented
I think there's a problem here.
def predict(self, X=None):
if not isinstance(X, np.ndarray):
X = np.array(X)
if self.X is not None or not self.fit_required:
return self._predict(X)
else:
raise ValueError("You must call `fit` before `predict`")
The following code shows that self.X is not None is always true.
>>> X=None
>>> isinstance(X,np.ndarray)
False
>>> X=np.array(X)
>>> X
array(None, dtype=object)
>>> X is not None
True
ageorgou commented
Not a contributor here, but I think I see the confusion: The predict
method checks self.X
(the estimator's training set), not the X
argument (the new point to be e.g. classified, which is what you've shown will not be None
). The training set self.X
is set up during fitting, so this essentially ensures that fitting has taken place before prediction, unless that's not required for the particular estimator being used.
therickli commented
Thanks, I understand it now.