from sklearn.preprocessing import MaxAbsScaler # create a dataset data = [[0.5, 1.2], [-3.3, 2.3], [6.7, 3.2]] # initialize the scaler scaler = MaxAbsScaler() # fit and transform the data scaled_data = scaler.fit_transform(data) print(scaled_data)
[[ 0.07462687 0.375 ] [-1. 0.71875 ] [ 1. 1. ]]In this example, we created a dataset of two features with some varying values. Then we initialized the scaler using `MaxAbsScaler()` method and applied it to the dataset using `fit_transform()` method. Finally, we printed the scaled data which is now scaled within the maximum absolute value range of [-1,1]. Overall, the package library used in this example is sklearn.preprocessing which is a part of the scikit-learn library.