-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
166 lines (136 loc) · 5.83 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Race Horse Prediction</title>
<meta charset="utf-8">
<meta name="description" content="Race Horse Prediction">
<meta name="author" content="Ian McCarthy">
<meta name="generator" content="slidify" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link rel="stylesheet" href="libraries/frameworks/io2012/css/default.css" media="all" >
<link rel="stylesheet" href="libraries/frameworks/io2012/css/phone.css"
media="only screen and (max-device-width: 480px)" >
<link rel="stylesheet" href="libraries/frameworks/io2012/css/slidify.css" >
<link rel="stylesheet" href="libraries/highlighters/highlight.js/css/tomorrow.css" />
<base target="_blank"> <!-- This amazingness opens all links in a new tab. --> <link rel=stylesheet href="./assets/css/ribbons.css"></link>
<!-- Grab CDN jQuery, fall back to local if offline -->
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.min.js"></script>
<script>window.jQuery || document.write('<script src="libraries/widgets/quiz/js/jquery.js"><\/script>')</script>
<script data-main="libraries/frameworks/io2012/js/slides"
src="libraries/frameworks/io2012/js/require-1.0.8.min.js">
</script>
</head>
<body style="opacity: 0">
<slides class="layout-widescreen">
<!-- LOGO SLIDE -->
<slide class="title-slide segue nobackground">
<hgroup class="auto-fadein">
<h1>Race Horse Prediction</h1>
<h2>Using linear regression to predict horse race outcomes</h2>
<p>Ian McCarthy<br/>SAP Consultant</p>
</hgroup>
<article></article>
</slide>
<!-- SLIDES -->
<slide class="class" id="id" style="background:;">
<hgroup>
<h2>Horse racing prediction</h2>
</hgroup>
<article data-timings="">
<p>I would like to take this opportunity to demonstrate, using Slidify, one simple model for making race predictions, which is an area rich in data!</p>
<h2>The method used</h2>
<p>Successful horse racing betters are able to 'read the form' of diferent horses and make predictions on how they will run against each another.</p>
<p>I have taken a more automated approach that uses a simple linear regression fitted to a data set of all 2013 Australian horse racing events.</p>
<p>It makes a prediction of how long it will take each horse to run a future race using its last race performance and the characteristics of the future race . Comparing the times of all horses in the race allows their finishing position to be predicted.</p>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="class" id="id" style="background:;">
<hgroup>
<h2>The model's input variables</h2>
</hgroup>
<article data-timings="">
<p>The input variables (delta of last race and future race) used in the linear regression model are as follows:</p>
<ul>
<li>Race distance - of course the farther the race the longer it takes to run.</li>
<li>The Going - how hard (faster) or soft (slower) a track is.</li>
<li>Weight - each horse carries a jockey and often an additional weight handicap</li>
</ul>
<p>This is the general form of the R code for fitting the model and then predicting a horse's finish time:</p>
<pre><code class="r">prediction_model <- lm(finish_time ~ distance + weight + going, data = aust_races_2013)
predicted_time <- (prediction_model, data = horses_last_race)
</code></pre>
<p>The outcome of this is not shown.</p>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="class" id="id" style="background:;">
<hgroup>
<h2>The effect of distance on average winning times</h2>
</hgroup>
<article data-timings="">
<pre><code class="r">dist <- seq(1000, 2000, by=100)
time <- 0.070*dist
plot(dist, time, main="Average winning race times by distance",
xlab="Race Distance (m)", ylab="Time (s)", pch=19)
abline(lm(time~dist), col="red")
</code></pre>
<p><img src="assets/fig/unnamed-chunk-2.png" alt="plot of chunk unnamed-chunk-2"> </p>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="class" id="id" style="background:;">
<hgroup>
<h2>The web app</h2>
</hgroup>
<article data-timings="">
<p>I have created a web app based on the described model which can be viewed here: <a href="https://ianmccarthy.shinyapps.io/HorseRace/">https://ianmccarthy.shinyapps.io/HorseRace/</a> (it may be necessary to zoom out to see all the input boxes).</p>
<p>The web app can make predictions for up to 5 horses, the race prediction changes as data is changed.</p>
<p>I hope you enjoy the app.
Thank you.</p>
</article>
<!-- Presenter Notes -->
</slide>
<slide class="backdrop"></slide>
</slides>
<div class="pagination pagination-small" id='io2012-ptoc' style="display:none;">
<ul>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=1 title='Horse racing prediction'>
1
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=2 title='The model's input variables'>
2
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=3 title='The effect of distance on average winning times'>
3
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=4 title='The web app'>
4
</a>
</li>
</ul>
</div> <!--[if IE]>
<script
src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js">
</script>
<script>CFInstall.check({mode: 'overlay'});</script>
<![endif]-->
</body>
<!-- Load Javascripts for Widgets -->
<!-- LOAD HIGHLIGHTER JS FILES -->
<script src="libraries/highlighters/highlight.js/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<!-- DONE LOADING HIGHLIGHTER JS FILES -->
</html>