This SLEP proposes the introduction of a public
for most transformers (where relevant).
Knowing the number of features that a transformer outputs is useful for inspection purposes. This is in conjunction with *SLEP010: ``n_features_in_``*.
The proposed solution is for the
n_features_out_ attribute to be set once a
fit is done. In many cases the value of
n_features_out_ is the
same as some other attribute stored in the transformer, e.g.
n_components_, and in these cases a
Mixin such as a
n_features_out_ to those attributes.
A test to the common tests is added to ensure the presence of the attribute or
property after calling
The main consideration is that the addition of the common test means that
existing estimators in downstream libraries will not pass our test suite,
unless the estimators also have the
The newly introduced checks will only raise a warning instead of an exception for the next 2 releases, so this will give more time for downstream packages to adjust.
There are other minor considerations:
- In some meta-estimators, this is delegated to the
n_features_out_attribute of the meta-estimator is thus explicitly set to that of the sub-estimator, either via a
@property, or directly in
- Some transformers such as
FunctionTransformermay not know the number of output features since arbitrary arrays can be passed to
transform. In such cases
n_features_out_is set to