• home
  • about
  • 全ての投稿
  • ソフトウェア・ハードウェアの設定のまとめ
  • 分析関連のまとめ
  • ヘルスケア関連のまとめ
  • 生涯学習関連のまとめ

standard scale(標準化, スタンダライゼーション)

date: 2022-09-16 excerpt: standard scale(標準化, スタンダライゼーション)の計算

tag: python標準化standard scale


standard scale(標準化, スタンダライゼーション)の計算

概要

  • データを同じような大きさの空間に組み込むとき
  • 区間は0 ~ 1に限定されない

定式

\[z = \frac{x - \mu}{s}\]
  • \(\mu\); 平均値
  • \(s\); 標準偏差

numpyでの利用法

x = (x - np.mean(x))/np.std(x)

sklearnでの使用法

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

print(scaler.transform(data))
"""
[[-1. -1.]
 [-1. -1.]
 [ 1.  1.]
 [ 1.  1.]]
"""

参考

  • sklearn.preprocessing.StandardScaler/sklearn
  • Numpy:zero mean data and standardization


python標準化standard scale Share Tweet