Unit 6 · 4 hrs · CSUE301 Big Data Analytics

Scalable
Machine Learning

Fit a line through fifteen points (order #10's veracity bug stays excluded — you don't train a model on a value you already know is broken) and you'd normally just... fit it. This chapter asks the question that only shows up once those fifteen points are scattered across three machines that don't share memory: how does an algorithm learn from data it can't see all at once?

Amount predicts delivery time, loosely

A gradient is just a direction to nudge two numbers

Who computes the nudge when the data is split three ways?

Correlation 0.74 between order amount and delivery time — enough for a real, if imperfect, line. Section 6.2 fits it with the data sitting on three separate machines the whole time.

Colour contract for this chapter Hub N's server Hub S's server Hub E's server What the learning algorithm had to decide
6.1 · WHY DISTRIBUTED ML IS DIFFERENT

The Formula Assumes You Can See Everything

A textbook fits a line through fifteen points by looking at all fifteen at once. That assumption is the first thing to break once the points live on three machines that don't share memory.

Split the WORK, or split the MODEL — these are the two genuinely different axes of "distributed" machine learning, and CityCourier's tiny linear model only ever needs one of them.

two kinds of parallelism Data parallelism the model is small enough to fit on one machine; the DATA doesn't fit (or shouldn't have to move). Every machine holds a slice of the rows and computes on its own slice. Model parallelism the MODEL itself is too big for one machine — a neural network with more parameters than one GPU's memory holds. Different machines hold different pieces of the same model.

A weight and a bias — two numbers — fit on any machine ever built. CityCourier's regression only ever needs data parallelism; model parallelism becomes relevant at a scale (billion-parameter models) this course doesn't otherwise touch.

Why the Closed-Form Formula Doesn't Just "Scale Up"

Linear regression has an exact, one-step formula (ordinary least squares, solved via matrix inversion) that a statistics course teaches first. It needs the entire dataset assembled into one matrix before a single operation can run. Gradient descent needs something much weaker at each step: a sum and a count, computable independently on each machine's own slice and combined afterward.

the pattern is: what can be aggregated?

This is the exact question Section 3.3 asked about combiners. A sum, a count, a gradient at a fixed point — all associative, all computable locally and combined afterward with no loss of correctness. A matrix inversion over the whole dataset, a global sort, a nearest-neighbour search against every other point — none of these decompose the same way. An algorithm's distributability isn't about how "advanced" it is; it's about whether its inner step can be expressed as aggregable partial results.

Worked Example · Same Answer, Two Very Different Appetites for Data Access
Closed-form OLS

Needs every (amount, delivery_time) pair present in memory together to build and invert a matrix. Exact, one step, and requires the full dataset to already be somewhere a single process can reach.

Gradient descent

Needs, per step, only each machine's local sum of a simple expression over its own rows. Approximate, many steps, but never requires all the data in one place at one time — exactly what three machines with 6, 4, and 5 rows each can actually provide.

pitfalls
  • "More machines always trains faster." Every additional machine's gradient has to be communicated and combined before the next step can start — Section 3's shuffle-cost lessons apply directly. Past some point, coordination overhead outgrows the benefit of splitting data further.
  • "Distributed ML means a fundamentally different algorithm." Gradient descent's distributed version computes the identical mathematical gradient as the single-machine version; it just computes the pieces on different machines and adds them up. The math didn't change, only where the arithmetic happens.
  • "Any algorithm can be made data-parallel with enough engineering." Some genuinely can't without changing what they compute — an exact global sort or an exact nearest-neighbour query needs comparisons against data that, by definition, isn't local to any one machine.
