I promise this is the last part of **The Darcey Coefficient**, having gone through linear regression, neural networks and refining the accuracy of the prediction, it was only fair I ran the linear regressions against some live scores to see how it performed.

If you want to read the first four parts (yes four, I’m sorry) then they are all here.

### Week 5 Scores

As ever the Ultimate Strictly website is on the ball, the scores are all in.

Judges scores | |||||
---|---|---|---|---|---|

Couple | Craig | Darcey | Len | Bruno | Total |

Robert & Oksana | 6 | 8 | 8 | 7 | 29 |

Lesley & Anton | 5 | 6 | 7 | 6 | 24 |

Greg & Natalie | 4 | 6 | 7 | 7 | 24 |

Anastacia & Gorka* | 7 | 7 | 8 | 8 | 30 |

Louise & Kevin | 8 | 8 | 8 | 9 | 33 |

Ed & Katya | 2 | 6 | 6 | 4 | 18 |

Ore & Joanne | 9 | 9 | 9 | 9 | 36 |

Daisy & Aljaž | 8 | 8 | 8 | 8 | 32 |

Danny & Oti | 8 | 9 | 9 | 9 | 35 |

Claudia & AJ | 8 | 7 | 8 | 9 | 32 |

So we have data and the expected result. The real question is how well the regressions perform. Time to rig up some code.

### Coding the Test

As the spreadsheet did the work I don’t need to reinvent the wheel. All I need is the numbers and put them in a function.

First there’s the Craig -> Darcey regression.

(defn predict-score-from-craig [x-score] (+ 3.031 (* 0.6769 x-score)))

And then there’s the All Judges -> Darcey regression.

(defn predict-darcey-from-all [x-score] (- (* 0.2855 x-score) 1.2991))

As the predictions will not come out as integers I need a function to round up or down as required. So I nabbed this one from a StackOverflow comment as it works nicely.

(defn round2 [precision d] (let [factor (Math/pow 10 precision)] (/ (Math/round (* d factor)) factor)))

Finally I need the data, a vector of vectors with Craig, Len, Bruno and Darcey’s score. I leave Darcey’s actual score in so have something to test against. What the predicted score was and what the actual score was.

;; vectors of scores, [craig, len, bruno, darcey's actual score] (def wk14-scores [[6 8 7 8] [5 7 6 6] [4 7 7 6] [7 8 8 7] [8 8 9 8] [2 6 4 6] [9 9 9 9] [8 8 8 8] [8 9 9 9] [8 8 9 7]])

### Predicting Against Craig’s Scores

The difference between Craig and Darcey’s scores can fluctuate depending on the judges comments. The dance with Ed and Katya is a good example, Craig scored 2 and Darcey scored 6, so I’m not expecting great things from this regression, but as it was our starting point let’s test it.

(defn predict-from-craig [scores] (map (fn [score] (let [craig (first score) expected (last score) predicted (round2 0 (predict-score-from-craig (first score)))] (println "Craig: " craig "Predicted: " predicted "Actual: " expected "Correct: " (if (= (int predicted) expected) true false)))) scores))

When run it gives us the following predictions:

strictlylinearregression.core> (predict-from-craig wk14-scores) Craig: 6 Predicted: 7.0 Actual: 8 Correct: false Craig: 5 Predicted: 6.0 Actual: 6 Correct: true Craig: 4 Predicted: 6.0 Actual: 6 Correct: true Craig: 7 Predicted: 8.0 Actual: 7 Correct: false Craig: 8 Predicted: 8.0 Actual: 8 Correct: true Craig: 2 Predicted: 4.0 Actual: 6 Correct: false Craig: 9 Predicted: 9.0 Actual: 9 Correct: true Craig: 8 Predicted: 8.0 Actual: 8 Correct: true Craig: 8 Predicted: 8.0 Actual: 9 Correct: false Craig: 8 Predicted: 8.0 Actual: 7 Correct: false

Okay, 50/50 but this doesn’t come as a surprise. With more scores (ie Len and Bruno) then we might hit the mark better.

### Does The Full Judges Scores Improve the Prediction?

Let’s find out, here’s the code:

(defn predict-from-judges [scores] (map (fn [score] (let [judges (reduce + (take 3 score)) expected (last score) predicted (round2 0 (predict-score-from-all judges))] (println "Judges: " judges "Predicted: " predicted "Actual: " expected "Correct: " (if (= (int predicted) expected) true false)))) scores))

By taking the sum of the first three scores (Craig, Len and Bruno) that total is then run against the **predict-score-from-all** function. How it performs is anyone’s guess right now.

strictlylinearregression.core> (predict-from-judges wk14-scores) Judges: 21 Predicted: 5.0 Actual: 8 Correct: false Judges: 18 Predicted: 4.0 Actual: 6 Correct: false Judges: 18 Predicted: 4.0 Actual: 6 Correct: false Judges: 23 Predicted: 5.0 Actual: 7 Correct: false Judges: 25 Predicted: 6.0 Actual: 8 Correct: false Judges: 12 Predicted: 2.0 Actual: 6 Correct: false Judges: 27 Predicted: 6.0 Actual: 9 Correct: false Judges: 24 Predicted: 6.0 Actual: 8 Correct: false Judges: 26 Predicted: 6.0 Actual: 9 Correct: false Judges: 25 Predicted: 6.0 Actual: 7 Correct: false

Well that’s interesting, we get much lower expected scores based on the combined scores. Every prediction was wrong, that would hurt if you were betting on it.

All of this leads us to a conclusion, if you want to predict what Darcey’s score is going to be then look at what Craig does first.

That’s that, case is now closed.