值:0.344 -0.124 0.880 0 0.910 -0.800
问问题
85 次
3 回答
0
您可以尝试cut()
在 R 中使用函数将值划分为区间。
value <- c(0.344, -0.124, 0.880, 0, 0.910, -0.800)
value.normalized <- cut(
x = value, breaks = seq(-1, 1, length.out = 8),
labels = -3:3, include.lowest = TRUE, right = TRUE
)
(value.normalized)
1 0 3 0 3 -3
Levels: -3 -2 -1 0 1 2 3
于 2019-12-06T07:11:59.107 回答
0
您可以执行以下操作将任何数据标准化为给定比例:
>>> Data = [0.9, 0.2, 0.3, 0.4]
>>> lower, upper =-3, 3
>>> Data_norm = [lower + (upper - lower) * x for x in Data]
>>> Data_norm
[2.4000000000000004, -1.7999999999999998, -1.2000000000000002, -0.5999999999999996]
于 2019-12-06T07:12:36.313 回答
0
利用sklearn.preprocessing.minmax_scale
In [1]: from sklearn.preprocessing import minmax_scale
In [2]: value = [0.344,-0.124,0.880,0,0.910,-0.800]
In [3]: in_range = [-1, 1]
In [4]: value_scaled = minmax_scale(value + in_range, feature_range=(-3,3))
In [5]: value_scaled[:-2]
Out[5]: array([ 1.032, -0.372, 2.64 , 0. , 2.73 , -2.4 ])
于 2019-12-06T07:43:32.390 回答