Practice
  1. Computing the MEAN delivery time across all 15 clean orders, split across 3 machines: is this data parallelism, model parallelism, both, or neither?
    Solution

    Data parallelism — there's no "model" here at all, just an aggregation (sum and count) computed locally per machine and combined. Same shape as Section 3.3's combiner, not machine learning in the model-fitting sense, but the same underlying pattern.

  2. A recommendation model has one billion parameters, too large for any single machine's memory, trained on a modest, single-machine-sized dataset. Which kind of parallelism does this scenario need?
    Solution

    Model parallelism — the data fits fine on one machine; it's the MODEL that doesn't fit anywhere. Different machines would hold different slices of the billion parameters, needing to coordinate during each forward/backward pass, the opposite bottleneck from CityCourier's tiny-model, split-data scenario.

  3. Why can't an exact median (not mean) be computed the same aggregate-and-combine way as a sum or count across partitions?
    Solution

    A median needs the actual relative ORDER of every value against every other value to find the true middle one; two machines' local medians don't combine into the global median through any simple arithmetic the way two local sums add into a global sum. (Approximate streaming median algorithms exist, but they trade exactness for exactly this reason.)

  4. Section 3.4 showed that a data-skewed key can't be fixed just by adding more reducers. Does adding more machines fix a poorly-parallelizable ML algorithm the same way it fails to fix skew?
    Solution

    Similar failure shape — more machines only help the parts of a computation that genuinely decompose into independent, combinable pieces. An algorithm whose core step needs global information (a closed-form matrix inversion, an exact sort) doesn't get any easier to distribute just because more machines are available, the same way more reducers didn't split Curry Point's single hot key.

6.2 · DISTRIBUTED GRADIENT DESCENT

Three Machines, One Nudge

Fitting delivery_time = w·amount + b needs a gradient at every step. Three machines each computing their own slice's gradient have to somehow become one number.

