On Thu, May 24, 2012 at 05:39:22PM -0400, Ian Goodfellow wrote:
> On Thu, May 24, 2012 at 5:07 PM, David Warde-Farley
> <[email protected]> wrote:
> > On Thu, May 24, 2012 at 04:22:30PM -0400, Ian Goodfellow wrote:
> >
> >> I think I need to introduce a dirty bit that determines whether coef_
> >> needs to be recomputed. It starts off as True, gets set to False
> >> whenever coef_ executes, and gets set to True whenever self.fit is
> >> called. Am I overlooking any other situations that should affect the
> >> dirty bit?
> >
> > An alternative might be to just compute it in fit() if kernel == 'linear',
> > and make the property function return the precomputed vector in that case.
> > That probably minimizes the number of bugs introduced by either neglecting 
> > to
> > update current functionality to use the dirty bit or future, orthogonal
> > functionality forgetting to respect the dirty bit.
> 
> I don't see how this solves anything.
>
> Any future functionality that would need to update the dirty bit in my 
> proposal
> would need to update the entire precomputed vector in your proposal.
 
> The only current functionality that needs to check the dirty bit is
> coef_ itself.
> Everything else is written in terms of coef_ because coef_cached_ doesn't
> exist yet. As long as all new code refers to coef_ rather than coef_cached_,
> the new code won't need to check the dirty bit.

Right, I guess the point I'm making is that lazy evaluation is unnecessary
if predict() is going to use coef_.

It would make sense to add a dirty bit/caching would be if coef_ was going to
be accessed only occasionally and sometimes not at all. But if it's going to
become needed every time one calls predict() on a SVC with a linear kernel,
then it might as well be precomputed in fit(), don't you think?

It has the fringe benefit that after a successful fit() call, predict()
should follow the same code path and incurs the same amount of computation
time on every call with the same input argument.

David

------------------------------------------------------------------------------
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