2017年11月8日水曜日

Imbalanced Data

偏りの極端なデータセットを扱わざるを得ないという状況は頻繁にあるようで、対応策も研究されているようです。

H2Oの場合、FAQ に掲載されていました。
http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/deep-learning.html
・How does class balancing work?
The max_after_balance_size parameter defines the maximum size of the over-sampled dataset. For example, if max_after_balance_size = 3, the over-sampled dataset will not be greater than three times the size of the original dataset.
For example, if you have five classes with priors of 90%, 2.5%, 2.5%, and 2.5% (out of a total of one million rows) and you oversample to obtain a class balance using balance_classes = T, the result is all four minor classes are oversampled by forty times and the total dataset will be 4.5 times as large as the original dataset (900,000 rows of each class). If max_after_balance_size = 3, all five balance classes are reduced by 3/5 resulting in 600,000 rows each (three million total).
To specify the per-class over- or under-sampling factors, use class_sampling_factors. In the previous example, the default behavior with balance_classes is equivalent to c(1,40,40,40,40), while when max_after_balance\size = 3, the results would be c(3/5,40*3/5,40*3/5,40*3/5).

H2O の FLOW では、そのオプションを見つけらませんでした。R か Python に移行しないといけない?と思いつつ、CSV の段階でマイナーデータの数を増やしてみました。単純に、コピペで崩壊したデータを非崩壊と同じ数まで増やすだけ。学習・検証させた結果は以下の通り。


うーん、ダメですね。過学習というべきなのでしょうか?
一見、高精度の判別器に見えますが、繰り返し入力された異常パターンを覚えすぎ、汎用性を喪失している可能性大。こうなると、既知の異常パターンにしか対応できなくなります。異常検出型でなく、正常から外れた場合に異常と判断する判別器に育てる方針の方が有利でしょう。

まさに、そのような方法も検討されているようです。
https://www.gputechconf.jp/assets/files/1029.pdf
AutoEncoder:固定長、または正規化可能な可変長データで、正常が圧倒的に多く、異常が少ない場合。正常なパター ンのみを学習し、正常なパターンを再現可能な特徴量を抽出する。異常なパターンが入力された場合、異常パターンの特徴量 は学習していないため、異常パターンを再現することができない。再現されたデータの類似度で異常判定を行う。
deep なのか shallow なのか分かりません。が、H2O でも deep learning のオプションに「Auto-Encoder」がありました。R や Python のコードも googling に出てきます。
が、使い方がわかりません。いえ、使っても、良い答えになりません。使い方を見極めていないため、宝の持ち腐れ、猫に小判状態です。うーん、どこにヒントがあるのでしょう?

0 件のコメント:

コメントを投稿