Ark
2013-01-11 00:19:28 UTC
Hello,
I see an issue with predict in case of predicting a text document. [I load
an already trained classifier (OneVsRest(SGDClassifier(loss=log))) using
joblib.load].
Thanks.
In [1]: import sklearn
In [2]: from sklearn.externals import joblib
In [4]: clf = joblib.load("classifier.joblib")
In [6]: with open("topredict.txt") as f:
...: em = f.read()
In [7]: clf.predict
Out[7]:
<bound method OneVsRestClassifier.predict of
OneVsRestClassifier(estimator=SGDClassifier(alpha=1e-05, class_weight=None,
epsilon=0.1, eta0=0.0,
fit_intercept=True, learning_rate='optimal', loss='log', n_iter=35,
n_jobs=-1, penalty='l2', power_t=0.5, rho=0.85, seed=0,
shuffle=True, verbose=0, warm_start=False))>
In [8]: clf.predict(em)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-20-3c92945e466e> in <module>()
----> 1 clf.predict(em)
/home/n/env/lib/python2.6/site-packages/sklearn/multiclass.pyc in predict(self,
X)
180 self._check_is_fitted()
181
--> 182 return predict_ovr(self.estimators_, self.label_binarizer_, X)
183
184 @property
/home/n/env/lib/python2.6/site-packages/sklearn/multiclass.pyc in
predict_ovr(estimators, label_binarizer, X)
79 def predict_ovr(estimators, label_binarizer, X):
80 """Make predictions using the one-vs-the-rest strategy."""
---> 81 Y = np.array([_predict_binary(e, X) for e in estimators])
82 e = estimators[0]
83 thresh = 0 if hasattr(e, "decision_function") and is_classifier(e)
else .5
/home/n7/env/lib/python2.6/site-packages/sklearn/multiclass.pyc in
_predict_binary(estimator, X)
54 else:
55 # probabilities of the positive class
---> 56 return estimator.predict_proba(X)[:, 1]
57
58
AttributeError: 'list' object has no attribute 'predict_proba'
In [9]:
I see an issue with predict in case of predicting a text document. [I load
an already trained classifier (OneVsRest(SGDClassifier(loss=log))) using
joblib.load].
Thanks.
In [1]: import sklearn
In [2]: from sklearn.externals import joblib
In [4]: clf = joblib.load("classifier.joblib")
In [6]: with open("topredict.txt") as f:
...: em = f.read()
In [7]: clf.predict
Out[7]:
<bound method OneVsRestClassifier.predict of
OneVsRestClassifier(estimator=SGDClassifier(alpha=1e-05, class_weight=None,
epsilon=0.1, eta0=0.0,
fit_intercept=True, learning_rate='optimal', loss='log', n_iter=35,
n_jobs=-1, penalty='l2', power_t=0.5, rho=0.85, seed=0,
shuffle=True, verbose=0, warm_start=False))>
In [8]: clf.predict(em)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-20-3c92945e466e> in <module>()
----> 1 clf.predict(em)
/home/n/env/lib/python2.6/site-packages/sklearn/multiclass.pyc in predict(self,
X)
180 self._check_is_fitted()
181
--> 182 return predict_ovr(self.estimators_, self.label_binarizer_, X)
183
184 @property
/home/n/env/lib/python2.6/site-packages/sklearn/multiclass.pyc in
predict_ovr(estimators, label_binarizer, X)
79 def predict_ovr(estimators, label_binarizer, X):
80 """Make predictions using the one-vs-the-rest strategy."""
---> 81 Y = np.array([_predict_binary(e, X) for e in estimators])
82 e = estimators[0]
83 thresh = 0 if hasattr(e, "decision_function") and is_classifier(e)
else .5
/home/n7/env/lib/python2.6/site-packages/sklearn/multiclass.pyc in
_predict_binary(estimator, X)
54 else:
55 # probabilities of the positive class
---> 56 return estimator.predict_proba(X)[:, 1]
57
58
AttributeError: 'list' object has no attribute 'predict_proba'
In [9]: