Discussion:
[Scikit-learn-general] Set coefficients for LogisticRegression() instance.
Jieyun Fu
2011-12-16 19:28:28 UTC
Permalink
So I read the scikit-learn package webpate:

http://scikit-learn.sourceforge.net/dev/modules/generated/sklearn.linear_model.LogisticRegression.html

I can use logistic regression to fit the data, and after I obtain an
instance of LogisticRegression, I can use it to classify new data points.
So far so good.

Is there a way to set the coefficients of LogisticRegression() instance
though? Because after I obtain the trained coefficients, I want to use the
same API to classify new data points. I also don't want to keep retraining
the data to obtain that particular instance that has the coefficients I
want.

For example, I want to do something like

lg = LogisticRegression()

lg.coef_ = [blah blah blah]
xinfan meng
2011-12-17 04:48:18 UTC
Permalink
Why would you want to set the coefficients manually? If you want to reuse
the model, you can always save the model and load it when you want to use
it. If you want to train the model in an online setting, I think there is a
SGD api for this.
Post by Jieyun Fu
http://scikit-learn.sourceforge.net/dev/modules/generated/sklearn.linear_model.LogisticRegression.html
I can use logistic regression to fit the data, and after I obtain an
instance of LogisticRegression, I can use it to classify new data points.
So far so good.
Is there a way to set the coefficients of LogisticRegression() instance
though? Because after I obtain the trained coefficients, I want to use the
same API to classify new data points. I also don't want to keep retraining
the data to obtain that particular instance that has the coefficients I
want.
For example, I want to do something like
lg = LogisticRegression()
lg.coef_ = [blah blah blah]
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
--
Best Wishes
--------------------------------------------
Meng Xinfan蒙新泛
Institute of Computational Linguistics
Department of Computer Science & Technology
School of Electronic Engineering & Computer Science
Peking University
Beijing, 100871
China
Jieyun Fu
2011-12-17 05:28:37 UTC
Permalink
I guess that's the same questions then. How do I *save the model* ? Through
pickling? Thanks!
Post by xinfan meng
Why would you want to set the coefficients manually? If you want to reuse
the model, you can always save the model and load it when you want to use
it. If you want to train the model in an online setting, I think there is a
SGD api for this.
Post by Jieyun Fu
http://scikit-learn.sourceforge.net/dev/modules/generated/sklearn.linear_model.LogisticRegression.html
I can use logistic regression to fit the data, and after I obtain an
instance of LogisticRegression, I can use it to classify new data points.
So far so good.
Is there a way to set the coefficients of LogisticRegression() instance
though? Because after I obtain the trained coefficients, I want to use the
same API to classify new data points. I also don't want to keep retraining
the data to obtain that particular instance that has the coefficients I
want.
For example, I want to do something like
lg = LogisticRegression()
lg.coef_ = [blah blah blah]
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
--
Best Wishes
--------------------------------------------
Meng Xinfan蒙新泛
Institute of Computational Linguistics
Department of Computer Science & Technology
School of Electronic Engineering & Computer Science
Peking University
Beijing, 100871
China
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
xinfan meng
2011-12-17 05:30:39 UTC
Permalink
Take a look at this.
http://scikit-learn.sourceforge.net/stable/tutorial.html#model-persistence
Post by Jieyun Fu
I guess that's the same questions then. How do I *save the model* ?
Through pickling? Thanks!
Post by xinfan meng
Why would you want to set the coefficients manually? If you want to reuse
the model, you can always save the model and load it when you want to use
it. If you want to train the model in an online setting, I think there is a
SGD api for this.
Post by Jieyun Fu
http://scikit-learn.sourceforge.net/dev/modules/generated/sklearn.linear_model.LogisticRegression.html
I can use logistic regression to fit the data, and after I obtain an
instance of LogisticRegression, I can use it to classify new data points.
So far so good.
Is there a way to set the coefficients of LogisticRegression() instance
though? Because after I obtain the trained coefficients, I want to use the
same API to classify new data points. I also don't want to keep retraining
the data to obtain that particular instance that has the coefficients I
want.
For example, I want to do something like
lg = LogisticRegression()
lg.coef_ = [blah blah blah]
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
--
Best Wishes
--------------------------------------------
Meng Xinfan蒙新泛
Institute of Computational Linguistics
Department of Computer Science & Technology
School of Electronic Engineering & Computer Science
Peking University
Beijing, 100871
China
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
--
Best Wishes
--------------------------------------------
Meng Xinfan蒙新泛
Institute of Computational Linguistics
Department of Computer Science & Technology
School of Electronic Engineering & Computer Science
Peking University
Beijing, 100871
China
Olivier Grisel
2011-12-18 12:30:06 UTC
Permalink
For reference a similar question was asked here:

http://stackoverflow.com/questions/8539141/sklearn-scikit-learn-logistic-regression-package-set-trained-coefficients-f

I have open an issue to track the coefficients issue here:

https://github.com/scikit-learn/scikit-learn/issues/470
--
Olivier
Jieyun Fu
2011-12-18 22:18:48 UTC
Permalink
Thanks Xinfan and Olivier. I appreciate your info!
Post by Olivier Grisel
http://stackoverflow.com/questions/8539141/sklearn-scikit-learn-logistic-regression-package-set-trained-coefficients-f
https://github.com/scikit-learn/scikit-learn/issues/470
--
Olivier
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
Loading...