Hi Ark
Thanks for reporting the issue.
Could you please provide a minimum code sample to reproduce and open an 
issue on github.
That would be great.
Which version of sklearn are you using?

Also, are you aware that you don't need the OneVsRestClassifier for 
multi-class support in SGDClassifier?
SGDClassifier has multi-class support on its own.
If you didn't know this, it would be good if you could point us to the 
docs that gave you the impression
you needed OneVsRestClassifier - this seems to be a common misconception.

Best,
Andy


On 01/11/2013 01:19 AM, Ark wrote:
> 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]:
>
>
> ------------------------------------------------------------------------------
> Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
> much more. Get web development skills now with LearnDevNow -
> 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
> SALE $99.99 this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122812
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general


------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to