StandardScaler follows Standard Normal Distribution (SND). Therefore, it makes mean = 0 and scales the data to unit variance.
MinMaxScaler scales all the data features in the range [0, 1] or else in the range [-1, 1] if there are negative values in the dataset. This scaling compresses all the inliers in the narrow range [0, 0.005].
In the presence of outliers, StandardScaler does not guarantee balanced feature scales, due to the influence of the outliers while computing the empirical mean and standard deviation. This leads to the shrinkage in the range of the feature values.
By using RobustScaler(), we can remove the outliers and then use either StandardScaler or MinMaxScaler for preprocessing the dataset.
How RobustScaler works:
It scales features using statistics that are robust to outliers. This method removes the median and scales the data in the range between 1st quartile and 3rd quartile. i.e., in between 25th quantile and 75th quantile range. This range is also called an Interquartile range.
The median and the interquartile range are then stored so that it could be used upon future data using the transform method. If outliers are present in the dataset, then the median and the interquartile range provide better results and outperform the sample mean and variance.
RobustScaler uses the interquartile range so that it is robust to outliers. Therefore its formula is as follows:
Code: comparison between StandardScaler, MinMaxScaler and RobustScaler.
Parameters of RobustScaler:
- with_centering: boolean: It is True by default. If the value is True, the data is centred before scaling. When it is applied on sparse matrices, the transform will raise an exception because centring them requires building a dense matrix, which generally is too large to fit in the memory.
- with_scaling: boolean: It is also set to True by default. It scales the data to the interquartile range.
- quantile_range: tuple(q_min, q_max), 0.0 < q_min < q_max < 100.0 : Quantile range is used to calculate scale. By default, it is set as below. Default: (25.0, 75.0) = (1st quantile, 3rd quantile) = IQR.
- copy: boolean It is an optional parameter. By default, it is True. If the input is already a NumPy array or a scipy.sparse CSC matrix and if axis = 1, avoid a copy by setting this parameter to False and instead perform inplace row normalization.
- center_: array of floats: The median value for each feature in the training set.
- scale_: array of floats: The scaled interquartile range for the feature in the training set.
- Impact of AI and ML On Warfare Techniques
- Different Input and Output Techniques in Python3
- Looping Techniques in Python
- Short Circuiting Techniques in Python
- Feature Extraction Techniques - NLP
- Optimization techniques for Gradient Descent
- Types of Regression Techniques
- Python | Thresholding techniques using OpenCV | Set-1 (Simple Thresholding)
- Python | Thresholding techniques using OpenCV | Set-2 (Adaptive Thresholding)
- Python | Thresholding techniques using OpenCV | Set-3 (Otsu Thresholding)
- Feature Encoding Techniques - Machine Learning
- Loops and Control Statements (continue, break and pass) in Python
- Python counter and dictionary intersection example (Make a string using deletion and rearrangement)
- Python | Using variable outside and inside the class and method
- Releasing GIL and mixing threads from C and Python
- Interquartile Range and Quartile Deviation using NumPy and SciPy
- Django Request and Response cycle - HttpRequest and HttpResponse Objects
- Python | Boolean List AND and OR operations
- Text Detection and Extraction using OpenCV and OCR
- Difference between 'and' and '&' in Python