haifengl / smile

Statistical Machine Intelligence & Learning Engine
https://haifengl.github.io
Other
6.02k stars 1.13k forks source link

Make FeatureTransform invertible #656

Closed gciatto closed 3 years ago

gciatto commented 3 years ago

It may be useful to make subtypes of smile.feature.FeatureTransform invertible, meaning that they also support the inverse transformations. For instance, I may be willing to scale a dataset via an instance of smile.feature.Scaler and then scale back some of its rows to the original size.

One simple solution could be to add a FeatureTransform invert() method to smile.feature.FeatureTransform returning another instance of smile.feature.FeatureTransform carrying the inverse transform:

public interface FeatureTransform extends Serializable {
    double[] transform(double[] x);
    default double[][] transform(double[][] data);
    Tuple transform(Tuple x);
    DataFrame transform(DataFrame data);

    FeatureTransform invert(); // new entry here
}

This may then imply a method to be added to 4 classes, namely: MaxAbsScaler, Normalizer, Standardizer, and Scaler

haifengl commented 3 years ago

added

gciatto commented 3 years ago

Have you released a new version containing this feature?

haifengl commented 3 years ago

No. We generally don't make a release for a small feature.