scikit-learn/scikit-learn — pull request #1952 by jnothman (2013-05-08 23:45:04+00:00)
Title: ENH store per-transformer index into feature space in FeatureUnion

`FeatureUnion` provided no simple way to tell which parts of the stack belonged to which transformer. This provides a `feature_ptr_` attribute (of the form of `csr_matrix.indptr`) to solve that.

Caveats:
* it can only be determined when `fit_transform`, not `fit` is called
* it will be incorrect if one of the sub-transformers has a change of parameters that affects the output size at `transform` time without a re`fit`.

Both these caveats would be solved if each transformer in sklearn provided a way to get the number of output features. I suggest a `transformed_width_` attribute or `get_transformed_width()` method (better name?), the latter making it more clear that the output can be affected by `set_params`. I also suggest this be posed as an Easy Issue for someone to tackle.

Finally, `feature_ptr_` is compact, but it might be more usable if I add a method to get this as a dict from transformer-name to `slice`s.