Predicting delivery time from order amount (correlation 0.74 on the 15 veracity-clean orders — order #10 stays excluded, exactly as training on a known-impossible label would corrupt the fit before it starts) is a one-weight, one-bias linear model. Gradient descent nudges both numbers, repeatedly, in the direction that reduces squared error — and each nudge only needs a sum over whatever rows are locally available.

Worked Example · Fitting the Line, Centrally

Starting from w=0, b=0, learning rate 0.01, on amount scaled to hundreds of rupees:

gradient descent, whole dataset, 6 epochs
epochwbMSE
0 (start)0.00.0522,504.6
151.0714.20281,049.3
287.7124.63156,378.6
4132.7738.1658,717.2
6155.8245.9532,586.8
Worked Example · The Same First Step, Split Across Two Machines

Split the 15 rows unevenly — 11 rows on one machine, 4 on the other, an imbalance no worse than Section 1.5's 11-vs-5 node split — and compute epoch 1's gradient on each machine separately, at the starting point w=0,b=0.

Combine two local gradients into one global step
11 rows · 4 rows · same starting point
local gradientsMachine A (n=11): ∂w = −4,717.4. Machine B (n=4): ∂w = −6,179.6. Each is a perfectly correct gradient — for its OWN 11 or 4 rows, not for all 15.
naive combination: plain average(−4,717.4 + −6,179.6) ÷ 2 = −5,448.5 — treating both machines as equally important, even though one holds nearly 3× the rows of the other.
correct combination: weighted by row count(−4,717.4×11 + −6,179.6×4) ÷ 15 = −5,107.3 — exactly matching the true whole-dataset gradient computed centrally above.
Answer: the naive average is 6.7% off the correct gradient. The weighted average matches it exactly. Every subsequent epoch inherits whichever error the first step made.
See the Gap
Naive vs weighted gradient combination
Machine A: n=11 · Machine B: n=4
Plain average: treats both machines as equally important, regardless of how many rows each holds.
this is the single most common distributed-training bug

Real frameworks (Spark MLlib, parameter-server systems) weight by partition size specifically because partitions are almost never equal — a straggler node, an uneven shuffle, or simply an odd row count guarantees it. Code that naively averages gradients across workers without weighting by how much data each one held is silently, consistently wrong, in exact proportion to how uneven the split happens to be.

pitfalls
  • "Each machine's gradient is 'wrong' on its own." Each is the exactly correct gradient for its own subset. The error is entirely in how they're combined afterward, not in either machine's arithmetic.
  • "Weighting only matters for extreme imbalances." An 11-vs-4 split (well short of Section 3.4's 144× skew) already produced a 6.7% error. Weighting costs nothing extra to implement correctly; there's no threshold below which skipping it is safe.
  • "Once the first step is right, later steps fix any earlier error." They don't automatically — each new step's local gradients would need the SAME correct weighting applied again, every time. An unweighted averaging bug in the code repeats identically at every epoch, not just the first.
Practice
  1. If the split were even (7 vs 8 rows instead of 11 vs 4), would naive averaging still produce an error?
    Solution

    Yes, generally — naive averaging is only guaranteed correct when the partition sizes are EXACTLY equal (7 vs 8 still differ). The error would likely be smaller than the 11-vs-4 case's 6.7%, since the imbalance is milder, but "smaller" isn't "zero" unless the split is perfectly even.

  2. Three machines hold 5, 5, and 5 rows respectively. Does naive (unweighted) averaging give the correct combined gradient here?
    Solution

    Yes — with equal partition sizes, the weighted average and the naive average are the same calculation (each weight is 5/15 = 1/3 either way). Naive averaging is a special case of weighted averaging that happens to be correct only when every partition is the same size.

  3. Section 3.1's ApplicationMaster tracked task completion for one job. In distributed gradient descent, what would need to be tracked before the driver can safely combine that epoch's gradients?
    Solution

    That every machine's local gradient for the current epoch has actually arrived, and how many rows each one was computed over. Combining early — using only 2 of 3 machines' results because the third hasn't reported yet — would silently produce a partial, biased gradient, structurally identical to this section's weighting bug even though the cause is different (missing data rather than wrong arithmetic).

  4. Connect this to Section 5.6: is an unweighted-average bug a "delivery" problem the way duplicate message processing was, or something else?
    Solution

    Something else entirely — nothing was delivered twice or lost. Every machine's gradient arrived exactly once and was used exactly once; the bug is purely in the COMBINING FORMULA applied to correctly-delivered data. Section 5.6's fixes (idempotency, exactly-once semantics) wouldn't touch this bug at all, since the problem isn't in how many times data arrived but in the arithmetic once it did.

6.3 · K-MEANS AT SCALE

Finding Groups Nobody Labelled

Nobody told CityCourier's orders which ones were "budget" and which were "premium." K-means finds that split on its own — using the exact same distributed-sum pattern Section 6.2 just got wrong and then fixed.

K-means repeats two steps until nothing changes: assign every point to its nearest of K centroids, then move each centroid to the mean of the points assigned to it. Lloyd's algorithm, and both steps distribute cleanly — assignment only needs a point and the current centroids (no cross-machine communication), and recomputing a centroid is exactly Section 3.3's sum-and-count combiner pattern.

Worked Example · Clustering by Order Amount, K=2

Starting centroids ₹150 and ₹560 (deliberately far apart, no special meaning), on the 15 veracity-clean orders:

Assign, recompute, converge
K=2 · 15 orders · 3 machines
round 1 · assign (local, no communication)Each machine compares its own points to the two current centroids and buckets them — purely local work, no different from Section 3.2's map phase.
round 1 · recompute (the only networked step)Block 1 contributes sum=1,090 count=4 to cluster 1 and sum=980 count=2 to cluster 2. Block 2 contributes 780/3 and 520/1. Block 3 contributes 780/3 and 955/2. Summed globally: cluster 1 = 2,650÷10 = ₹265.0. Cluster 2 = 2,455÷5 = ₹491.0.
round 2Re-assigning against the new centroids (265.0, 491.0) produces the identical grouping as round 1 — no point crosses to the other cluster. The centroids don't move. Converged.
Answer: two clusters — 10 orders averaging ₹265 (ids 1,2,3,5,7,8,9,12,13,16), 5 orders averaging ₹491 (ids 4,6,11,14,15) — found in exactly one real iteration, using nothing but per-machine sums and counts.
Step Through the Iteration
Assign → recompute, one round at a time
3 machines · K=2
Step 1 of 3
Starting centroids: ₹150 and ₹560. Every machine assigns its own points locally.
K-means is data-parallel almost by accident

Nothing about K-means was DESIGNED for distribution the way MapReduce was — it's a 1957 algorithm. It happens to distribute cleanly because both of its steps only ever need per-point comparisons (assignment) or aggregable sums (recomputation), exactly Section 6.1's litmus test for what parallelizes, applied retroactively to an algorithm invented decades before distributed computing existed.

pitfalls
  • "K-means always converges to the same answer." Different starting centroids can converge to different final clusters, especially with more clusters than this section's K=2 example. Real implementations run several random initializations and keep the best result.
  • "More machines make each round of K-means faster in proportion." The assign step scales well (embarrassingly parallel, no communication). The recompute step still needs every machine's partial sums gathered centrally every round — a real, if usually small, communication cost that doesn't vanish just because assignment is cheap.
  • "Distributed K-means requires a different algorithm than single-machine K-means." Same algorithm, same two steps, same convergence guarantee — only the recompute step's implementation changes, from "sum a local array" to "sum local arrays and add across machines."
Practice
  1. If Block 2's contribution to cluster 1 (sum=780, count=3) were lost due to a machine failure before the driver combined the round, what would the resulting centroid be, and is this the same kind of problem Section 3.6 addressed?
    Solution

    Cluster 1's centroid would be computed from only 1,870÷7 = ₹267.1 instead of the correct ₹265.0 — close, but silently wrong, using 7 of the true 10 points. Yes, structurally the same problem as Section 3.6: a lost partial result needs to be detected and either retried or recomputed from lineage, not silently omitted from the combination.

  2. With K=3 instead of K=2, would the assign step's cost per point change?
    Solution

    Slightly — each point now compares against 3 centroids instead of 2, a small constant-factor increase, not a fundamental change. The assign step remains purely local and embarrassingly parallel regardless of K.

  3. Two different machines, run independently with different random seeds for initial centroids, produce different final clusterings for the same 15 orders. Does this mean K-means is broken?
    Solution

    No — this section's pitfall box already flagged it: K-means can converge to different local answers depending on starting centroids. It's a known property of the algorithm (not a distributed-computing bug), which is why production use runs multiple initializations and picks the best-scoring result rather than trusting any single run.

  4. Section 6.1 distinguished algorithms that decompose into aggregable statistics from those that don't. Does K-means's ASSIGN step (finding each point's nearest centroid) require any aggregation at all?
    Solution

    No — assignment is a pure per-point computation against the current (already-known) centroids, needing no aggregation and no cross-machine communication whatsoever. Only the RECOMPUTE step aggregates. K-means is actually two different kinds of step glued together, one trivially parallel and one requiring combination, which is worth noticing precisely because they're so often described as a single undifferentiated "iteration."

6.4 · NAIVE BAYES: EMBARRASSINGLY PARALLEL

Training Is Just Counting

Will a new Hub E order get a high rating? Naive Bayes answers with nothing more sophisticated than counts — which is exactly why "training" this model distributes for free.

Predict "high rating" (4–5 stars) versus "low" (1–3) from which hub an order came from. Sections 1.1's three missing-rating orders (#3, #7, #11) can't train or be predicted against a label they don't have — 13 of 16 orders remain.

what "training" actually computes prior: P(high) = 10/13 = 0.769, P(low) = 3/13 = 0.231 per-hub, per-label counts (Laplace-smoothed against 3 possible hubs): P(Hub E | high) = (4+1)/(10+3) = 0.385 P(Hub E | low) = (0+1)/(3+3) = 0.167 prediction for a new Hub E order: score(high) = 0.769 × 0.385 = 0.296 score(low) = 0.231 × 0.167 = 0.038 → predict HIGH, with normalized confidence 0.296÷(0.296+0.038) = 88.5%

Every quantity above is a count, or a ratio of counts. "Training" a Naive Bayes classifier isn't an iterative search like Section 6.2's gradient descent — it's tallying, once, and dividing.

Worked Example · Counting in Parallel
local hub counts per block, high-rated orders only
blockHub NHub SHub E
Block 1 (orders 1–6)211
Block 2 (orders 7–11)101
Block 3 (orders 12–16)112
sum (global count)424

Identical shape to Section 3.2's restaurant-count MapReduce job — each block counts locally, a global sum combines them, and the "model" is nothing but this table plus the equally simple low-rating version of it.

why "naive," and why it barely matters here

Naive Bayes assumes every feature is independent given the class — hub tells you nothing extra once you already know the rating class, which is rarely literally true (a restaurant's typical rating and its hub might correlate). The independence assumption is what makes the counting decompose so cleanly: with it, P(features|class) is just a product of separately-countable per-feature probabilities. Drop the assumption for a more realistic model and the clean parallel-counting property usually goes with it.

pitfalls
  • "Naive Bayes needs iterative training like gradient descent." It needs exactly one pass over the data to build the counts, then a single division per probability. There's no learning rate, no convergence check, no epochs.
  • "Smoothing is optional polish." Without it, any hub with zero LOW-rated orders in training (none appear for Hub E here) gets P(Hub E|low)=0 outright, which would make ANY future Hub E order impossible to classify as low, no matter how much other evidence suggested it. Laplace smoothing (the "+1" in this section's formula) exists specifically to prevent one empty count from becoming an absolute, unbreakable rule.
  • "More training data always means a better model here." More data means better-estimated counts, but the INDEPENDENCE ASSUMPTION itself doesn't get more true with more rows — if hub and restaurant genuinely aren't independent given rating, no amount of additional counting fixes that structural mismatch.
Practice
  1. Using this section's counts, compute P(Hub S | high) and P(Hub S | low) with Laplace smoothing.
    Solution

    P(Hub S|high) = (2+1)/(10+3) = 3/13 ≈ 0.231. P(Hub S|low) = (2+1)/(3+3) = 3/6 = 0.5 — matching the worked example's stated values exactly.

  2. Classify a new Hub S order using this section's priors and the Hub S probabilities above. Which class wins?
    Solution

    score(high) = 0.769 × 0.231 ≈ 0.178. score(low) = 0.231 × 0.5 ≈ 0.116. High still wins, but by a much smaller margin than the Hub E case (normalized confidence ≈ 60.6% instead of 88.5%) — Hub S's orders are relatively more associated with low ratings than Hub E's, and the model's confidence reflects that.

  3. If Block 2 had actually gone offline before reporting its local counts (1 high at Hub N, 1 high at Hub E, 1 low at Hub S), how would that change the global counts, and is the resulting model simply "less accurate" or something worse?
    Solution

    Global high counts would read N=3,S=1,E=3 instead of N=4,S=2,E=4 — not just less accurate, systematically biased toward whichever blocks DID report, since the missing block's specific rows are silently absent rather than randomly sampled out. This is the same "missing partition contribution" failure mode flagged in Section 6.3's practice, now applied to Naive Bayes counting instead of K-means recomputation.

  4. Section 6.1 asked whether an algorithm's inner step reduces to aggregable statistics. Does Naive Bayes's PREDICTION step (classifying one new order) need any cross-machine aggregation at all?
    Solution

    No — once the counts (the "model") are computed and available, classifying a single new order is a handful of multiplications against already-known probabilities, needing no further access to the training data or any other machine. Training aggregates; prediction, given a trained model, doesn't.

6.5 · EVALUATING MODELS AT SCALE

Splitting Data You Can't See All At Once

"Hold out 20% for testing" sounds like one line of code. On data spread across three machines, it's a question about who gets to decide which 20%.

A train/test split needs to behave like a fair, random sample of the whole dataset. The easiest thing to actually implement — each machine holding out its own last 20% — isn't that, and the difference is exactly Chapter 5's ordering problem wearing a different hat.

Worked Example · Two Ways to Get "80/20"
Naive: first 80% by arrival order

Train = orders #1–13 (in arrival order, skipping #10). Test = orders #14, 15, 16 — whichever three happened to arrive last. The test set is a CONTIGUOUS tail of the stream, not a sample of it.

Shuffled: random 80/20 across all rows

Test = orders #3, 6, 7 — scattered across the entire arrival window, no relationship to when anything happened. Getting here requires touching and reshuffling rows from every machine, not just trimming each one's own tail.

On these 15 rows the two test sets happen to look similarly balanced by hub — small-sample luck, not a guarantee. The real risk isn't visible in fifteen rows at all: at citywide volume, if order characteristics genuinely drift over the course of a rush (later orders skewing toward different hubs, larger group orders, whatever pattern actually holds), a contiguous tail-as-test-set inherits that drift wholesale, and a model evaluated against it gets judged on a systematically unrepresentative slice.

why the shuffle itself is a distributed operation

Getting orders #3, 6, and 7 into one test set means comparing a random draw against rows sitting on whichever machine holds them — #3 and #6 are in Block 1, #7 is in Block 2 (Section 2.1). No single machine can decide the global 80/20 split alone; it needs either a coordinated random assignment communicated to every partition, or a full shuffle (Section 3's shuffle-cost lessons apply directly) before any splitting happens at all.

The Same Problem, K Times: Cross-Validation

K-fold cross-validation repeats the split K times, holding out a different fold each round and training on the rest, then averages the K evaluation scores. It's not a different problem from the single 80/20 split — it's the identical distributed-shuffle requirement, paid K times instead of once, specifically so a model's evaluation doesn't depend on the luck of one particular split.

pitfalls
  • "Any 80/20 split is as good as any other." A split correlated with an ordering the data actually carries (arrival time, here) can silently bias evaluation. A split should be exchangeable with any other equally-sized random split — "could this test set have been any other 20%, with equal probability" is the real bar.
  • "Cross-validation is only about getting a more precise score." It's also about not trusting a single split's luck — a model that scores well on one particular held-out 20% might score differently on another, and K-fold surfaces that variance directly instead of hiding it behind one number.
  • "Shuffling is free once you decide to do it." It's exactly Section 3's shuffle cost, paid specifically to produce a fair split — a real, measurable expense that naive contiguous splitting avoids by being wrong for free.
Practice
  1. Would a train/test split based on HUB (all of Hub N's orders as test, everyone else as train) share the naive time-ordered split's core problem?
    Solution

    Yes, the identical shape of problem — the test set is defined by a characteristic (hub) that might itself correlate with the thing being predicted, rather than being an unbiased random sample. Any split correlated with a real attribute of the data risks this, not just time.

  2. In 5-fold cross-validation on these 15 rows, roughly how many rows would each fold hold out?
    Solution

    15÷5 = 3 rows per fold — five rounds, each training on the other 12 and testing on a different 3, cycling through until every row has been in exactly one test fold.

  3. Section 2.3 showed consistent hashing distributing keys without regard to any business meaning. Could a hash-of-order-id assignment be used to build a fair random train/test split?
    Solution

    Yes, cleanly — hash each order id, and route it to "train" or "test" based on the hash value (say, below some threshold goes to test). Since the hash has no relationship to arrival order, hub, or any other real attribute (Section 2.3's whole point), this produces exactly the "any 20% with equal probability" property this section's pitfall box asked for, and can be computed independently on each partition with no coordination beyond agreeing on the hash function and threshold.

  4. A model trained with Section 6.2's gradient descent is evaluated only on the naive tail-of-stream test set (orders #14–16). Its MSE looks great. Should that result be trusted?
    Solution

    Not fully — a good score on a non-representative test set only tells you the model fits that particular slice, which this section already flagged as potentially unlike the data as a whole. The fix isn't necessarily distrust of the model itself, but re-evaluating on a properly shuffled (or cross-validated) split before trusting the number enough to act on it.

CLOSING · CHEAT SHEET

Chapter 6, One Page

6.1 · Why Distributed ML Differs

Data parallelism (model fits, data doesn't) vs model parallelism (model itself doesn't fit)

Distributable = decomposes into aggregable statistics (sums, counts, gradients)

6.2 · Distributed Gradient Descent

Each machine's local gradient is correct for ITS rows only

Combine by weighting by row count — unweighted average is wrong unless partitions are equal-sized

6.3 · K-Means at Scale

Assign step: local, free, no communication · Recompute step: sum-and-count combiner, networked

Same algorithm distributed or not — only the recompute step's implementation changes

6.4 · Naive Bayes

Training = counting, once, per partition, then summed — no iteration

Independence assumption is WHY it parallelizes so cleanly

Smoothing prevents one zero count from becoming an absolute rule

6.5 · Evaluating at Scale

A fair split must be exchangeable with any other same-sized random split

Contiguous "first 80%" risks inheriting any real ordering pattern in the data

Cross-validation = the same shuffle-and-split cost, paid K times

CLOSING · SELF-TEST

Mixed Review

Eight questions, deliberately out of section order.

  1. Two machines hold 8 and 8 rows. Does averaging their local gradients without weighting give the correct combined gradient?
    Solution

    Yes — with equal partition sizes, unweighted and weighted averaging compute the same result. The bug only appears when partitions differ in size.

  2. Which K-means step needs no communication between machines at all: assign or recompute?
    Solution

    Assign — each point only needs comparison against the already-known current centroids, entirely local. Recompute needs every machine's partial sums combined.

  3. A Naive Bayes model has zero training examples of "low-rated Hub E orders." Without smoothing, what happens to any future Hub E order's probability of being classified low?
    Solution

    It becomes exactly zero, permanently, regardless of any other evidence — an unsmoothed zero count makes an outcome flatly impossible rather than merely unlikely. Laplace smoothing exists specifically to prevent this.

  4. Why does a closed-form (matrix-inversion) solution to linear regression resist data-parallel distribution better than gradient descent does?
    Solution

    It needs the entire dataset assembled into one matrix before any single operation can proceed, unlike gradient descent's per-step reliance on locally-computable, aggregable partial sums.

  5. A train/test split is built by hashing order id and routing below a threshold to test. Is this split's fairness affected by which hub, restaurant, or arrival time each order has?
    Solution

    No — a well-chosen hash has no relationship to any of those attributes, which is exactly the property that makes it a fair substitute for a true random shuffle.

  6. A billion-parameter model needs to be split across machines because no single machine's memory can hold it. Is this data parallelism or model parallelism?
    Solution

    Model parallelism — the constraint is the model's size, not the data's, the opposite bottleneck from Chapter 6's CityCourier examples.

  7. In distributed K-means, Block 3 reports its partial sum and count for cluster 2 twice due to a retried message. What happens to the resulting centroid if the driver isn't careful?
    Solution

    Cluster 2's centroid would be computed with Block 3's contribution counted twice, pulling the mean toward Block 3's points more than it should — a double-counting problem structurally identical to Section 5.6's duplicate-message issue, just occurring in a training aggregation instead of a revenue count.

  8. Does 5-fold cross-validation require 5× as much raw data as a single 80/20 split?
    Solution

    No — it reuses the same dataset five times, each round holding out a different fold. It costs roughly 5× the TRAINING compute (fitting five separate models), not five times the data.

FURTHER READING

If You Want the Long Version

  • Mining of Massive Datasets — Leskovec, Rajaraman & Ullman. Its machine learning chapters cover distributed K-means, Naive Bayes, and gradient-based methods (Sections 6.2–6.4) with the same MapReduce-flavoured lens this chapter used throughout.
  • Spark: The Definitive Guide — Chambers & Zaharia. MLlib's actual implementations of everything in this chapter, including how partition-size weighting (Section 6.2) and cross-validation (Section 6.5) are handled in production code.
  • Designing Data-Intensive Applications — Martin Kleppmann. Not ML-specific, but its treatment of what makes a computation decomposable (Section 6.1's core question) underlies why some algorithms distribute cleanly and others resist it.

Chapter 6 of 7 · CSUE301 Big Data Analytics · builds on Chapter 3's combiner pattern (Section 3.3) and Chapter 1's imbalance lesson (Section 1.5).
Next → Chapter 7, Scalable Visualization and Analytics.