[scikit-learn] Why is subset invariance necessary for transfom()?

Joel Nothman joel.nothman at gmail.com
Mon Jan 20 21:24:52 EST 2020


I think allowing subset invariance to not hold is making stronger
assumptions than we usually do about what it means to have a "test set".
Having a transformation like this that relies on test set statistics
implies that the test set is more than just selected samples, but rather
that a large collection of samples is available at one time, and that it is
in some sense sufficient or complete (no more samples are available that
would give a better fit). So in a predictive modelling context you might
have to set up your cross validation splits with this in mind.

In terms of API, the subset invariance constraint allows us to assume that
the transformation can be distributed or parallelized over samples. I'm not
sure whether we have exploited that assumption within scikit-learn or
whether related projects do so.

I see the benefit of using such transformations in a prediction Pipeline,
and really appreciate this challenge to our assumptions of what "transform"
means.

Joel

On Tue., 21 Jan. 2020, 11:50 am Charles Pehlivanian, <
pehlivaniancharles at gmail.com> wrote:

> Not all data transformers have a transform method. For those that do,
> subset invariance is assumed as expressed
> in check_methods_subset_invariance(). It must be the case that
> T.transform(X)[i] == T.transform(X[i:i+1]), e.g. This is true for classic
> projections - PCA, kernel PCA, etc., but not for some manifold learning
> transformers - MDS, SpectralEmbedding, etc. For those, an optimal placement
> of the data in space is a constrained optimization, may take into account
> the centroid of the dataset etc.
>
> The manifold learners have "batch" oos transform() methods that aren't
> implemented, and wouldn't pass that test. Instead, those that do -
> LocallyLinearEmbedding - use a pointwise version, essentially replacing a
> batch fit with a suboptimal greedy one [for LocallyLinearEmbedding]:
>
>     for i in range(X.shape[0]):
>         X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
>
> Where to implement the batch transform() methods for MDS,
> SpectralEmbedding, LocallyLinearEmbedding, etc?
>
> Another verb? Both batch and pointwise versions? The latter is easy to
> implement once the batch version exists. Relax the test conditions?
> transform() is necessary for oos testing, so necessary for cross
> validation. The batch versions should be preferred, although as it stands,
> the pointwise versions are.
>
> Thanks
> Charles Pehlivanian
> _______________________________________________
> 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/20200121/b402c42e/attachment.html>


More information about the scikit-learn mailing list