1.需要标准化:k-均值聚类,最邻近法则,径向基核函数,欧式距离
2.不需要标准化:基于空间分类的,决策树、梯度提升、随机森林;
3.线性回归需要数据服从高斯分布:对数运算。
4.数值计数:二值化,数据区间量化:固定宽度分箱
这时分箱宽度是呈指数增长的,从 O(10) 到 O(100)、 O(1000) 以及更大。要将计数值映射到分箱,需要取计数值的对数。指数宽度分箱与对数变换的关系非常紧密
np.floor_divide(small_counts, 10):数据除以10,向下元整。
small_counts = np.random.randint(0, 100, 20)
small_counts
array([30, 64, 49, 26, 69, 23, 56, 7, 69, 67, 87, 14, 67, 33, 88, 77, 75,
47, 44, 93])
通过除法映射到间隔均匀的分箱中,每个分箱的取值范围都是0~9
np.floor_divide(small_counts, 10)
array([3, 6, 4, 2, 6, 2, 5, 0, 6, 6, 8, 1, 6, 3, 8, 7, 7, 4, 4, 9], dtype=int32)
横跨若干数量级的计数值数组
large_counts = [296, 8286, 64011, 80, 3, 725, 867, 2215, 7689, 11495, 91897,
… 44, 28, 7971, 926, 122, 22222]
通过对数函数映射到指数宽度分箱
np.floor(np.log10(large_counts))
array([ 2., 3., 4., 1., 0., 2., 2., 3., 3., 4., 4., 1., 1., 3., 2., 2., 4.])