0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

データ前処理の基本:Min-Maxスケーリングを理解しよう

0
Posted at

Min-Max正規化(Min-Max Normalization)は、データを一定の範囲、通常は [0, 1] にスケーリングする手法です。機械学習や統計分析において、異なるスケールを持つ特徴量を揃えることで、モデルの学習精度や収束速度を向上させるために使われます。


Min-Max正規化の計算式

基本的な式は以下の通りです:

image.png

  • x:正規化したい元の値
  • x_min:対象データの最小値
  • x_max:対象データの最大値
  • x':正規化された値(通常 [0,1] の範囲)

任意の範囲 [a, b] にスケーリングしたい場合:

image.png


特徴

メリット

  • 実装が非常にシンプル
  • 元のデータの分布を保持しつつスケーリングできる
  • 特にニューラルネットワークのような距離に敏感なアルゴリズムと相性が良い

デメリット

  • 外れ値(アウトライヤー)に非常に弱い
  • x_maxx_min に依存するため、テストデータにこれらの範囲外の値があると正しくスケーリングできない

実装例(Python)

from sklearn.preprocessing import MinMaxScaler
import numpy as np

# サンプルデータ
data = np.array([[10], [20], [30], [40], [50]])

# Min-Max正規化
scaler = MinMaxScaler()
scaled_data = scaler.fit_transform(data)

print(scaled_data)
  • x_min = 10
  • x_max = 50
  • 差:x_max - x_min = 40
元の値 計算式 正規化後の値
10 (10 - 10) / 40 0.0
20 (20 - 10) / 40 0.25
30 (30 - 10) / 40 0.5
40 (40 - 10) / 40 0.75
50 (50 - 10) / 40 1.0

どんなときに使う?

  • 特徴量のスケールがバラバラな場合
  • k近傍法(KNN)やサポートベクターマシン(SVM)など、距離に基づくアルゴリズムを使うとき
  • ニューラルネットワークでの学習前の前処理

補足:他の正規化との違い

手法 スケーリング範囲 外れ値への強さ 使用シーン
Min-Max正規化 通常 [0, 1] 弱い データが一定の範囲に収まっているとき
Zスコア正規化(標準化) 平均0・分散1 強い 外れ値が存在する場合
ロバストスケーリング 四分位数に基づく とても強い 外れ値が多いとき
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?