On Thu, May 24, 2012 at 5:11 PM, Gael Varoquaux
<[email protected]> wrote:
> On Thu, May 24, 2012 at 05:06:51PM -0400, Ian Goodfellow wrote:
>> > It seems to me that a simple way to avoid the problem would be to do:
>
>> >    coef_ = self.coef_
>
>> > outside any for loop. That way the cost of computing the coef_ is
>> > hopefully negligeable.
>
>> > Do you think that this could work?
>
>> No. The only for loop we need to get rid of is the one contained in coef_.
>
> Then I don't understand: if there is no loop, where does the cost come
> from? Sorry if I am being dense: I am looking at this from very far and
> haven't fully understood your usecase.

There is a for loop in the predict function that is not necessary if
using kernel='linear'.
However, this same for loop is also present inside coef_, so replacing the
for loop with a call to coef_ does nothing but add function call overhead.

Specifically, the SVM decision function is based on
b + sum_i=1^n alpha_i K(x, x_i)

When the kernel is linear, we can replace this with
b + dot( coef, x)
where coef = sum_i=1^n alpha_i x_i.

However, rewriting the decision function in terms of coef only
results in the maximum speedup if we don't recompute coef
every time we get a new x.

If a script calls predict M times with N examples, then my proposal
gives a speedup of MxN over the current implementation. Computing
coef_ inside predict would give a speedup of only N.


>
> G
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to