-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathassignment6-451.html
707 lines (551 loc) · 28 KB
/
assignment6-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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
<!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 6: Spam Classification <small>due 2:30pm March 28</small></h3>
<p>In this assignment, you will build a spam classifier trained using
stochastic gradient descent in Spark, replicating the work described
in <a href="http://arxiv.org/abs/1004.5168">Efficient and Effective
Spam Filtering and Re-ranking for Large Web Datasets</a> by Cormack,
Smucker, and Clarke. We will draw your attention to specific sections
of the paper that are directly pertinent to the assignment, but you
should read the entire paper for background.</p>
<h4 style="padding-top: 10px">Downloading Data</h4>
<p>If you're working on your laptop, grab the training and test data:</p>
<pre>
wget https://www.student.cs.uwaterloo.ca/~cs451/spam/spam.train.group_x.txt.bz2
wget https://www.student.cs.uwaterloo.ca/~cs451/spam/spam.train.group_y.txt.bz2
wget https://www.student.cs.uwaterloo.ca/~cs451/spam/spam.train.britney.txt.bz2
wget https://www.student.cs.uwaterloo.ca/~cs451/spam/spam.test.qrels.txt.bz2
</pre>
<p>Otherwise, the datasets are at <code>~cs451/public_html/spam/</code> in the
Linux Student CS environment.</p>
<p>Just to verify what you've downloaded:</p>
<div style="width: 75%">
<table class="table table-striped">
<thead><tr><td><b>File</b></td><td><b>MD5</b></td><td><b>Size</b></td></tr></thead>
<tr><td><code>spam.train.group_x.txt.bz2</code></td><td><code>947faf932afee7e35d79e7da10fe0e3e</code></td><td>5.5 MB</td></tr>
<tr><td><code>spam.train.group_y.txt.bz2</code></td><td><code>7cf45c3666915999f1048aafeff4c60e</code></td><td>6.6 MB</td></tr>
<tr><td><code>spam.train.britney.txt.bz2</code></td><td><code>bad2e4ccaed7482f9e99e65e58c6beda</code></td><td>248 MB</td></tr>
<tr><td><code>spam.test.qrels.txt.bz2</code></td><td><code>99858d9dd1b40e994732a641703859ec</code></td><td>303 MB</td></tr>
</table>
</div>
<p>After you've downloaded the data, unpack:</p>
<pre>
bunzip2 spam.train.group_x.txt.bz2
bunzip2 spam.train.group_y.txt.bz2
bunzip2 spam.train.britney.txt.bz2
bunzip2 spam.test.qrels.txt.bz2
</pre>
<p>Verify the unpacked data:</p>
<div style="width: 75%">
<table class="table table-striped">
<thead><tr><td><b>File</b></td><td><b>MD5</b></td><td><b>Size</b></td></tr></thead>
<tr><td><code>spam.train.group_x.txt</code></td><td><code>d6897ed8319c71604b1278b660a479b6</code></td><td>25 MB</td></tr>
<tr><td><code>spam.train.group_y.txt</code></td><td><code>4d103821fdf369be526347b503655da5</code></td><td>20 MB</td></tr>
<tr><td><code>spam.train.britney.txt</code></td><td><code>b52d54caa20325413491591f034b5e7b</code></td><td>766 MB</td></tr>
<tr><td><code>spam.test.qrels.txt</code></td> <td><code>df1d26476ec41fec625bc2eb9969875c</code></td><td>1.1 GB</td></tr>
</table>
</div>
<p>Next, download the two files you'll need for evaluating the output of
the spam classifier (links below):</p>
<ul>
<li><a href="assignments/compute_spam_metrics.c"><code>compute_spam_metrics.c</code></a></li>
<li><a href="assignments/spam_eval.sh"><code>spam_eval.sh</code></a></li>
<li><a href="assignments/spam_eval_hdfs.sh"><code>spam_eval_hdfs.sh</code></a></li>
</ul>
<p>Compile the C program:</p>
<pre>
gcc -O2 -o compute_spam_metrics compute_spam_metrics.c -lm
</pre>
<p>You might get some warnings but don't worry—the code should
compile fine. The actual evaluation script <code>spam_eval.sh</code>
(and <code>spam_eval_hdfs.sh</code>)
calls <code>compute_spam_metrics</code>, so make sure they're in the
same directory.</p>
<p>Note on local vs. the Datasci cluster: for this assignment, your
code must (eventually) work on the Datasci cluster, but feel free to
develop locally or in the Linux Student CS environment. The
instructions below are written for running locally, but in a separate
section later we will cover details specific to the Datasci
cluster.</p>
<h4 style="padding-top: 10px">Basic Spam Classifier</h4>
<p>In this assignment, we'll take you through building spam
classifiers of increasing complexity, but let's start with a basic
implementation using stochastic gradient descent. Build the spam
classifier in <b>exactly</b> the way we describe below, because later
parts of the assignment will depend on the setup.</p>
<p>First, let's write the classifier trainer. The classifier trainer
takes all the training instances, runs stochastic gradient descent,
and produces a model as output.</p>
<p>Look at the Cormack, Smucker, and Clarke paper:
the entire algorithm is literally 34 lines of C, shown in Figure 2 on
page 10. The stochastic gradient descent update equations are in
equations (11) and (12) on page 11. We actually made things <i>even
simpler</i> for you: the features used in the spam classifier are
hashed byte 4-grams (thus, integers)—we've pre-computed the
features for you.</p>
<p>Take a look at <code>spam.train.group_x.txt</code>. The first line
begins as follows:</p>
<pre>
clueweb09-en0094-20-13546 spam 387908 697162 426572 161118 688171 ...
</pre>
<p>In the file, each training instance is on a line. Each line begins
with a document id, the string "spam" or "ham" (the label), and a list
of integers (the features).</p>
<p>Therefore, your spam classifier will look something like this:</p>
<pre>
// w is the weight vector (make sure the variable is within scope)
val w = Map[Int, Double]()
// Scores a document based on its list of features.
def spamminess(features: Array[Int]) : Double = {
var score = 0d
features.foreach(f => if (w.contains(f)) score += w(f))
score
}
// This is the main learner:
val delta = 0.002
// For each instance...
val isSpam = ... // label
val features = ... // feature vector of the training instance
// Update the weights as follows:
val score = spamminess(features)
val prob = 1.0 / (1 + exp(-score))
features.foreach(f => {
if (w.contains(f)) {
w(f) += (isSpam - prob) * delta
} else {
w(f) = (isSpam - prob) * delta
}
})
</pre>
<p>We've given you the code fragment for the learner above as a
starting point—it's your job to understand exactly how it works
and turn it into a complete classifier trainer in Spark.</p>
<p>For the structure of the Spark trainer program, take a look at
slide 14 in the <a href="slides/didp-part06b.pdf#page=14">Part 06b, slide 14</a>
deck. We're going to build the configuration shown there (even though
the slide says MapReduce, we're implementing it in
Spark). Specifically, we're going run a single reducer to make sure we
pump all the training instances through a single learner on the
reducer end. The overall structure of your program is going to look
something like this:</p>
<pre>
val textFile = sc.textFile("/path/to/training/data")
val trained = textFile.map(line =>{
// Parse input
// ..
(0, (docid, isSpam, features))
}).groupByKey(1)
// Then run the trainer...
trained.saveAsTextFile(...)
</pre>
<p>Note the mappers are basically just parsing the feature vectors and
pushing them over to the reducer side for additional processing. We
emit "0" as a "dummy key" to make sure all the training instances get
collected at the reducer end via <code>groupByKey()</code>... after
which you run the trainer (which applies the SGD updates, per
above). Of course, it's your job to figure out how to connect the
pieces together. This is the crux of the assignment.</p>
<p>Putting everything together, you will write a trainer program
called <code>TrainSpamClassifier</code> that we will execute in the
following manner:</p>
<pre>
spark-submit --driver-memory 2g --class ca.uwaterloo.cs451.a6.TrainSpamClassifier \
target/assignments-1.0.jar --input spam.train.group_x.txt --model cs451-bigdatateach-a6-model-group_x
</pre>
<p>The <code>--input</code> option specifies the input training
instances (from above); the <code>--model</code> option specifies the
output directory where the model goes. Inside the model
directory <code>cs451-bigdatateach-a6-model-group_x</code>, there
should be a single file, <code>part-00000</code>, that contains the
trained model. The trained model should be a sequence of tuples, one
on each line; each tuple should contain a feature and its weight (a
double value). Something like:</p>
<pre>
$ head -5 cs451-bigdatateach-a6-model-group_x/part-00000
(547993,2.019484093190069E-4)
(577107,5.255371091500805E-5)
(12572,-4.40967560913553E-4)
(270898,-0.001340150007664197)
(946531,2.560528666942676E-4)
</pre>
<p>Next, you will write another Spark program
named <code>ApplySpamClassifier</code> that will apply the trained spam
classifier to the test instances. That is, the program will read in
each input instance, compute the spamminess score (from above), and
make a prediction: if the spamminess score is above 0, classify the
document as spam; otherwise, classify the document as ham.</p>
<p>We will run the program in the following manner:</p>
<pre>
spark-submit --driver-memory 2g --class ca.uwaterloo.cs451.a6.ApplySpamClassifier \
target/assignments-1.0.jar --input spam.test.qrels.txt \
--output cs451-bigdatateach-a6-test-group_x --model cs451-bigdatateach-a6-model-group_x
</pre>
<p>The <code>--input</code> option specifies the input test instances;
the <code>--model</code> option specifies the classifier model; and
the <code>--output</code> option specifies the output directory. The
test data is organized in exactly the same way as the training data.
The output of <code>ApplySpamClassifier</code> should be organized as
follows:</p>
<pre>
$ cat cs451-bigdatateach-a6-test-group_x/* | sort | head -5
(clueweb09-en0000-00-00142,spam,2.601624279252943,spam)
(clueweb09-en0000-00-01005,ham,2.5654162439491004,spam)
(clueweb09-en0000-00-01382,ham,2.5893946346394188,spam)
(clueweb09-en0000-00-01383,ham,2.6190102258752614,spam)
(clueweb09-en0000-00-03449,ham,1.500142758578532,spam)
</pre>
<p>The first field in each tuple is the document id and the second
field is the test label. These are just copied from the
test data. The third field is the spamminess score, and the fourth
field is the classifier's prediction.</p>
<p><b>Important:</b> It is absolutely critical that your
classifier <b>does not</b> use the label in the test data when making its
predictions. The only reason the label is included in the
output is to facilitate evaluation (see below).</p>
<p>Finally, you can evaluate your results:</p>
<pre>
$ ./spam_eval.sh cs451-bigdatateach-a6-test-group_x
1-ROCA%: 17.25
</pre>
<p>The eval script prints the evaluation metric, which is the area under the
receiver operating characteristic (ROC) curve. This is a common way to
characterize classifier error. The lower this score, the better.</p>
<p>If you've done everything correctly up until now, you should be
able to replicate the above results.</p>
<p>You should then be able to train on the <code>group_y</code> training set:</p>
<pre>
spark-submit --driver-memory 2g --class ca.uwaterloo.cs451.a6.TrainSpamClassifier \
target/assignments-1.0.jar --input spam.train.group_y.txt --model cs451-bigdatateach-a6-model-group_y
</pre>
<p>And make predictions:</p>
<pre>
spark-submit --driver-memory 2g --class ca.uwaterloo.cs451.a6.ApplySpamClassifier \
target/assignments-1.0.jar --input spam.test.qrels.txt \
--output cs451-bigdatateach-a6-test-group_y --model cs451-bigdatateach-a6-model-group_y
</pre>
<p>And evaluate:</p>
<pre>
$ ./spam_eval.sh cs451-bigdatateach-a6-test-group_y
1-ROCA%: 12.82
</pre>
<p>Finally, train on the <code>britney</code> training set:</p>
<pre>
spark-submit --driver-memory 2g --class ca.uwaterloo.cs451.a6.TrainSpamClassifier \
target/assignments-1.0.jar --input spam.train.britney.txt --model cs451-bigdatateach-a6-model-britney
</pre>
<p>And make predictions:</p>
<pre>
spark-submit --driver-memory 2g --class ca.uwaterloo.cs451.a6.ApplySpamClassifier \
target/assignments-1.0.jar --input spam.test.qrels.txt \
--output cs451-bigdatateach-a6-test-britney --model cs451-bigdatateach-a6-model-britney
</pre>
<p>And evaluate:</p>
<pre>
$ ./spam_eval.sh cs451-bigdatateach-a6-test-britney
1-ROCA%: 15.96
</pre>
<p>There may be some non-determinism in running over
the <code>britney</code> dataset, so you might get something slightly
different.</p>
<p>Here's a placeholder for question 1 that you're going to answer
below (see section on the Datasci cluster).</p>
<h4 style="padding-top: 10px">Ensemble Spam Classifier</h4>
<p>Next, let's build an ensemble classifier. Start by gathering all
the models from each of the individual classifiers into a common
directory:</p>
<pre>
mkdir cs451-bigdatateach-a6-model-fusion
cp cs451-bigdatateach-a6-model-group_x/part-00000 cs451-bigdatateach-a6-model-fusion/part-00000
cp cs451-bigdatateach-a6-model-group_y/part-00000 cs451-bigdatateach-a6-model-fusion/part-00001
cp cs451-bigdatateach-a6-model-britney/part-00000 cs451-bigdatateach-a6-model-fusion/part-00002
</pre>
<p>With these three separate classifiers, implement two different
ensemble techniques:</p>
<ul>
<li>Score averaging: Average the spamminess score from each
individual classifier. If the average score is above 0, classify the
document as spam; otherwise, classify the document as ham.</li>
<li>Voting: Each classifier gets a vote on spam/ham. Majority
wins. The spamminess score in this case is # spam - # ham (so the
possible scores are -3, -1, 1, 3).</li>
</ul>
<p>Write a program <code>ApplyEnsembleSpamClassifier</code> that we
will execute in the following manner:</p>
<pre>
spark-submit --driver-memory 2g --class ca.uwaterloo.cs451.a6.ApplyEnsembleSpamClassifier \
target/assignments-1.0.jar --input spam.test.qrels.txt \
--output cs451-bigdatateach-a6-test-fusion-average --model cs451-bigdatateach-a6-model-fusion --method average
</pre>
<p>The <code>--input</code> option specifies the input test instances.
The <code>--model</code> option specifies the base directory of all
the classifier models; in this directory your program should expect
each individual model in a <code>part-XXXXX</code> file; it's okay to
hard code the part files for convenience. The <code>--output</code>
option specifies the output directory. Finally,
the <code>--method</code> option specifies the ensemble technique,
either "average" or "vote" per above.</p>
<p>Your prediction program needs to load all three models, apply the
specified ensemble technique, and make predictions. Hint: Spark
broadcast variables are helpful in this implementation.</p>
<p>The output format of the predictions should be the same as the
output of the <code>ApplySpamClassifier</code> program. You should be
able to evaluate with <code>spam_eval.sh</code> in the same way. Go
ahead and predict with the two ensemble techniques and evaluate the
predictions. Note that ensemble techniques can sometimes improve on
the best classifier; sometimes not.</p>
<p>Here's a placeholder for questions 2 and 3 that you're going to
answer below (see section on the Datasci cluster).</p>
<p>How does the ensemble compare to just concatenating all the
training data together and training a single classifier? Let's find
out:</p>
<pre>
cat spam.train.group_x.txt spam.train.group_y.txt spam.train.britney.txt > spam.train.all.txt
</pre>
<p>Now train on this larger test set, predict, and evaluate.</p>
<p>Here's a placeholder for question 4 that you're going to answer
below (see section on the Datasci cluster).</p>
<h4 style="padding-top: 10px">The Effects of Data Shuffling</h4>
<p>In class, we talked about how a model trained using stochastic
gradient descent is dependent on the order in which the training
instances are presented to the trainer. Let's explore this effect.</p>
<p>Modify the <code>TrainSpamClassifier</code> to implement a new
option <code>--shuffle</code>. With this option, the program will
randomly shuffle the training instances before running the
trainer:</p>
<pre>
spark-submit --driver-memory 2g --class ca.uwaterloo.cs451.a6.TrainSpamClassifier \
target/assignments-1.0.jar --input spam.train.britney.txt --model cs451-bigdatateach-a6-model-britney-shuffle --shuffle
</pre>
<p>You <i>must</i> shuffle the data using Spark. The way to accomplish
this in Spark is to generate a random number for each instance and
then sort the instances by the value. That is, you <i>cannot</i>
simply read all the training instances into memory in the driver,
shuffle, and then parallelize.</p>
<p>Obviously, the addition of the <code>--shuffle</code> option should
not break existing functionality; that is, without the option, the
program should behave exactly as before.</p>
<p>Note that in this case we're working with the <code>britney</code>
data because the two other datasets have very few
examples—random shuffles can lead to weird idiosyncratic
effects.</p>
<p>You should be able to evaluate the newly trained model in exactly
the same way as above. If you are getting a wildly different 1-ROCA%
scores each time, you're doing something wrong.</p>
<p>Here's a placeholder for question 5 that you're going to answer
below.</p>
<h4 style="padding-top: 10px">Running on the Datasci Cluster</h4>
<p>You are free to develop locally on your own machine or in the Linux
Student CS environment (and in fact, the instructions above assume
so), but you must make sure that your code runs in the Datasci cluster
also. This is just to verify that your Spark programs will work in a
distributed environment, and that you are not inadvertently taking
advantage of some local feature.</p>
<p>All training and test data are located in <code>/data/cs451/</code>
on HDFS. Note that
<code>spam.train.all.txt</code> has already been prepared for you in
that directory also.</p>
<p>For example, training, predicting, and evaluating on
the <code>group_x</code> dataset on the Datasci cluster:</p>
<pre>
spark-submit --class ca.uwaterloo.cs451.a6.TrainSpamClassifier \
--num-executors 2 --executor-cores 2 --executor-memory 8G \
target/assignments-1.0.jar --input /data/cs451/spam.train.group_x.txt \
--model cs451-bigdatateach-a6-model-group_x
spark-submit --class ca.uwaterloo.cs451.a6.ApplySpamClassifier \
--num-executors 2 --executor-cores 2 --executor-memory 8G \
target/assignments-1.0.jar --input /data/cs451/spam.test.qrels.txt \
--output cs451-bigdatateach-a6-test-group_x --model cs451-bigdatateach-a6-model-group_x
./spam_eval_hdfs.sh cs451-bigdatateach-a6-test-group_x
</pre>
<p>The major differences are:</p>
<ul>
<li>Location of the training/test data (on HDFS).</li>
<li>All input/output from/to HDFS.</li>
<li>Use of <code>spam_eval_hdfs.sh</code> for the evaluation script.</li>
<li>Cluster-specific setup parameters (e.g., <code>--num-executors</code>). These are the settings that we'll use, so please don't change.</li>
</ul>
<p>Refer back to the placeholders above and answer the following
questions, <i>running your code on the Datasci cluster</i>:</p>
<p><b>Question 1:</b> For each individual classifiers trained
on <code>group_x</code>, <code>group_y</code>,
and <code>britney</code>, what are the 1-ROCA% scores? You should be
able to replicate our results
on <code>group_x</code>, <code>group_y</code>, but there may be some
non-determinism for <code>britney</code>, which is why we want you to
report the figures.</p>
<p><b>Question 2:</b> What is the 1-ROCA% score of the score averaging
technique in the 3-classifier ensemble?</p>
<p><b>Question 3:</b> What is the 1-ROCA% score of the voting
technique in the 3-classifier ensemble?</p>
<p><b>Question 4:</b> What is the 1-ROCA% score of a single classifier
trained on all available training data concatenated together?</p>
<p><b>Question 5:</b> Run the shuffle trainer 10 times on
the <code>britney</code> dataset, predict and evaluate the classifier
on the test data each time. Report the 1-ROCA% score in each of the
ten trials and compute the overall average.</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>Put the answers to all the questions above
in <code>bigdata2019w/assignment6.md</code>.</li>
<li>Your implementations should go in
package <code>ca.uwaterloo.cs451.a6</code>. At the minimum, you should have
<code>TrainSpamClassifier</code>, <code>ApplySpamClassifier</code>,
and <code>ApplyEnsembleSpamClassifier</code>. Feel free to include helper code also.</li>
</ul>
<p>Make sure your implementation runs on the Datasci cluster. The
following check script is provided for you (check the source for the relevant flags):</p>
<ul>
<li><a href="assignments/check_assignment6_public.py"><code>check_assignment6_public.py</code></a></li>
</ul>
<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", we would
recommend that you verify everything above works by performing a clean
clone of your repo and run the public check scripts.</p>
<p>That's it!</p>
<h4 style="padding-top: 10px">Grading</h4>
<p>The entire assignment is worth 60 points:</p>
<ul>
<li>Getting your code to compile is worth 4 points.</li>
<li>A correct implementation of the
basic <code>TrainSpamClassifier</code> is worth 15 points.</li>
<li>A correct implementation of <code>ApplySpamClassifier</code> is
worth 5 points.</li>
<li>A correct implementation
of <code>ApplyEnsembleSpamClassifier</code> is worth 6 points.</li>
<li>A correct implementation of the <code>--shuffle</code> option
in <code>TrainSpamClassifier</code> is worth 5 points.</li>
<li>The answers to questions 1-5 are worth 3 points each.</li>
<li>Being able to successfully run all your code on the Datasci
cluster is worth 10 points. We will begin by testing all your code
on the Datasci cluster. If everything works there, you will get full
marks. If we can't get your code to run successfully on the Datasci
cluster, we will try running your code in the Linux Student CS
environment, as part of confirming that the implementations above
are correct. However, if your code works in the Linux Student CS
environment but not on the Datasci cluster, you will still receive
zero marks for this item.</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;">TrainSpamClassifier - group x</td>
<td style="border: 1px solid black; padding: 2px">9 seconds</td>
<td style="border: 1px solid black; padding: 2px">30 seconds</td>
</tr>
<tr style="border: 1px solid black">
<td style="border: 1px solid black; padding: 2px">TrainSpamClassifier - group y</td>
<td style="border: 1px solid black; padding: 2px">9 seconds</td>
<td style="border: 1px solid black; padding: 2px">30 seconds</td>
</tr>
<tr style="border: 1px solid black">
<td style="border: 1px solid black; padding: 2px">TrainSpamClassifier - britney</td>
<td style="border: 1px solid black; padding: 2px">75 seconds</td>
<td style="border: 1px solid black; padding: 2px">90 seconds</td>
</tr>
<tr style="border: 1px solid black">
<td style="border: 1px solid black; padding: 2px;">TrainSpamClassifier - all</td>
<td style="border: 1px solid black; padding: 2px">1 minute 44 seconds</td>
<td style="border: 1px solid black; padding: 2px">90 seconds</td>
</tr>
<tr style="border: 1px solid black">
<td style="border: 1px solid black; padding: 2px;">TrainSpamClassifier - shuffle britney</td>
<td style="border: 1px solid black; padding: 2px">1 minute 40 seconds</td>
<td style="border: 1px solid black; padding: 2px">1 minute 40 seconds</td>
</tr>
<tr style="border: 1px solid black">
<td style="border: 1px solid black; padding: 2px;">ApplySpamClassifier</td>
<td style="border: 1px solid black; padding: 2px">15 seconds</td>
<td style="border: 1px solid black; padding: 2px">45 seconds</td>
</tr>
<tr style="border: 1px solid black">
<td style="border: 1px solid black; padding: 2px;">ApplyEnsembleSpamClassifier</td>
<td style="border: 1px solid black; padding: 2px">24 seconds</td>
<td style="border: 1px solid black; padding: 2px">74 seconds</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>