Más contenido relacionado La actualidad más candente (20) Similar a 今日からできる構造学習(主に構造化パーセプトロンについて) (20) 今日からできる構造学習(主に構造化パーセプトロンについて)8. 教師あり学習
• 二値分類
– スパム分類
• 多値分類
– はてなブックマークのカテゴリ分類
• 構造予測
– 形態素解析(mecabとか) [Kudo2004]
– 単語の係り受け解析(cabochaとか)
[Kudo2002,McDonald2005]
– Webページのランキング(Learning to rank) [He2008]
– 二部グラフマッチング
• 機械翻訳[Taskar2005]
• (合コンのマッチング問題…?)
二値分類、多値分類:
出力がスカラー
構造学習:
出力がスカラーではなく
構造を持つオブジェクト
16. 分かりやすく言うと…?(文書分類の例)
入力: Webページ x ワールドカップの速報Webページ
特徴ベクトルは
(1)エンタメ && 本文にサッカーが含まれているか
(2)経済 && 本文にサッカーが含まれているか
(3)エンタメ && タグにサッカーが含まれているか
(4)経済 && タグにサッカーが含まれているか
を表現している(こういうのが数万次元くらいあるイメージ)。
出力ラベル集合: Y = {エンタメ, 経済}
重みベクトル:
特徴ベクトル:
特徴ベクトル:
w= [3, 1, 3, 2]T
fx,エンタメ = [1, 0, 1, 0]T
fx,経済 = [0, 0, 0, 1]T
17. 分かりやすく言うと…?(文書分類の例)
スコア: s(x, エンタメ; w) = wTfx,エンタメ = 6
スコア: s(x, 経済; w) = wTfx,経済 = 2
スコアが最大の
「エンタメ」が入力xの
カテゴリと判定される!
入力: Webページ x ワールドカップの速報Webページ
出力ラベル集合: Y = {エンタメ, 経済}
重みベクトル:
特徴ベクトル:
特徴ベクトル:
w= [3, 1, 3, 2]T
fx,エンタメ = [1, 0, 1, 0]T
fx,経済 = [0, 0, 0, 1]T
20. 目次
• 機械学習の問題の種類
• 構造学習とは何か
• 線形識別器について
• パーセプトロンについて
– 平均化
• コードを見ながら具体例
• 発展的話題
重みベクトルwがあれば
構造学習できることは分かった。
だけど、重みベクトルwってどう
やって決めればいいんだろう?
27. 学習部分(1)
my $weight = {};!
my $cum_weight = {};!
my $n = 1;!
for my $iter ( 0 .. 10 ) {!
print "Iter: $itern";!
for my $gold ( List::Util::shuffle @$train_data) {!
my $predict = argmax($gold, $weight, $pos_labels);!
if (pos_labels_str($gold) ne pos_labels_str($predict)) {!
update_weight( $weight, $cum_weight, $gold, $predict,
$n, $pos_labels );!
$n++;!
}!
}!
}!
データの偏りがあると学習が
うまく進まないのでシャッフルする
28. 学習部分(2)
sub update_weight {!
my ( $weight, $cum_weight, $sentence, $predict_sentence, $n,
$pos_labels ) = @_;!
my $gold_features = get_features($sentence);!
my $predict_features = get_features($predict_sentence);!
!
for my $feature (@$gold_features) {!
$weight->{$feature} += 1;!
$cum_weight->{$feature} += $n;!
}!
for my $feature (@$predict_features) {!
$weight->{$feature} -= 1;!
$cum_weight->{$feature} -= $n;!
}!
}!
正解の特徴量fx,y($gold_features)と
予測の特徴量fx,y*($predict_features)を
それぞれ取ってくる
正解の特徴量は足す、
予測の特徴量は引く!
37. 参考資料(1)
• 日本語入力を支える技術 by tkngさん
– h8ps://www.amazon.co.jp/dp/4774149934
• GramさんのNLPチュートリアル
– h8p://www.phontron.com/teaching.php
• [Huang2012]Liang Huang, Suphan Fayong, and Yang Guo. 2012. Structured perceptron with
inexact search. In Proceedings of the 2012 Conference of the North American Chapter of the
Associa8on for Computa8onal Linguis8cs: Human Language Technologies (NAACL HLT '12).
Associa;on for Computa;onal Linguis;cs, Stroudsburg, PA, USA, 142-151.
• [Zhao2013]K. Zhao and L. Huang. Minibatch and paralleliza;on for online large margin
structured learn- ing. In NAACL, pages 370–379, 2013.
• [Collins 2002]Michael Collins. 2002. Discrimina;ve training methods for hidden Markov
models: theory and experiments with perceptron algorithms. In Proceedings of the ACL-02
conference on Empirical methods in natural language processing - Volume 10 (EMNLP '02),
Vol. 10. Associa;on for Computa;onal Linguis;cs, Stroudsburg, PA, USA, 1-8.
• [Taskar2005]Ben Taskar, Simon Lacoste-Julien, and Dan Klein. 2005. A discrimina;ve
matching approach to word alignment. In Proceedings of the conference on Human Language
Technology and Empirical Methods in Natural Language Processing (HLT '05). Associa;on for
Computa;onal Linguis;cs, Stroudsburg, PA, USA, 73-80.
38. 参考資料(2)
• [He2008]C. He, C. Wang, YX. Zhong and RF. Li. A Survey on Learning to Rank. Proceedings of
the Seventh Interna;onal Conference on Machine Learning and Cyberne;cs, Kunming, 12-15
July 2008.
• [McDonald2005]Ryan McDonald, Koby Crammer, and Fernando Pereira. 2005. Online large-
margin training of dependency parsers. In Proceedings of the 43rd Annual Mee8ng on
Associa8on for Computa8onal Linguis8cs (ACL '05). Associa;on for Computa;onal Linguis;cs,
Stroudsburg, PA, USA, 91-98.
• [Kudo2004]Taku Kudo, Kaoru Yamamoto, and Yuji Matsumoto. 2004. Applying condi;onal
random fields to Japanese morphological analysis. In Proceedings of the Conference on
Emprical Methods in Natural Language Processing (EMNLP 2004), volume 2004.
• [Kudo2002]Taku Kudo and Yuji Matsumoto. 2002. Japanese dependency analysis using
cascaded chunking. In proceedings of the 6th conference on Natural language learning -
Volume 20 (COLING-02), Vol. 20. Associa;on for Computa;onal Linguis;cs, Stroudsburg, PA,
USA, 1-7.
• [Liang2008]Percy Liang, Hal Daumé, III, and Dan Klein. 2008. Structure compila;on: trading
structure for features. In Proceedings of the 25th interna;onal conference on Machine
learning (ICML '08). ACM, New York, NY, USA, 592-599.
39. 参考資料(3)
• [Crammer2006]Koby Crammer, Ofer Dekel, Joseph Keshet, Shai Shalev-Shwartz, and Yoram
Singer. 2006. Online Passive-Aggressive Algorithms. J. Mach. Learn. Res. 7 (December 2006),
551-585.
• [Dredze2008]Mark Dredze, Koby Crammer, and Fernando Pereira. 2008. Confidence-
weighted linear classifica;on. In Proceedings of the 25th interna;onal conference on
Machine learning (ICML '08). ACM, New York, NY, USA, 264-271.
• [Duchi2009]John Duchi and Yoram Singer. 2009. Efficient Online and Batch Learning Using
Forward Backward Spli‚ng. J. Mach. Learn. Res. 10 (December 2009), 2899-2934.