I have a list of integer ranging from -3 to 3.
list = [-0.33, -2.5, 2.1, ......., -1.2, -2.4444, 1.788]
Is there a way to convert all the numbers between 0 to 1?
I have a list of integer ranging from -3 to 3.
list = [-0.33, -2.5, 2.1, ......., -1.2, -2.4444, 1.788]
Is there a way to convert all the numbers between 0 to 1?
>>> from sklearn.preprocessing import StandardScaler
>>> data = [[0, 0, 0, 0, 1, 1, 1, 1]]
>>> scaler = StandardScaler()
>>> print(scaler.fit(data))
StandardScaler()
>>> print(scaler.mean_)
[0.5 0.5]
>>> print(scaler.transform(data))
this shall convert the data into -1 to 1
Add three to each, then divide by six.
lst = [-0.33, -2.5, 2.1, ......., -1.2, -2.4444, 1.788]
lst = [(i + 3) / 6 for i in lst]
(I renamed list
to lst
, as the former conflicts with the preexisting list
type)