scikit-learn/scikit-learn — pull request #3342 by dougalsutherland (2014-07-03 22:36:31+00:00)
Title: Truncating in MinMaxScaler

The output of MinMaxScaler doesn't always lie within the passed feature range, if data that you transform() has values outside the range of the values that you fit() on. If you're using it just to make the scale of the data nicer, this probably doesn't matter, but if your algorithm actually relies on the data lying in a certain range ([example](https://github.com/dougalsutherland/skl-groups/blob/2c7874e824b6f4c78d15c5e1c3f963b444a98b6e/skl_groups/summaries/l2_density.py)) this is no good.

So, this PR adds optional support for truncation, so that values that would be transformed outside of feature_range are clipped to the ends of it. It also adds a fit_feature_range to make truncation less likely (e.g. if you need your data to lie in [0, 1], you can make your training data like in [.1, .9] and then test values have more of a range to avoid clipping).

Incidentally, I also add assert_array_{less_equal,greater,greater_equal} because my tests wanted them and it's silly that numpy only provides assert_array_less.