Discussion:
[Scikit-learn-general] Use of safe functions such as safe_sqr
WENDLINGER Antoine
2016-01-13 16:40:59 UTC
Permalink
Hi everyone,

I'm working on issue 2121
<https://github.com/scikit-learn/scikit-learn/issues/2121#issuecomment-171067587>,
and have trouble understanding when to use safe methods like safe_sqr. What
I would want to do here is use np.linalg.norm on the coeff array when it is
of dimension 2, but it seems it is not the way to go (since it's not what
is done for example in the RFE feature selector, where the l2 norm of the
coeff array is used). Am I missing something here ?


Regards,

Antoine
Joel Nothman
2016-01-13 19:36:50 UTC
Permalink
safe_sqr applies when its operand may be a sparse matrix. In theory this
could be true of coef_, but I don't think this is tested as often as it
might be.

But, in general, you should not take what is done in any particular piece
of code to be indicative of best practice. There are often multiple ways to
do things, and while there may be a best choice, the best choice may change
over time as different parts of the codebase are atomically created or
modified. And we'll generally not be *that *nitpicky in reviewing, more
often focusing on readability, functionality and, where appropriate,
efficiency. In short, I don't think you need to worry about this much.

Supporting an arbitrary norm might be appropriate in RFE too.

HTH

- Joel
Post by WENDLINGER Antoine
Hi everyone,
I'm working on issue 2121
<https://github.com/scikit-learn/scikit-learn/issues/2121#issuecomment-171067587>,
and have trouble understanding when to use safe methods like safe_sqr. What
I would want to do here is use np.linalg.norm on the coeff array when it
is of dimension 2, but it seems it is not the way to go (since it's not
what is done for example in the RFE feature selector, where the l2 norm of
the coeff array is used). Am I missing something here ?
Regards,
Antoine
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
WENDLINGER Antoine
2016-01-15 12:27:59 UTC
Permalink
For RFE there is a specific test case where the coef_ is sparse. It's
messing things up since there does not seem to be a norm function for
sparse matrix in the current stable release of scipy. Should I define a
helper function that can compute the norm of a sparse matrix or just
convert coeff_ to a dense matrix ?
Post by Joel Nothman
safe_sqr applies when its operand may be a sparse matrix. In theory this
could be true of coef_, but I don't think this is tested as often as it
might be.
But, in general, you should not take what is done in any particular piece
of code to be indicative of best practice. There are often multiple ways to
do things, and while there may be a best choice, the best choice may change
over time as different parts of the codebase are atomically created or
modified. And we'll generally not be *that *nitpicky in reviewing, more
often focusing on readability, functionality and, where appropriate,
efficiency. In short, I don't think you need to worry about this much.
Supporting an arbitrary norm might be appropriate in RFE too.
HTH
- Joel
On 14 January 2016 at 03:40, WENDLINGER Antoine <
Post by WENDLINGER Antoine
Hi everyone,
I'm working on issue 2121
<https://github.com/scikit-learn/scikit-learn/issues/2121#issuecomment-171067587>,
and have trouble understanding when to use safe methods like safe_sqr. What
I would want to do here is use np.linalg.norm on the coeff array when it
is of dimension 2, but it seems it is not the way to go (since it's not
what is done for example in the RFE feature selector, where the l2 norm of
the coeff array is used). Am I missing something here ?
Regards,
Antoine
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
Loading...