-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadMe.html
More file actions
320 lines (255 loc) · 7.29 KB
/
ReadMe.html
File metadata and controls
320 lines (255 loc) · 7.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Visualization, Data Analysis, and Interaction Discussion</title>
<style type="text/css">
body, td {
font-family: sans-serif;
background-color: white;
font-size: 12px;
margin: 8px;
}
tt, code, pre {
font-family: 'DejaVu Sans Mono', 'Droid Sans Mono', 'Lucida Console', Consolas, Monaco, monospace;
}
h1 {
font-size:2.2em;
}
h2 {
font-size:1.8em;
}
h3 {
font-size:1.4em;
}
h4 {
font-size:1.0em;
}
h5 {
font-size:0.9em;
}
h6 {
font-size:0.8em;
}
a:visited {
color: rgb(50%, 0%, 50%);
}
pre {
margin-top: 0;
max-width: 95%;
border: 1px solid #ccc;
white-space: pre-wrap;
}
pre code {
display: block; padding: 0.5em;
}
code.r, code.cpp {
background-color: #F8F8F8;
}
table, td, th {
border: none;
}
blockquote {
color:#666666;
margin:0;
padding-left: 1em;
border-left: 0.5em #EEE solid;
}
hr {
height: 0px;
border-bottom: none;
border-top-width: thin;
border-top-style: dotted;
border-top-color: #999999;
}
@media print {
* {
background: transparent !important;
color: black !important;
filter:none !important;
-ms-filter: none !important;
}
body {
font-size:12pt;
max-width:100%;
}
a, a:visited {
text-decoration: underline;
}
hr {
visibility: hidden;
page-break-before: always;
}
pre, blockquote {
padding-right: 1em;
page-break-inside: avoid;
}
tr, img {
page-break-inside: avoid;
}
img {
max-width: 100% !important;
}
@page :left {
margin: 15mm 20mm 15mm 10mm;
}
@page :right {
margin: 15mm 10mm 15mm 20mm;
}
p, h2, h3 {
orphans: 3; widows: 3;
}
h2, h3 {
page-break-after: avoid;
}
}
</style>
<!-- MathJax scripts -->
<script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/2.0-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body>
<h1>Visualization, Data Analysis, and Interaction Discussion</h1>
<h1>Clustering Methods</h1>
<ul>
<li>Lantent Semantic Analysis</li>
<li>Positive Pointwise Mutual Information</li>
<li>WordNet/MeSH</li>
</ul>
<h2>Custom</h2>
<ul>
<li>Get AverageArcLength</li>
<li>BeginRepeat</li>
<li>Take Smallest Arc</li>
<li>Place Point in middle of arc called NewCenter</li>
<li>Calculate Distance of all Points to the NewCenter and remove if Distance < (Threshold * AverageArcLength) </li>
<li>If Arcs Removed > Threshold2 GoTo BeginRepeat</li>
<li>Preform K-Means Clustering</li>
</ul>
<h2>Speedups</h2>
<h3>Best Bet</h3>
<ul>
<li><a href="http://www.indiana.edu/%7Eclcl/Papers/BSC901.pdf">http://www.indiana.edu/~clcl/Papers/BSC901.pdf</a></li>
</ul>
<h3>Ways to minimize the vocabulary.</h3>
<ul>
<li>Replace words that are highly specialized with a category, eg H2O->Chemical.</li>
<li>Remove words that are below some threshold in commonality. (Word * occurs in 1 out of 50,000 articles)</li>
<li>Remove words that are above some threshold. (Stop Words)</li>
<li>Use only pre-selected keywords eg. MeSH, or ones the client selects.</li>
</ul>
<h3>Encode in a Sparse Matrix.</h3>
<p>W is all words in all documents
V is set of all works in all documents
D is set of all documents</p>
<ul>
<li>For each Document, create a list of words and their count.
<ul>
<li>Dictionary<int,List<KeyValuePair<string,int>> Documents;</li>
</ul></li>
<li>For each Word, create a list of Documents and their count.
<ul>
<li>Dictionary<string,Dictionary<int,int>> Words</li>
</ul></li>
<li>Space for each Word would be
<ul>
<li>P(W|D) * N(D)</li>
</ul></li>
<li>Space for each Document would be
<ul>
<li>P(W|D) * N(W|D)</li>
</ul></li>
</ul>
<h4>Sparse vs Normal Matrix:</h4>
<p>Number of unique words in document * number of documents
\[ \sum_w^V{[P(w|\overline{D}) * N(D)]} + P(w \in D) * N(W|D) * N(D) vs N(W)*N(D) \]</p>
<h2>Improved Sparse Matrix</h2>
<pre><code>Dictionary<int, Dictionary<string,int>> Documents;
Dictionary<int, Dictionary<string,double>> PPMI;
Dictionary<int, int> DocumentWordCounts;
//Dictionary<string, int> WordCounts;
HashSet Vocabulary;
int WordCount;
int UniqueWordCount;
int DocumentCount;
UniqueWordCount = Vocabulary.Count;
DocumentCount = Documents.Count;
while(Documents.Count > 0)
{
KeyValuePair<int,Dictionary<string,int>> doc = Documents.First();
while(doc.Value.Count > 0)
{
Dictionary<string,int> dic = doc.Values.First();
//foreach(string word in Vocabulary)
foreach(string word in dic.Keys)
{
List<int> DocumentsContainingWord = Documents.Where(o=>o.Value.ContainsKey(word)).Select(o=>o.Key).AsList();
int WordCount2 = 0;
foreach(int doc2 in DocumentsContainingWord)
WordCount2 += Documents[doc2][word];
foreach(int doc2 in DocumentsContainingWord)
{
double P_of_w_given_d = ((double)(Documents[doc2][word] + DirichletSmoothAmmount) / (double)(UniqueWordCount*DirichletSmoothAmmount + DocumentWordCount[doc2]));
double P_of_w = ((double)(/*WordCounts[word]*/ WordCount2 + DirichletSmoothAmmount)/(double)(WordCount+DirichletSmoothAmmount*UniqueWordCount*DocumentCount))
int MI = P_of_w_given_d/P_of_w;
PMI = log2(MI);
if(PMI >= PostiveThreshold)
{
PPMI[doc2].Add(word, PMI)
if(PPMI[doc2]==null)
PPMI.add(doc2, new Dictionary<string,int>());
}
Documents[doc2].RemoveKey(word);
if(Documents[doc2].Count == 0)
Documents.RemoveKey(doc2)
//PPMI = max(P(W|C)/P(W),PostiveThreshold)
}
}
}
}
</code></pre>
<pre><code>Dictionary<int, Dictionary<string,int>> Documents;
Dictionary<int, Dictionary<string,double>> PPMI;
Dictionary<int, int> DocumentWordCounts;
//Dictionary<string, int> WordCounts;
HashSet Vocabulary;
int WordCount;
int UniqueWordCount;
int DocumentCount;
UniqueWordCount = Vocabulary.Count;
DocumentCount = Documents.Count;
foreach(string word in Vocabulary)
{
List<int> DocumentsContainingWord = Documents.Where(o=>o.Value.ContainsKey(word)).Select(o=>o.Key).AsList();
int WordCount2 = 0;
foreach(int doc2 in DocumentsContainingWord)
WordCount2 += Documents[doc2][word];
foreach(int doc2 in DocumentsContainingWord)
{
double P_of_w_given_d = ((double)(Documents[doc2][word] + DirichletSmoothAmmount) / (double)(UniqueWordCount*DirichletSmoothAmmount + DocumentWordCount[doc2]));
double P_of_w = ((double)(/*WordCounts[word]*/ WordCount2 + DirichletSmoothAmmount)/(double)(WordCount+DirichletSmoothAmmount*UniqueWordCount*DocumentCount))
int MI = P_of_w_given_d/P_of_w;
PMI = log2(MI);
if(PMI >= PostiveThreshold)
{
if(PPMI[doc2]==null)
PPMI.add(doc2, new Dictionary<string,int>());
PPMI[doc2].Add(word, PMI)
}
//PPMI = max(P(W|C)/P(W),PostiveThreshold)
}
}
</code></pre>
<p>Cosine Similarity</p>
<pre><code>CosineSimilarity(int doc1, int doc2)
{
PPMI[doc1]
}
</code></pre>
<h3>Contact for the Fast PMI Network: : FLAG</h3>
<ul>
<li><a href="mailto:amit@umiacs.umd.edu">amit@umiacs.umd.edu</a></li>
</ul>
</body>
</html>