New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'LogisticRegression' object has no attribute 'classes_' #11444
Comments
The usual way would be fit the estimator, serialize it (e.g. with joblib pickle) then unserialize and predict. Monkeypatching of estimator attributes as you are doing is not officially supported. You can do it, but it's up to you to read the code and set the needed attributes (all of which will not be public). In this case the Though, the documentation of the |
The model was built in the past using other programming language. We are simply implementing the model in production, so it doesn't make sense to retrieve the build dataset.
The 'LogisticRegression' object has no attribute 'classes_', and I don't know where it comes from. But indeed this is solved by logreg.classes_ = np.array([-1, 1]) |
The Estimators after learning by calling their Back to |
@Olamyy this is not necessarily true. When the I'm with @rth that this is more of a document issue. The |
I'm with @rth <https://github.com/rth> that this is more of a document
issue. The classes_ attribute is not mentioned in the Sklearn
LogisticRegression documentation. I'm feeling comfortable to close this
issue if we can have a short description ofclasses_ attribute in the
documentation.
+1 and at the same time check than all estimators that inherit from
ClassifierMixin do the same.
|
It could be worth enforcing this in |
working on this. |
hello can someone tell me about what this do "self.coef_.T" i read it used to change the coefficient of X[i] into sparse matrix but i can't get clear image, please help me out here |
working on this |
Closing since Thanks @judithabk6 for helping to clean our issue tracker! |
Description
I'm creating a logistic regression Python model from existing parameters for production. This is done by creating a
LogisticRegression
object and manually specifying the model coefficients. When I try to use this model object and thepredict()
method to predict an np matrix, I got the error messageOn the other hand, the
predict_proba()
works fine.Steps/Code to Reproduce
Example:
Expected Results
It should return the label predicted.
Actual Results
Versions
Darwin-17.6.0-x86_64-i386-64bit
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
NumPy 1.14.0
SciPy 1.0.0
Scikit-Learn 0.19.1
The text was updated successfully, but these errors were encountered: