A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | ||||||||||||||||||||||||||
2 | Tf-Idf Definition and Example | |||||||||||||||||||||||||
3 | ||||||||||||||||||||||||||
4 | Term Frequency (TF): TF(t) = (Number of times term t appears in a document) / (Total number of terms in the document) | |||||||||||||||||||||||||
5 | Inverse Document Frequency (IDF): IDF(t) = log_e(Total number of documents / Number of documents with term t in it) | |||||||||||||||||||||||||
6 | It helps to find out relevant documents for the query | |||||||||||||||||||||||||
7 | Example: There are 3 different documents in the collection (dataset) | |||||||||||||||||||||||||
8 | Q1. | Find TF and IDF | ||||||||||||||||||||||||
9 | Q2. | For the query Q = "Big Data", find the two top ranked documents according to the TF/IDF rank | ||||||||||||||||||||||||
10 | ||||||||||||||||||||||||||
11 | Solution Q1: TF and IDF | IT | study | Big | Data | prediction | helps | in | business | Total Terms in a doc | ||||||||||||||||
12 | d1: | IT study Big Data | TF for d1 | 1 | 1 | 1 | 1 | 4 | ||||||||||||||||||
13 | d2: | Big Data helps in big prediction | TF for d2 | 2 | 1 | 1 | 1 | 1 | 6 | |||||||||||||||||
14 | d3: | Big prediction helps in business | TF for d3 | 1 | 1 | 1 | 1 | 1 | 5 | |||||||||||||||||
15 | # of docs with term = | 1 | 1 | 3 | 2 | 2 | 2 | 2 | 1 | 14 | ||||||||||||||||
16 | ||||||||||||||||||||||||||
17 | Inverse Document Frequency (IDF) | IDF = | log(# docs / # docs with that term) | |||||||||||||||||||||||
18 | IDF = | 0.477 | 0.477 | 0.000 | 0.176 | 0.176 | 0.176 | 0.176 | 0.477 | |||||||||||||||||
19 | ||||||||||||||||||||||||||
20 | ||||||||||||||||||||||||||
21 | ||||||||||||||||||||||||||
22 | ||||||||||||||||||||||||||
23 | ||||||||||||||||||||||||||
24 | ||||||||||||||||||||||||||
25 | ||||||||||||||||||||||||||
26 | ||||||||||||||||||||||||||
27 | ||||||||||||||||||||||||||
28 | ||||||||||||||||||||||||||
29 | ||||||||||||||||||||||||||
30 | ||||||||||||||||||||||||||
31 | ||||||||||||||||||||||||||
32 | ||||||||||||||||||||||||||
33 | ||||||||||||||||||||||||||
34 | ||||||||||||||||||||||||||
35 | ||||||||||||||||||||||||||
36 | ||||||||||||||||||||||||||
37 | ||||||||||||||||||||||||||
38 | ||||||||||||||||||||||||||
39 | ||||||||||||||||||||||||||
40 | ||||||||||||||||||||||||||
41 | ||||||||||||||||||||||||||
42 | ||||||||||||||||||||||||||
43 | ||||||||||||||||||||||||||
44 | ||||||||||||||||||||||||||
45 | ||||||||||||||||||||||||||
46 | ||||||||||||||||||||||||||
47 | ||||||||||||||||||||||||||
48 | ||||||||||||||||||||||||||
49 | ||||||||||||||||||||||||||
50 | ||||||||||||||||||||||||||
51 | ||||||||||||||||||||||||||
52 | ||||||||||||||||||||||||||
53 | ||||||||||||||||||||||||||
54 | ||||||||||||||||||||||||||
55 | ||||||||||||||||||||||||||
56 | ||||||||||||||||||||||||||
57 | ||||||||||||||||||||||||||
58 | ||||||||||||||||||||||||||
59 | ||||||||||||||||||||||||||
60 | ||||||||||||||||||||||||||
61 | ||||||||||||||||||||||||||
62 | ||||||||||||||||||||||||||
63 | ||||||||||||||||||||||||||
64 | ||||||||||||||||||||||||||
65 | ||||||||||||||||||||||||||
66 | ||||||||||||||||||||||||||
67 | ||||||||||||||||||||||||||
68 | ||||||||||||||||||||||||||
69 | ||||||||||||||||||||||||||
70 | ||||||||||||||||||||||||||
71 | ||||||||||||||||||||||||||
72 | ||||||||||||||||||||||||||
73 | ||||||||||||||||||||||||||
74 | ||||||||||||||||||||||||||
75 | ||||||||||||||||||||||||||
76 | ||||||||||||||||||||||||||
77 | ||||||||||||||||||||||||||
78 | ||||||||||||||||||||||||||
79 | ||||||||||||||||||||||||||
80 | ||||||||||||||||||||||||||
81 | ||||||||||||||||||||||||||
82 | ||||||||||||||||||||||||||
83 | ||||||||||||||||||||||||||
84 | ||||||||||||||||||||||||||
85 | ||||||||||||||||||||||||||
86 | ||||||||||||||||||||||||||
87 | ||||||||||||||||||||||||||
88 | ||||||||||||||||||||||||||
89 | ||||||||||||||||||||||||||
90 | ||||||||||||||||||||||||||
91 | ||||||||||||||||||||||||||
92 | ||||||||||||||||||||||||||
93 | ||||||||||||||||||||||||||
94 | ||||||||||||||||||||||||||
95 | ||||||||||||||||||||||||||
96 | ||||||||||||||||||||||||||
97 | ||||||||||||||||||||||||||
98 | ||||||||||||||||||||||||||
99 | ||||||||||||||||||||||||||
100 |