首页 > 解决方案 > 对不同的特征使用不同的特征缩放技术是否正确?

问题描述

我读了这篇关于特征缩放的文章: all-about-feature-scaling

两种主要的特征缩放技术是:

  1. min-max scaler- 它对具有非高斯分布的特征响应良好。

  2. Standard scaler- 对具有高斯分布的特征反应良好。

我阅读了其他帖子和示例,似乎我们总是对所有功能使用一种缩放方法(min-maxstandard)。

我还没有看到建议的示例或论文:

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
  1. 为什么我们不混合缩放方法?

  2. 我的建议有什么问题或缺点?

标签: machine-learningdata-sciencefeature-scaling

解决方案


然后,您的特征将具有不同的比例,这是一个问题,因为具有较大比例的特征将主导其余特征(例如,在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')

在此处输入图像描述


推荐阅读