-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathassignment1-451.html
477 lines (373 loc) · 19.6 KB
/
assignment1-451.html
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="Course homepage for CS 431/631 451/651 Data-Intensive Distributed Computing (Winter 2019) at the University of Waterloo">
<meta name="author" content="Adam Roegiest">
<title>Data-Intensive Distributed Computing</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="index.html">Overview</a></li>
<li><a href="organization.html">Organization</a></li>
<li><a href="syllabus.html">Syllabus</a></li>
<li class="active"><a href="assignments.html">Assignments</a></li>
<li><a href="software.html">Software</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="container">
<div class="page-header">
<div style="float: right"><img width="250" src="images/waterloo_logo.png" alt="University of Waterloo logo"/></div>
<h1>Assignments <br/><small>Data-Intensive Distributed Computing (Winter 2019)</small></h1>
</div>
<div class="subnav">
<ul class="nav nav-pills">
<li><a href="assignment0-451.html">0</a></li>
<li><a href="assignment1-451.html">1</a></li>
<li><a href="assignment2-451.html">2</a></li>
<li><a href="assignment3-451.html">3</a></li>
<li><a href="assignment4-451.html">4</a></li>
<li><a href="assignment5-451.html">5</a></li>
<li><a href="assignment6-451.html">6</a></li>
<li><a href="assignment7-451.html">7</a></li>
<li><a href="project-451.html">Final Project</a></li>
</ul>
</div>
<h3>Assignment 1: Counting in MapReduce <small>due 2:30pm January 24</small></h3>
<p>By now, you should already be familiar with the Hadoop execution
environment (e.g., submitting jobs) and using Maven to organize your
assignments. You will be working in the same repo as before, except
that everything should go into the package namespace
<code>ca.uwaterloo.cs451.a1</code>.</p>
<p>Note that the point of assignment 0 was to familiarize you with
GitHub and the Hadoop development environment. Starting this
assignment, excuses along the lines of "I couldn't get my repo set up
properly", "I couldn't figure out how to push my assignment to
GitHub", etc. will not be accepted. It is your responsibility to sort
through any mechanics issue you have.</p>
<p>Before starting this assignment, it is <i>highly recommended</i>
that you look at the implementations of bigram relative frequency and
co-occurrence matrix computation
in <a href="http://bespin.io">Bespin</a>.</p>
<p>In this assignment you'll be
computing <a href="http://en.wikipedia.org/wiki/Pointwise_mutual_information">pointwise
mutual information</a>, which is a function of two events <i>x</i>
and <i>y</i>:</p>
<p><img width="200" src="assignments/PMI.png" alt="PMI equation"/></p>
<p>The larger the magnitude of PMI for <i>x</i> and <i>y</i> is,
the more information you know about the probability of seeing <i>y</i>
having just seen <i>x</i> (and vice-versa, since PMI is
symmetrical). If seeing <i>x</i> gives you no information about seeing
<i>y</i>, then <i>x</i> and <i>y</i> are independent and the PMI is
zero.</p>
<p>Write two separate implementations (more details below) that
computes the PMI of words in the
<code>data/Shakespeare.txt</code> collection that's used in the Bespin
demos and the previous assignment. Your implementation should be in
Java. To be more specific, the event we're after is <i>x</i> occurring
on a line in the file (the denominator in the above equation)
or <i>x</i> and <i>y</i> co-occurring on a line (the numerator in the
above equation). That is, if a line contains "A B C", then the
co-occurring pairs are:</p>
<ul>
<li>(A, B)</li>
<li>(A, C)</li>
<li>(B, A)</li>
<li>(B, C)</li>
<li>(C, A)</li>
<li>(C, B)</li>
</ul>
<p>If the line contains "A A B C", the co-occurring pairs are still
the same as above; same if the line contains "A B C A B C"; or any
combinations of A, B, and C in any order.</p>
<p>A few additional specifications:</p>
<ul>
<li>In addition to PMI, it's also important to know how many times the
pair actually co-occurs, so you'll include this information in the
output (format explained below). To reduce the number of spurious
pairs, we want to be able to specify a command-line
option <code>-threshold</code> to indicate the threshold of
co-occurrence. For example, if we specify <code>-threshold 10</code>,
then we are only interested in pairs of words that co-occur in ten or
more lines.</li>
<li>To reduce the computational complexity of the problem (since we're
generating intermediate data that is quadratic with respect to the
input), we are only going to consider up to only the first 40 words on
each line (using the definition of "word" below).</li>
<li>Just so everyone's answer is consistent, please use
log base 10.</li>
<li>Use the same definition of "word" as in the word count demo.</li>
</ul>
<p>To ensure consistent tokenization, use the Tokenizer class provided
in Bespin that you've used for assignment 0.</p>
<p>You will build two versions of the program (put both in
package <code>ca.uwaterloo.cs451.a1</code>):</p>
<ol>
<li>A "pairs" implementation. The implementation must use
combiners. Name this implementation <code>PairsPMI</code>. In the
final output, the key should be a co-occurring pair, e.g., (A, B),
and the value should be a pair (PMI, count) denoting its PMI
and co-occurrence count.</li>
<li>A "stripes" implementation. The implementation must use
combiners. Name this implementation <code>StripesPMI</code>. In the
final output, the key should be a word (e.g., A), and the value
should be a map, where each of the keys is a co-occurring word (e.g.,
B), and the value is a pair (PMI, count) denoting its PMI and
co-occurrence count.</li>
</ol>
<p>Since PMI is symmetrical, PMI(x, y) = PMI(y, x). However, it's
actually easier in your implementation to compute both values, so
don't worry about duplicates. Also, use <code>TextOutputFormat</code>
so the results of your program are human readable.</p>
<p>Make sure that the pairs implementation and the stripes
implementation give the same answers!</p>
<p>Answer the following questions:</p>
<p><b>Question 1.</b> (6 points) <i>Briefly</i> describe in prose your solution,
both the pairs and stripes implementation. For example: how many
MapReduce jobs? What are the input records? What are the intermediate
key-value pairs? What are the final output records? A paragraph for
each implementation is about the expected length.</p>
<p><b>Question 2.</b> (2 points) What is the running time of the complete pairs
implementation? What is the running time of the complete stripes
implementation? (Tell me where you ran these experiments,
e.g., <code>linux.student.cs.uwaterloo.ca</code> or your own
laptop.)</p>
<p><b>Question 3.</b> (2 points) Now disable all combiners. What is the running
time of the complete pairs implementation now? What is the running
time of the complete stripes implementation? (Tell me where you ran
these experiments, e.g., <code>linux.student.cs.uwaterloo.ca</code> or
your own laptop.)</p>
<p><b>Question 4.</b> (3 points) How many distinct PMI pairs did you
extract? Use <code>-threshold 10</code>.</p>
<p><b>Question 5.</b> (6 points) What's the pair (x, y) (or pairs if
there are ties) with the highest PMI? Use <code>-threshold
10</code>. Similarly, what's the pair with the lowest (negative) PMI?
Use the same threshold. Write a sentence or two to explain these
results.</p>
<p><b>Question 6.</b> (6 points) What are the three words that have
the highest PMI with "tears" and "death"? <code>-threshold
10</code>. And what are the PMI values?</p>
<p>Make sure that your code runs in the Linux Student CS environment
(even if you do development on your own machine), which is where we
will be doing the grading. "But it runs on my laptop!" will not be
accepted as an excuse if we can't get your code to run.</p>
<p>Note that you can compute the answer to questions 4—6 however
you wish: a helper Java program, a Python script, command-line
one-liner, etc.</p>
<h4 style="padding-top: 10px">Running on the Datasci cluster</h4>
<p>Now, on the Datasci cluster, run your pairs and stripes
implementation on the sample Wikipedia collection stored on HDFS
at <code>/data/cs451/simplewiki-20180901-sentences.txt</code>. This
is a dump
of <a href="https://simple.wikipedia.org/wiki/Main_Page">"simple"
Wikipedia</a> that has been tokenized into sentences, one per line. As
with the Shakespeare collection, we care about co-occurrence on a line
(which is a sentence in this case).</p>
<p>Make sure your code runs on this larger dataset. Assuming that
there aren't many competing jobs on the cluster, your programs should
not take more than 10 minutes to run. For reference, on an idle
cluster, the reference pairs implementation takes around 6 minutes to run and
the reference stripes implementation takes around 3 minutes to run.</p>
<p>If your job is taking much longer than that or if it doesn't look
your job is making obvious progress, then please kill it so it doesn't
waste resources and slow other people's jobs down. To kill your job,
first find its application id in the RM webapp, then issue:</p>
<pre>
$ yarn application -kill application_xxxxxxxxxxxxx_xxxx
</pre>
<p>Obviously, if the cluster is really
busy or if there's a long list of queued jobs, your job will take
longer, so use your judgement here. The only point is: be nice. It's a
shared resource, and let's not let runaway jobs slow everyone
down.</p>
<p>One final detail, set your MapReduce job parameters as follows:</p>
<pre>
job.getConfiguration().setInt("mapred.max.split.size", 1024 * 1024 * 32);
job.getConfiguration().set("mapreduce.map.memory.mb", "3072");
job.getConfiguration().set("mapreduce.map.java.opts", "-Xmx3072m");
job.getConfiguration().set("mapreduce.reduce.memory.mb", "3072");
job.getConfiguration().set("mapreduce.reduce.java.opts", "-Xmx3072m");
</pre>
<p>What the last four options do is fairly obvious. The first sets
the <i>maximum</i> split size to be 32 MB. What effect does that have?
(Hint, consider the physical execution of MapReduce programs we
discussed in class)</p>
<p><b>Question 7.</b> (5 points) In the Wikipedia dataset, what are
the five words that have the highest PMI with "hockey"? And how many
times do these words co-occur? Use <code>-threshold 50</code>.</p>
<p><b>Question 8.</b> (5 points) Same as above, but with the word
"data".</p>
<p>It's worth noting again: the Datasci cluster is a shared
resource, and how fast your jobs complete will depend on how busy it
is. You're advised to begin the assignment early as to avoid long job
queues. "I wasn't able to complete the assignment because there were
too many jobs running on the cluster" will not be accepted as an
excuse if your assignment is late.</p>
<h4 style="padding-top: 10px">Turning in the Assignment</h4>
<p>Please follow these instructions carefully!</p>
<p>Make sure your repo has the following items:</p>
<ul>
<li>Similar to assignment 0, the answers to the questions go
in <code>bigdata2019w/assignment1.md</code>.</li>
<li>The pairs and stripes implementation should be in
package <code>ca.uwaterloo.cs451.a1</code>.</li>
</ul>
<p>When grading, we will pull your repo and build your code:<p>
<pre>
$ mvn clean package
</pre>
<p>Your code should build successfully. We are then going to check
your code (both the pairs and stripes implementations).</p>
<p>We're going to run your code on the Linux student CS environment as
follows (we will make sure the collection is there):</p>
<pre>
$ hadoop jar target/assignments-1.0.jar ca.uwaterloo.cs451.a1.PairsPMI \
-input data/Shakespeare.txt -output cs451-bigdatateach-a1-shakespeare-pairs \
-reducers 5 -threshold 10
$ hadoop jar target/assignments-1.0.jar ca.uwaterloo.cs451.a1.StripesPMI \
-input data/Shakespeare.txt -output cs451-bigdatateach-a1-shakespeare-stripes \
-reducers 5 -threshold 10
</pre>
<p>Make sure that your code runs in the Linux Student CS environment
(even if you do development on your own machine), which is where we
will be doing the grading. "But it runs on my laptop!" will not be
accepted as an excuse if we can't get your code to run.</p>
<p>You can run the above instructions using
<a href="assignments/check_assignment1_public_linux.py"><code>check_assignment1_public_linux.py</code></a>,
with something like:</p>
<pre>
$ wget http://roegiest.com/bigdata-2019w/assignments/check_assignment1_public_linux.py
$ chmod +x check_assignment1_public_linux.py
$ ./check_assignment1_public_linux.py bigdatateach
</pre>
<p>We're going to run your code on the Datasci cluster as
follows:</p>
<pre>
$ hadoop jar target/assignments-1.0.jar ca.uwaterloo.cs451.a1.PairsPMI \
-input /data/cs451/simplewiki-20180901-sentences.txt -output cs451-bigdatateach-a1-wiki-pairs \
-reducers 5 -threshold 50
$ hadoop jar target/assignments-1.0.jar ca.uwaterloo.cs451.a1.StripesPMI \
-input /data/cs451/simplewiki-20180901-sentences.txt -output cs451-bigdatateach-a1-wiki-stripes \
-reducers 5 -threshold 50
</pre>
<p>You can run the above instructions using
<a href="assignments/check_assignment1_public_datasci.py"><code>check_assignment1_public_datasci.py</code></a>,
with something like:</p>
<pre>
$ wget http://roegiest.com/bigdata-2019w/assignments/check_assignment1_public_datasci.py
$ chmod +x check_assignment1_public_datasci.py
$ ./check_assignment1_public_datasci.py bigdatateach
</pre>
<p><b>Important:</b> Make sure that your code accepts the command-line
parameters above! That is, make sure the check scripts work!<p>
<p>When you've done everything, commit to your repo and remember to
push back to origin. You should be able to see your edits in the web
interface. Before you consider the assignment "complete", verify
everything above works by performing a clean clone of your repo and
going through the steps above.</p>
<p>That's it! There's no need to send us anything—we already
know your username from assignment 0. Note that everything should be
committed and pushed to origin before the deadline.</p>
<h4 style="padding-top: 10px">Hints</h4>
<ul>
<li>Did you take a look at the implementations of bigram relative
frequency and co-occurrence matrix computation
in <a href="http://bespin.io">Bespin</a>?</li>
<li>Your solution will likely require more than one MapReduce job.</li>
<li>You may have to load in "side data"?</li>
<li>See <a href="https://github.com/lintool/bespin/blob/master/src/main/java/io/bespin/java/mapreduce/cooccur/ComputeCooccurrenceMatrixPairs.java">this example</a> for how to pass in a command-line argument.</li>
<li>Counters may be useful for... well, counting.</li>
<li>Jimmy Lin's <a href="https://github.com/lintool/tools/tree/master/lintools-datatypes/">lintools-datatypes
package</a> has <code>Writable</code> datatypes that you might find
useful. (Feel free to use, but assignment can be completed
without it.)</li>
</ul>
<h4 style="padding-top: 10px">Grading</h4>
<p>This assignment is worth a total of 70 points, broken down as
follows:</p>
<ul>
<li>The questions above are worth a total of 35 points.</li>
<li>Getting your code to compile and successfully run is worth
another 20 points (5 points each for the pairs and stripes
implementation in the Linux student CS environment and on
the Datasci cluster). We will make a minimal effort to fix <i>trivial</i>
issues with your code (e.g., a typo)—and deduct
points—but <b>will not</b> spend time debugging your code. It
is your responsibility to make sure your code runs: we have taken
care to specify exactly how we will run your code—if anything
is unclear, it is your responsibility to seek clarification. In
order to get a perfect score of 16 for this portion of the grade, we
should be able to run the two public check
scripts: <a href="assignments/check_assignment1_public_linux.py"><code>check_assignment1_public_linux.py</code></a>
(on Linux Student CS)
an <a href="assignments/check_assignment1_public_datasci.py"><code>check_assignment1_public_datasci.py</code></a>
(on the Datasci cluster) successfully without any errors.</li>
<li>Another 15 points is allotted to us verifying the output of your
program in ways that we will not tell you. We're giving you the
"public" versions of the check scripts; we'll run a "private"
version to examine your output further (i.e., think blind test
cases).</li>
</ul>
<h4 style="padding-top: 10px">Reference Running Times</h4>
<p>To help you gauge the efficiency of your solution, we are giving you the running times of our reference implementations.
Keep in mind that these are machine dependent and can vary depending on the server/cluster load.</p>
<table style="border: 1px solid black; width:50%;padding: 5px;">
<tr style="border: 1px solid black">
<th style="border: 1px solid black; text-align: center;">Class name</th>
<th style="border: 1px solid black; text-align: center;">Running time Linux</th>
<th style="border: 1px solid black; text-align: center;">Running time Datasci</th>
</tr>
<tr style="border: 1px solid black">
<td style="border: 1px solid black; padding: 2px;">PairsPMI</td>
<td style="border: 1px solid black; padding: 2px">80 seconds</td>
<td style="border: 1px solid black; padding: 2px">5 minutes 45 seconds</td>
</tr>
<tr style="border: 1px solid black">
<td style="border: 1px solid black; padding: 2px">StripesPMI</td>
<td style="border: 1px solid black; padding: 2px">50 seconds</td>
<td style="border: 1px solid black; padding: 2px">3 minutes</td>
</tr>
</table>
<p style="padding-top: 20px"><a href="#">Back to top</a></p>
<div style="padding-bottom: 100px"></div>
</div><!-- /.container -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>