nedjelja, 28. srpnja 2024.

MaxAbsScaler

Step one: Select a .csv format file.
0%
Step two: Download the file after the process is completed.

The Max Abs Scaler

The MaxAbsScaler is the data preprocessing technique which is commonly used in Machine learning to scale the dataset features (variables). The main purpose of this scaler is to transform the data to a -1 to 1 range, based on the maximum absolute value of each feature. This technique is particularly useful for data that contains both positive and negative values and when maintaining sparsity is important (text processing and sparse data matrices).

How MaxAbsScaler works ?

The MaxAbsScaler consist of two steps i.e. Identifying the Maximum Absolute value and Scale the Feature (Variable). After the dataset is uploaded the MaxAbsScaler algorithm for each feature/variable (column) in the dataset, find the maximum absolute value. Then each value in the feature/variable (column) is divided by the maximum absolute value for that feature. The formula for scaling values of any feature/variable (column) can be written in the following form: \begin{equation} x_s = \frac{x}{\max(|x|)} \end{equation} where \(x\) is the original value, and \(\max(|x|)\) is the maximum absolute value of the feature/variable (column).

Example: Application of MaxAbsScaler

In this example the MaxAbsScaler will be applied on two features/Variables (columns) of the dataset. Here the features are defined in form of the array. \begin{eqnarray} x_1 &=& [1,-2,3,-4]\\ x_2 &=& [-3,4,-1,2] \end{eqnarray} The first step is to identify the maximum absolute value for each feature/variable column. For the first feature \(x_1\) the maximum absolute value is equal to 4. \begin{equation} \max(|1|,|-2|,|3|,|-4|) = \max(1,2,3,4) = 4 \end{equation} For the second feature \(x_2\) the maximum absolute value is equal to 4. \begin{equation} \max(|-3|, |4|, |-1|, |2|) = \max(3,4,1,2) = 4 \end{equation} The second step is to scale each value in the dataset by dividing the maximum absolute value for the respective feature.

Scaling First Feature

The original value of the first element in a first feature \(x_1\) array is 1 while the scaled value is equal to 0.25. \begin{equation} x_{s11} = \frac{x_{11}}{\max(|x_1|)} = \frac{1}{4} = 0.25. \end{equation} The original value of the second element in a first feature \(x_1\) array is -2 while the scaled value is equal to -0.5. \begin{equation} x_{s12} = \frac{x_{12}}{\max(|x_1|)} = \frac{-2}{4} = -0.5. \end{equation} The original value of the third element in a first feature \(x_1\) array is 3 while the scaled value is equal to -0.5. \begin{equation} x_{s13} = \frac{x_{13}}{\max(|x_1|)} = \frac{3}{4} = 0.75. \end{equation} The original value of the fourth element in a first feature \(x_1\) array is -4 while the scaled value is equal to -0.5. \begin{equation} x_{s14} = \frac{x_{14}}{\max(|x_1|)} = \frac{-4}{4} = -1.00. \end{equation} The scaled array can be written as: \begin{equation} x_{1s} = [0.25,-0.50,0.75,-1.00] \end{equation}

Scaling Second Feature

The original value of the first element in a second feature \(x_2\) array is -3 while the scaled value is equal to -0.75. \begin{equation} x_{s21} = \frac{x_{21}}{\max(|x_2|)} = \frac{-3}{4} = -0.75. \end{equation} The original value of the second element in a second feature \(x_2\) array is 4 while the scaled value is equal to 1.00. \begin{equation} x_{s22} = \frac{x_{22}}{\max(|x_2|)} = \frac{4}{4} = 1.00. \end{equation} The original value of the third element in a second feature \(x_2\) array is -1 while the scaled value is equal to -0.25. \begin{equation} x_{s23} = \frac{x_{23}}{\max(|x_2|)} = \frac{-1}{4} = -0.25. \end{equation} The original value of the fourth element in a second feature \(x_2\) array is 2 while the scaled value is equal to 0.5. \begin{equation} x_{s24} = \frac{x_{24}}{\max(|x_2|)} = \frac{2}{4} = 0.5. \end{equation} The scaled array can be written as: \begin{equation} x_{2s} = [-0.75,1.00,-0.25,0.5] \end{equation} The MaxAbsScaler is used when the sparsity of the data must be preserved, when data contains both positive and negative values, and when scaling data would not affect the distorting the range of values significantly.

Nema komentara:

Objavi komentar

CSV to SQL Converter

CSV to SQL Converter Step 1: Choose CSV File ...