[scikit-learn] Getting weight coefficient of logistic regression from a pipeline

Andreas Mueller t3kcit at gmail.com
Mon Aug 28 12:01:31 EDT 2017


Can can get the coefficients on the scaled data with
pipeline_lr.named_steps_['clf'].coef_
though


On 08/28/2017 12:08 AM, Raga Markely wrote:
> No problem, thank you!
>
> Best,
> Raga
>
> On Mon, Aug 28, 2017 at 12:01 AM, Joel Nothman <joel.nothman at gmail.com 
> <mailto:joel.nothman at gmail.com>> wrote:
>
>     No, we do not have a way to get the coefficients with respect to
>     the input (pre-scaling) space.
>
>     On 28 August 2017 at 13:20, Raga Markely <raga.markely at gmail.com
>     <mailto:raga.markely at gmail.com>> wrote:
>
>         Hello,
>
>         I am wondering if it's possible to get the weight coefficients
>         of logistic regression from a pipeline?
>
>         For instance, I have the followings:
>
>             clf_lr = LogisticRegression(penalty='l1', C=0.1)
>             pipe_lr = Pipeline([['sc', StandardScaler()], ['clf',
>             clf_lr]])
>             pipe_lr.fit(X, y)
>
>
>         Does pipe_lr have an attribute that I can call to get the
>         weight coefficient?
>
>         Or do I have to get it from the classifier as follows?
>
>             X_std = StandardScaler().fit_transform(X)
>             clf_lr = LogisticRegression(penalty='l1', C=0.1)
>             clf_lr.fit(X_std, y)
>             clf_lr.coef_
>
>
>         Thank you,
>         Raga
>
>
>         _______________________________________________
>         scikit-learn mailing list
>         scikit-learn at python.org <mailto:scikit-learn at python.org>
>         https://mail.python.org/mailman/listinfo/scikit-learn
>         <https://mail.python.org/mailman/listinfo/scikit-learn>
>
>
>
>     _______________________________________________
>     scikit-learn mailing list
>     scikit-learn at python.org <mailto:scikit-learn at python.org>
>     https://mail.python.org/mailman/listinfo/scikit-learn
>     <https://mail.python.org/mailman/listinfo/scikit-learn>
>
>
>
>
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20170828/1ba5a634/attachment.html>


More information about the scikit-learn mailing list