Scikit-learn:preprocessing.scale() 与 preprocessing.StandardScalar() [英] Scikit-learn: preprocessing.scale() vs preprocessing.StandardScalar()

查看:166
本文介绍了Scikit-learn:preprocessing.scale() 与 preprocessing.StandardScalar()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解缩放意味着将均值(均值 = 0)居中并制作单位方差(方差 = 1).

I understand that scaling means centering the mean(mean=0) and making unit variance(variance=1).

但是,scikit-learn 中的 preprocessing.scale(x)preprocessing.StandardScalar() 有什么区别?

But, What is the difference between preprocessing.scale(x)and preprocessing.StandardScalar() in scikit-learn?

推荐答案

那些做的完全一样,但是:

Those are doing exactly the same, but:

  • preprocessing.scale(x) 只是一个函数,它转换一些数据
  • preprocessing.StandardScaler() 是一个支持 Transformer API
  • 的类
  • preprocessing.scale(x) is just a function, which transforms some data
  • preprocessing.StandardScaler() is a class supporting the Transformer API

我总是使用后者,即使我不需要 inverse_transform 和 co.StandardScaler() 支持.

I would always use the latter, even if i would not need inverse_transform and co. supported by StandardScaler().

摘自 文档:

函数 scale 提供了一种快速简便的方法来对单个类似数组的数据集执行此操作

The function scale provides a quick and easy way to perform this operation on a single array-like dataset

预处理模块进一步提供了一个实用程序类 StandardScaler,它实现了 Transformer API 来计算训练集的均值和标准差,以便以后能够在测试集上重新应用相同的变换.因此,此类适用于 sklearn.pipeline.Pipeline

The preprocessing module further provides a utility class StandardScaler that implements the Transformer API to compute the mean and standard deviation on a training set so as to be able to later reapply the same transformation on the testing set. This class is hence suitable for use in the early steps of a sklearn.pipeline.Pipeline

这篇关于Scikit-learn:preprocessing.scale() 与 preprocessing.StandardScalar()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