sklearn.preprocessing()详解: 标准化、正则化、最小最大规范化、特征二值化

一. 数据的标准化与归一化(zero-mean normalization): class sklearn.preprocessing.StandardScaler(*, copy=True, with_mean=True, with_std=True)

官方文档-StandardScaler

  • standard score(z) of a sample x: z = (x - u) / s
    u: the mean of training samples (u = 0 if with_mean = False)
    s: the standard deviation of the training samples (s = 1 if with_std = False)
    在这里插入图片描述

  • Parameters and Attributes:
    在这里插入图片描述
    例子:

from sklearn.preprocessing import StandardScaler
data = [[0, 0], [0, 0], [1, 1], [1, 1]]
scaler = StandardScaler()
print(scaler.fit(data))

output: StandardScaler()

print(scaler.mean_)
print(scaler.var_)

output:
array([0.5, 0.5])
array([0.25, 0.25])

其中scaler.fit(data),即StandardScaler.fit(data)计算出数据的平均值和标准差,并存储在StandardScaler()中便于之后的使用;
调用attributes中的mean_和var_求数据的平均值和方差.
除了fit()之外,StandardScaler()还有许多不同的methods:

  • Popular Methods:
  1. fit(): compute the mean and std to be used for
  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值