我目前正在使用MinMaxScaler()
,但是StandardScaler()
对我来说也是一样。我究竟做错了什么?我的功能列表也发生了同样的情况。其中一些甚至还没有关闭?
test_labels
array([[1100. , 0.05, 0.69],
[1095. , 0.15, 1.2 ],
[1097. , 0.13, 1.14],
[1094. , 0.12, 1.15]])
MinMax_scaler = MinMaxScaler(feature_range=(-1, 1))
test_labels_MinMax = MinMax_scaler.fit_transform(test_labels)
test_labels_MinMax
array([[ 1. , -1. , -1. ],
[-0.66666667, 1. , 1. ],
[ 0. , 0.6 , 0.76470588],
[-1. , 0.4 , 0.80392157]])
MinMax_scaler.inverse_transform(test_labels_MinMax)
array([[1101. , 0.05 , 0.4 ],
[1100.16666667, 1.05 , 1.4 ],
[1100.5 , 0.85 , 1.28235294],
[1100. , 0.75 , 1.30196078]])
答案 0 :(得分:1)
如果我在空笔记本上运行相同的脚本:
import numpy as np
test_labels = np.array([[1100. , 0.05, 0.69],
[1095. , 0.15, 1.2 ],
[1097. , 0.13, 1.14],
[1094. , 0.12, 1.15]])
from sklearn.preprocessing import MinMaxScaler
MinMax_scaler = MinMaxScaler(feature_range=(-1, 1))
test_labels_MinMax = MinMax_scaler.fit_transform(test_labels)
MinMax_scaler.inverse_transform(test_labels_MinMax)
它给了我确切的匹配结果:
array([[1.100e+03, 5.000e-02, 6.900e-01],
[1.095e+03, 1.500e-01, 1.200e+00],
[1.097e+03, 1.300e-01, 1.140e+00],
[1.094e+03, 1.200e-01, 1.150e+00]])
是不是您在两者之间使用MinMax_scaler,然后以错误的拟合方式应用了它?