简体   繁体   English

线性回归缩放功能

[英]Linear Regression Scaling Features

I want to do a linear regression.我想做一个线性回归。

My features are something like this:我的特点是这样的:

Marketcap       EBIT Margin   Price to Book Ratio   EPS Growth

5.589918e+08    23.05            8.71                 7.16
5.572475e+08    65.00            9.68              - 18.44
8.639290e+09     7.8            12.74              - 55.00

I do have to scale the features when doing linear regression, especially when they have such a different scale like Marketcap and the other features, right?在进行线性回归时,我确实必须缩放特征,尤其是当它们具有像 Marketcap 和其他特征这样不同的比例时,对吗?

Whats with the negative values of EPS Growth? EPS增长的负值是什么? Whats the best way to perform a feature scaling in this example?在此示例中执行特征缩放的最佳方法是什么?

From the docs :文档

Standardize features by removing the mean and scaling to unit variance通过去除均值和缩放到单位方差来标准化特征

This means, given an input x, transform it to (x-mean)/std (where all dimensions and operations are well defined).这意味着,给定输入 x,将其转换为 (x-mean)/std(其中所有维度和操作都已明确定义)。

So even if your input values are all positive, removing the mean can make some of them negative:因此,即使您的输入值都是正值,去除均值也会使其中一些为负值:

>>> x = np.array([3,5,7])
>>> np.mean(x)
5.0
>>> x - np.mean(x)
array([-2.,  0.,  2.])

More details:更多细节:

http://yann.lecun.com/exdb/publis/pdf/lecun-98b.pdf (sec. 4.3) http://scikit-learn.org/stable/modules/preprocessing.html#standardization-or-mean-removal-and-variance-scaling http://www.faqs.org/faqs/ai-faq/neural-nets/part2/section-16.html http://yann.lecun.com/exdb/publis/pdf/lecun-98b.pdf (第 4.3 节) http://scikit-learn.org/stable/modules/preprocessing.html#standardization-or-mean-去除和方差缩放http://www.faqs.org/faqs/ai-faq/neural-nets/part2/section-16.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM