Excellent, so we can eat the cake and have it too ;-)

On 03.09.2013, at 23:02, Olivier Grisel <notifications@github.com> wrote:

> In sklearn/decomposition/factor_analysis.py:
> 
> > @@ -140,20 +156,35 @@ def fit(self, X, y=None):
> >          loglike = []
> >          old_ll = -np.inf
> >          SMALL = 1e-12
> > +
> > +        # we'll modify svd outputs to return unexplained variance
> > +        # to allow for unified computation of loglikelihood
> > +        if self.svd_method == 'svd':
> > +            def my_svd(X):
> > +                _, s, V = linalg.svd(X, full_matrices=False)
> > +                return (s[:n_components], V[:n_components],
> > +                        np.sum(s[n_components:] ** 2))
> > +        elif self.svd_method == 'randomized':
> > +            random_state = check_random_state(self.random_state)
> > +
> > +            def my_svd(X):
> > +                _, s, V = randomized_svd(X, n_components,
> > +                                         random_state=random_state)
> > +                return s, V, (X ** 2).sum() - np.sum(s ** 2)
> I think its good to do the validation for this param in the __init__ for early failure (by raising a ValueError) and also in the fit method in case the caller has changed the param value in the mean time (using the set_params method as the GridSearchCV class does for instance).
> 
> —
> Reply to this email directly or view it on GitHub.