In order to normalize values in Python, you can use the scikit-learn library. Specifically, you can use the MinMaxScaler
class from the sklearn.preprocessing
module.
Here's an example of how to normalize values using MinMaxScaler
:
main.py296 chars16 lines
This will output the following normalized values:
main.py57 chars5 lines
The values will be normalized between the range of 0 and 1, with the highest value being 1 and the lowest value being 0. The MinMaxScaler
class automatically handles the normalization process for you.
Note that the fit()
method is used to compute the minimum and maximum values of the data, while the transform()
method is used to apply the normalization to the data.
Make sure to import the MinMaxScaler
class from the sklearn.preprocessing
module before using it.
tags: normalization, data-preprocessing, scikit-learn
gistlibby LogSnag