8000 LogisticRegression and LinearSVC should have read-write coef_ and intercept_ attributes · Issue #470 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

LogisticRegression and LinearSVC should have read-write coef_ and intercept_ attributes #470

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

Closed
ogrisel opened this issue Dec 18, 2011 · 4 comments

Comments

@ogrisel
Copy link
Member
ogrisel commented Dec 18, 2011

As reported on this stackoverflow question the current implementation of liblinear models is using a special memory layout for the coefficient (currently stored in the raw_coef_ array). Those coefficients are made read-only accessible to the user by means of the python properties coef_ and intercept_. However this solution prevents the user to change some of the coefficient values or to reassign a complete coef_ array on a the fitted estimator.

It would be much nicer to have coef_ / intercept_ as traditional array attributes instead.

Options:

  • store parameters fitted by liblinear using the traditional coef_ / intercept_ layout and copy those parameters at prediction time to a temporary array suitable for prediction using liblinear
  • implement predict and predict_proba in numpy instead of using liblinear at prediction time hence we could use standard numpy arrays with the usual layout for coef_ and intercept_
@dszhengyu
Copy link

It is that after training a LR and get coef_ and intercept_ stored in disk, next time I could just get a new instance LR() and chage the coef_ and intercept_ fromin disk, the I don't need to train it again?

@amueller
Copy link
Member
amueller commented Apr 1, 2015

Yes, that is what a164d57 ensures. You can just store the whole model, too, though: http://scikit-learn.org/dev/modules/model_persistence.html

@dszhengyu
Copy link

just changed the coef_ & intercept_ still can't work, it would ask for class_ or sth like that

I have just used pickle and it work well

thank you for the marvellous packege you guys development

and you are the first foreigner I have speaked with!
so i speak so much...

@Sandy4321
Copy link

1
may you clarify it is done or not?
some working example?
there is some clue that it is done
a164d57

but prove needed that it works : changed coeffs are used for prediction?
and new coeffs are used for next fit when warm_start=True

2
this indirect way
by using fake double fit with warm_start=True and coeffs resetting in middle
coeffs initialization can be done or not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0