machine-learning - 对不同的特征使用不同的特征缩放技术是否正确?
问题描述
我读了这篇关于特征缩放的文章: all-about-feature-scaling
两种主要的特征缩放技术是:
min-max scaler
- 它对具有非高斯分布的特征响应良好。Standard scaler
- 对具有高斯分布的特征反应良好。
我阅读了其他帖子和示例,似乎我们总是对所有功能使用一种缩放方法(min-max
或standard
)。
我还没有看到建议的示例或论文:
1. go over all the features, and for each feature:
1.1 check feature distribution
1.2 if the feature distribution is Gaussian:
1.2.1 use Standard scaler for this feature
1.3 otherwise:
1.3.1 use min-max scaler for this feature
为什么我们不混合缩放方法?
我的建议有什么问题或缺点?
解决方案
然后,您的特征将具有不同的比例,这是一个问题,因为具有较大比例的特征将主导其余特征(例如,在KNN中)。具有最小-最大归一化的特征将被重新缩放到 [0,1] 范围,而具有标准化的特征将被转换为负到正的范围(例如,[-2,+2] 甚至更宽小标准偏差)。
import pandas as pd
from sklearn.preprocessing import MinMaxScaler, StandardScaler
dfTest = pd.DataFrame({'A':[14,90,80,90,70],
'B':[10,107,110,114,113]})
scaler = MinMaxScaler()
dfTest['A'] = scaler.fit_transform(dfTest[['A']])
scaler = StandardScaler()
dfTest['B'] = scaler.fit_transform(dfTest[['B']])
ax = dfTest.plot.scatter('A', 'B')
ax.set_aspect('equal')
推荐阅读
- virtualbox - VirtualBox 虚拟机列表窗口消失
- javascript - React -> 仅将对象的“id”和“name”保存在一种状态
- typescript - 为什么我不能使用联合类型参数调用泛型函数?
- php - 将文件上传到 codeigniter 中的自定义路径
- google-analytics - Google Analytics 如何处理过长的参数
- javascript - 如何将类添加到 Select2 中的标签
- python - 如何解决 anaconda python 中的数据重塑错误?
- javascript - 我的工作报价计算器返回“X 不是函数”
- c - 控制变量位置对循环体的影响
- wpf - WPF 触发器无法更改 mvvm 中的属性