binary
(2値)
0
,
1
{\displaystyle {0,1}}
異なるidf関数(標準、スムージングあり、確率論的idf)グラフのプロット
Term frequency–inverse document frequency (tf-idf)
ここで、tf-idfは次のように計算される。
t
f
i
d
f
(
t
,
d
,
D
)
=
t
f
(
t
,
d
)
⋅
i
d
f
(
t
,
D
)
{\displaystyle \mathrm {tfidf} (t,d,D)=\mathrm {tf} (t,d)\cdot \mathrm {idf} (t,D)}
tf-idfの重みが高くなるのは、(与えられた文書内で)その単語の単語頻度(term frequency, tf)が高く、かつ、文書集合全体においてその単語の文書頻度(document frequency, df)が低い場合である。それゆえに、重みは普遍的な語をフィルタする傾向がある。idfの対数内の分数は常に1以上となるため、idf(とtf-idf)の値は常に0以上になる。単語がより多くの文書に現れる場合、対数の中の分数は1に近づき、それゆえにidfとtf-idfは0に近づく。
推奨されているtf–idf重み付け手法
重み付け手法
文書における利用
クエリにおける利用
1
f
t
,
d
⋅
log
N
n
t
{\displaystyle f_{t,d}\cdot \log {\frac {N}{n_{t}}}}
(
0.5
+
0.5
f
t
,
q
max
t
f
t
,
q
)
⋅
log
N
n
t
{\displaystyle \left(0.5+0.5{\frac {f_{t,q}}{\max _{t}f_{t,q}}}\right)\cdot \log {\frac {N}{n_{t}}}}
2
log
(
1
+
f
t
,
d
)
{\displaystyle \log(1+f_{t,d})}
log
(
1
+
N
n
t
)
{\displaystyle \log \left(1+{\frac {N}{n_{t}}}\right)}
3
(
1
+
log
f
t
,
d
)
⋅
log
N
n
t
{\displaystyle (1+\log f_{t,d})\cdot \log {\frac {N}{n_{t}}}}
(
1
+
log
f
t
,
q
)
⋅
log
N
n
t
{\displaystyle (1+\log f_{t,q})\cdot \log {\frac {N}{n_{t}}}}
idfの正当化
idfは1972年のKaren Spärck Jones(英語版 ) の論文によって「単語の特異性」として導入された。idfはヒューリスティクス でうまくいくとされてきたにもかかわらず、その論理的な基礎は少なくとも30年以上悩みの種となっており、多くの研究者が情報理論 的な正当化を試み続けている[7] 。
Spärck Jonesは自身の説明の中で、ジップの法則 を別にして、十分な理論を提供していない[7] 。与えられた文書d が語t を含む確率を、相対文書頻度として推定することによって、idfを確率論 的基盤に置こうとする試みが行われてきている[8] 。
P
(
t
|
D
)
=
|
{
d
∈
D
:
t
∈
d
}
|
N
,
{\displaystyle P(t|D)={\frac {|\{d\in D:t\in d\}|}{N}},}
idfを次のように定義すると、
i
d
f
=
−
log
P
(
t
|
D
)
=
log
1
P
(
t
|
D
)
=
log
N
|
{
d
∈
D
:
t
∈
d
}
|
{\displaystyle {\begin{aligned}\mathrm {idf} &=-\log P(t|D)\\&=\log {\frac {1}{P(t|D)}}\\&=\log {\frac {N}{|\{d\in D:t\in d\}|}}\end{aligned}}}
つまり、逆文書頻度は対数を取った「逆」相対文書頻度となる。
また、この確率論的解釈は自己情報量 と同じ形を取る。しかし、そのような情報理論的概念を情報検索の問題に応用すると、必要な確率分布 に適切な確率空間 を定義する際、文書だけでなく、クエリや単語を考慮する必要があるため、問題が生ずる[7] 。
情報理論との関係
term frequency (tf) とinverse document frequency (idf) の両者は情報理論 の観点から定式化されうる。この考えは、なぜそれらの積が文書の結合情報量 の観点から意味があるのかを理解するのに役立つ。分布
p
(
d
,
t
)
{\displaystyle p(d,t)}
に関する特徴的な仮定を以下の示す。
p
(
d
|
t
)
=
1
|
{
d
∈
D
:
t
∈
d
}
|
{\displaystyle p(d|t)={\frac {1}{|\{d\in D:t\in d\}|}}}
この仮定とその意味は、Aizawaによれば、「ヒューリスティックなtf-idfの使われ方を表している。」という[9] 。
特定の語
t
{\displaystyle t}
を含む事象を条件として、コーパス
D
{\displaystyle D}
の文書を「ランダムで選択」する条件付きエントロピー(英語版 ) は以下のように示される(全文書は等しい確率で選択されると仮定する)。
H
(
D
|
T
=
t
)
=
−
∑
d
p
d
|
t
log
p
d
|
t
=
−
log
1
|
{
d
∈
D
:
t
∈
d
}
|
=
log
|
{
d
∈
D
:
t
∈
d
}
|
|
D
|
+
log
|
D
|
=
−
i
d
f
(
t
)
+
log
|
D
|
{\displaystyle H({\cal {D}}|{\cal {T}}=t)=-\sum _{d}p_{d|t}\log p_{d|t}=-\log {\frac {1}{|\{d\in D:t\in d\}|}}=\log {\frac {|\{d\in D:t\in d\}|}{|D|}}+\log |D|=-\mathrm {idf} (t)+\log |D|}
表記に関して、
D
{\displaystyle {\cal {D}}}
と
T
{\displaystyle {\cal {T}}}
は「ランダムな変数」であり、文書や単語がそれぞれ選ばれることに相当する。ここで、相互情報量 は以下のように表される。
M
(
T
;
D
)
=
H
(
D
)
−
H
(
D
|
T
)
=
∑
t
p
t
⋅
(
H
(
D
)
−
H
(
D
|
W
=
t
)
)
=
∑
t
p
t
⋅
i
d
f
(
t
)
{\displaystyle M({\cal {T}};{\cal {D}})=H({\cal {D}})-H({\cal {D}}|{\cal {T}})=\sum _{t}p_{t}\cdot (H({\cal {D}})-H({\cal {D}}|W=t))=\sum _{t}p_{t}\cdot \mathrm {idf} (t)}
最後のステップは
p
t
{\displaystyle p_{t}}
を展開することであり、文書の(ランダムな)選択に関して、条件と無関係に単語を選択する確率であるから、
M
(
T
;
D
)
=
∑
t
,
d
p
t
|
d
⋅
p
d
⋅
i
d
f
(
t
)
=
∑
t
,
d
t
f
(
t
,
d
)
⋅
1
|
D
|
⋅
i
d
f
(
t
)
=
1
|
D
|
∑
t
,
d
t
f
(
t
,
d
)
⋅
i
d
f
(
t
)
.
{\displaystyle M({\cal {T}};{\cal {D}})=\sum _{t,d}p_{t|d}\cdot p_{d}\cdot \mathrm {idf} (t)=\sum _{t,d}\mathrm {tf} (t,d)\cdot {\frac {1}{|D|}}\cdot \mathrm {idf} (t)={\frac {1}{|D|}}\sum _{t,d}\mathrm {tf} (t,d)\cdot \mathrm {idf} (t).}
この式は、すべての有効な単語と文書のtf-idfの和は、文書と単語の同時確率分布 の特異性のすべてを考慮した、文書と単語の間の相互情報量に立ち戻ることを表している[9] 。それゆえに、それぞれのtf-idfは、ある単語と文書のペアに付け足された、「情報のかけら(bit of information)」を意味している。
tf–idfの例
2つの文書からのみ構成されるコーパスの単語カウント表(右に示す)を扱うと仮定する。
文書2
語
語のカウント
this
1
is
1
another
2
example
3
文書1
語
語のカウント
this
1
is
1
a
2
sample
1
語"this"のtf-idfは以下のように計算される。
出現頻度をそのままtfとして用いる場合、tfはそれぞれの文書の"this"の頻度と同じになる。標準的な文書長を調整するtfでは、各文書において単語"this"は1度現れるが、文書2はより多くの単語を含むため、相対頻度は小さくなる。
t
f
(
″
t
h
i
s
″
,
d
1
)
=
1
5
=
0.2
{\displaystyle \mathrm {tf} ({\mathsf {''this''}},d_{1})={\frac {1}{5}}=0.2}
t
f
(
″
t
h
i
s
″
,
d
2
)
=
1
7
≈
0.14
{\displaystyle \mathrm {tf} ({\mathsf {''this''}},d_{2})={\frac {1}{7}}\approx 0.14}
idfはコーパス毎の定数であり、"this"という単語を含む文書の比率から成り立って いる。この事例では、2つの文書からなるコーパスを扱い、それらはすべて"this"という語を含んでいる。
i
d
f
(
″
t
h
i
s
″
,
D
)
=
log
(
2
2
)
=
0
{\displaystyle \mathrm {idf} ({\mathsf {''this''}},D)=\log \left({\frac {2}{2}}\right)=0}
つまり、"this"という語のtf-idfはゼロである。これはこの単語がすべての文書に現れることから、その単語が有益でないでないこと示唆している。
t
f
i
d
f
(
″
t
h
i
s
″
,
d
1
,
D
)
=
0.2
×
0
=
0
{\displaystyle \mathrm {tfidf} ({\mathsf {''this''}},d_{1},D)=0.2\times 0=0}
t
f
i
d
f
(
″
t
h
i
s
″
,
d
2
,
D
)
=
0.14
×
0
=
0
{\displaystyle \mathrm {tfidf} ({\mathsf {''this''}},d_{2},D)=0.14\times 0=0}
"example"という語はより興味深く――3度現れるが、文書2にしか現れない。
t
f
(
″
e
x
a
m
p
l
e
″
,
d
1
)
=
0
5
=
0
{\displaystyle \mathrm {tf} ({\mathsf {''example''}},d_{1})={\frac {0}{5}}=0}
t
f
(
″
e
x
a
m
p
l
e
″
,
d
2
)
=
3
7
≈
0.429
{\displaystyle \mathrm {tf} ({\mathsf {''example''}},d_{2})={\frac {3}{7}}\approx 0.429}
i
d
f
(
″
e
x
a
m
p
l
e
″
,
D
)
=
log
(
2
1
)
=
0.301
{\displaystyle \mathrm {idf} ({\mathsf {''example''}},D)=\log \left({\frac {2}{1}}\right)=0.301}
最終的には,
t
f
i
d
f
(
″
e
x
a
m
p
l
e
″
,
d
1
,
D
)
=
t
f
(
″
e
x
a
m
p
l
e
″
,
d
1
)
×
i
d
f
(
″
e
x
a
m
p
l
e
″
,
D
)
=
0
×
0.301
=
0
{\displaystyle \mathrm {tfidf} ({\mathsf {''example''}},d_{1},D)=\mathrm {tf} ({\mathsf {''example''}},d_{1})\times \mathrm {idf} ({\mathsf {''example''}},D)=0\times 0.301=0}
t
f
i
d
f
(
″
e
x
a
m
p
l
e
″
,
d
2
,
D
)
=
t
f
(
″
e
x
a
m
p
l
e
″
,
d
2
)
×
i
d
f
(
″
e
x
a
m
p
l
e
″
,
D
)
=
0.429
×
0.301
≈
0.129
{\displaystyle \mathrm {tfidf} ({\mathsf {''example''}},d_{2},D)=\mathrm {tf} ({\mathsf {''example''}},d_{2})\times \mathrm {idf} ({\mathsf {''example''}},D)=0.429\times 0.301\approx 0.129}
(対数は常用対数 を用いている。)
単語以外への応用
tf-idfの背後にある考えは、単語以外の存在にも応用される。1998年 にはidfのコンセプトが引用分析 に応用された[10] 。筆者は「もし非常に珍しい引用が2つの文書によって共有されたならば、その引用された文書はたくさんの文書によって引用されている文書よりもより高く重み付けされるべきである。」と主張した。加えて、動画や内における物体マッチング を行うための「visual words(英語版 ) 」や[11] 全文検索にも[12] tf-idfは応用されている。しかし、tf-idfのコンセプトは、すべての手法において、単純な(idf成分を除いた)tfのみの手法よりも効果的であるという証明はされていない。tf-idfを引用分析に応用する際には、研究者はidf重みをもたない単純な引用回数重みを超える精度向上を確認することができなかった[13] 。
tf-idfの派生
多数の単語重み付け手法はtf-idfからの派生である。そのうちの一つはTF-PDF (term frequency * proportional document frequency) である[14] 。TF-PDFは2001年 にメディアにおける新たなトピックを特定するという文脈で導入された。PDF成分は異なるドメインの中でどのくらいの頻度である単語が出現したかの差を測定する。他の派生にはTF-IDuFがある。TF-IDuFでは[15] 、idfは文書コーパスに基づき計算されず、検索または推薦される。例えば、idfはユーザの個人的な文書コレクションに基づいて計算される。その著者らはTF-IDuFはtf-idfと等しく効果的であるが、例えば、ユーザーモデリング(英語版 ) システムにおいて、外部の文書コーパスにアクセスできない時などに、応用可能であると報告している。
関連項目
参考文献
^ Rajaraman, A.; Ullman, J.D. (2011). “Data Mining” . Mining of Massive Datasets . pp. 1–17. doi :10.1017/CBO9781139058452.002 . ISBN 978-1-139-05845-2 . http://i.stanford.edu/~ullman/mmds/ch1.pdf
^ Breitinger, Corinna; Gipp, Bela; Langer, Stefan (2015-07-26). “Research-paper recommender systems: a literature survey” (英語). International Journal on Digital Libraries 17 (4): 305–338. doi :10.1007/s00799-015-0156-0 . ISSN 1432-5012 . http://nbn-resolving.de/urn:nbn:de:bsz:352-0-311312 .
^ Luhn, Hans Peter (1957). “A Statistical Approach to Mechanized Encoding and Searching of Literary Information” . IBM Journal of Research and Development 1 (4): 309–317. doi :10.1147/rd.14.0309 . https://web.stanford.edu/class/linguist289/luhn57.pdf 2015年3月2日 閲覧 . "There is also the probability that the more frequently a notion and combination of notions occur, the more importance the author attaches to them as reflecting the essence of his overall idea."
^ Spärck Jones, K. (1972). “A Statistical Interpretation of Term Specificity and Its Application in Retrieval”. Journal of Documentation 28 : 11–21. doi :10.1108/eb026526 .
^ Manning, C.D.; Raghavan, P.; Schutze, H. (2008). “Scoring, term weighting, and the vector space model” . Introduction to Information Retrieval . pp. 100. doi :10.1017/CBO9780511809071.007 . ISBN 978-0-511-80907-1 . http://nlp.stanford.edu/IR-book/pdf/06vect.pdf
^ “TFIDF statistics | SAX-VSM ”. 2022年3月29日 閲覧。
^ a b c Robertson, S. (2004). “Understanding inverse document frequency: On theoretical arguments for IDF”. Journal of Documentation 60 (5): 503–520. doi :10.1108/00220410410560582 .
^ See also Probability estimates in practice in Introduction to Information Retrieval .
^ a b Aizawa, Akiko (2003). “An information-theoretic perspective of tf–idf measures” (英語). Information Processing and Management 39 (1): 45–65. doi :10.1016/S0306-4573(02)00021-3 .
^ Bollacker, Kurt D.; Lawrence, Steve; Giles, C. Lee (1998-01-01). CiteSeer: An Autonomous Web Agent for Automatic Retrieval and Identification of Interesting Publications . AGENTS '98. 116–123. doi :10.1145/280765.280786 . ISBN 978-0-89791-983-8 . https://www.semanticscholar.org/paper/b23a5a62b7cb5278ceb5a6cc021c28a92041d792
^ Sivic, Josef; Zisserman, Andrew (2003-01-01). Video Google: A Text Retrieval Approach to Object Matching in Videos . ICCV '03. 1470–. doi :10.1109/ICCV.2003.1238663 . ISBN 978-0-7695-1950-0 . http://dl.acm.org/citation.cfm?id=946247.946751
^ Seki, Yohei. “Sentence Extraction by tf/idf and Position Weighting from Newspaper Articles ”. National Institute of Informatics. 2022年3月29日 閲覧。
^ Beel, Joeran; Breitinger, Corinna (2017). “Evaluating the CC-IDF citation-weighting scheme – How effectively can 'Inverse Document Frequency' (IDF) be applied to references?” . Proceedings of the 12th IConference . http://beel.org/publications/2017%20iConference%20--%20Evaluating%20the%20CC-IDF%20citation-weighting%20scheme%20--%20preprint.pdf .
^ Khoo Khyou Bun; Bun, Khoo Khyou; Ishizuka, M. (2001) (英語). Emerging Topic Tracking System . 2. doi :10.1109/wecwis.2001.933900 . ISBN 978-0-7695-1224-2
^ Langer, Stefan; Gipp, Bela (2017). “TF-IDuF: A Novel Term-Weighting Scheme for User Modeling based on Users' Personal Document Collections” . IConference . https://www.gipp.com/wp-content/papercite-data/pdf/beel17.pdf .
Salton, G; McGill, M. J. (1986). Introduction to modern information retrieval . McGraw-Hill . ISBN 978-0-07-054484-0 . https://archive.org/details/introductiontomo00salt
Salton, G.; Fox, E. A.; Wu, H. (1983). “Extended Boolean information retrieval”. Communications of the ACM 26 (11): 1022–1036. doi :10.1145/182.358466 . hdl :1813/6351 .
Salton, G.; Buckley, C. (1988). “Term-weighting approaches in automatic text retrieval” . Information Processing & Management 24 (5): 513–523. doi :10.1016/0306-4573(88)90021-0 . hdl :1813/6721 . https://ecommons.cornell.edu/bitstream/1813/6721/1/87-881.pdf .
Wu, H. C.; Luk, R.W.P.; Wong, K.F.; Kwok, K.L. (2008). “Interpreting TF-IDF term weights as making relevance decisions” . ACM Transactions on Information Systems 26 (3): 1. doi :10.1145/1361684.1361686 . hdl :10397/10130 . https://www.semanticscholar.org/paper/f6bbbf2cc785cf96019dcd9c41ab1801aad962dd .
外部リンクと推薦図書
tf-idfのページの著作権
Weblio 辞書
情報提供元は
参加元一覧
にて確認できます。
Copyright © 2005-2025 Weblio 辞書 IT用語辞典バイナリさくいん 。 この記事は、IT用語辞典バイナリの【tf-idf】の記事を利用しております。
All text is available under the terms of the GNU Free Documentation License . この記事は、ウィキペディアのtf-idf (改訂履歴) の記事を複製、再配布したものにあたり、GNU Free Documentation Licenseというライセンスの下で提供されています。
Weblio辞書 に掲載されているウィキペディアの記事も、全てGNU Free Documentation Licenseの元に提供されております。