-
Notifications
You must be signed in to change notification settings - Fork 7
/
output_model.txt
17336 lines (17308 loc) · 401 KB
/
output_model.txt
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
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
soccerproject
Neeraj
## Warning: package 'elastic' was built under R version 3.2.2
## url: http://127.0.0.1
## port: 9200
## username: NULL
## password: NULL
## elasticsearch details:
## status: NULL
## name: Mandrill
## Elasticsearch version: 2.0.0
## ES version timestamp: 2015-10-22T08:09:48Z
## lucene version: 5.2.1
## [1] 3910
## [[1]]
## [[1]]$`_index`
## [1] "spainsoccer"
##
## [[1]]$`_type`
## [1] "liga_data"
##
## [[1]]$`_id`
## [1] "56520fb086015e256820a95f"
##
## [[1]]$`_version`
## [1] 1
##
## [[1]]$`_score`
## [1] 1
##
## [[1]]$`_source`
## [[1]]$`_source`$BbAHh
## [1] 0.5
##
## [[1]]$`_source`$HY
## [1] 3
##
## [[1]]$`_source`$HTHG
## [1] 0
##
## [[1]]$`_source`$HR
## [1] 0
##
## [[1]]$`_source`$HTAG
## [1] 0
##
## [[1]]$`_source`$BbAH
## [1] 27
##
## [[1]]$`_source`$BbAvTwo
## [1] 1.75
##
## [[1]]$`_source`$BbMxD
## [1] 3.77
##
## [[1]]$`_source`$AwayTeam
## [1] "Valencia"
##
## [[1]]$`_source`$BbAvD
## [1] 3.55
##
## [[1]]$`_source`$BbMxA
## [1] 2.15
##
## [[1]]$`_source`$BbAvA
## [1] 2.02
##
## [[1]]$`_source`$HC
## [1] 3
##
## [[1]]$`_source`$BbMxH
## [1] 4
##
## [[1]]$`_source`$Bb1X2
## [1] 41
##
## [[1]]$`_source`$BbAvH
## [1] 3.57
##
## [[1]]$`_source`$WHD
## [1] 3.3
##
## [[1]]$`_source`$IWD
## [1] 3.3
##
## [[1]]$`_source`$WHA
## [1] 2.1
##
## [[1]]$`_source`$IWA
## [1] 2
##
## [[1]]$`_source`$AST
## [1] 4
##
## [[1]]$`_source`$HF
## [1] 19
##
## [[1]]$`_source`$WHH
## [1] 3.6
##
## [[1]]$`_source`$BbMxAHA
## [1] 2.08
##
## [[1]]$`_source`$IWH
## [1] 3.6
##
## [[1]]$`_source`$LBA
## [1] 2
##
## [[1]]$`_source`$BWA
## [1] 2.05
##
## [[1]]$`_source`$BWD
## [1] 3.4
##
## [[1]]$`_source`$BbAvAHH
## [1] 1.83
##
## [[1]]$`_source`$HST
## [1] 3
##
## [[1]]$`_source`$HS
## [1] 8
##
## [[1]]$`_source`$BWH
## [1] 3.5
##
## [[1]]$`_source`$LBH
## [1] 3.6
##
## [[1]]$`_source`$BbAvAHA
## [1] 2.01
##
## [[1]]$`_source`$LBD
## [1] 3.6
##
## [[1]]$`_source`$BbMxTwo
## [1] 1.83
##
## [[1]]$`_source`$VCA
## [1] 2.05
##
## [[1]]$`_source`$AC
## [1] 3
##
## [[1]]$`_source`$FTR
## [1] "D"
##
## [[1]]$`_source`$VCD
## [1] 3.75
##
## [[1]]$`_source`$AF
## [1] 11
##
## [[1]]$`_source`$VCH
## [1] 3.7
##
## [[1]]$`_source`$FTHG
## [1] 0
##
## [[1]]$`_source`$Date
## [1] "22/08/15"
##
## [[1]]$`_source`$AS
## [1] 10
##
## [[1]]$`_source`$AR
## [1] 0
##
## [[1]]$`_source`$BbMxLess
## [1] 2.15
##
## [[1]]$`_source`$AY
## [1] 1
##
## [[1]]$`_source`$Div
## [1] "SP1"
##
## [[1]]$`_source`$PSH
## [1] 3.72
##
## [[1]]$`_source`$B365H
## [1] 3.6
##
## [[1]]$`_source`$BbAvLess
## [1] 2.04
##
## [[1]]$`_source`$PSA
## [1] 2.06
##
## [[1]]$`_source`$B365A
## [1] 2.05
##
## [[1]]$`_source`$B365D
## [1] 3.5
##
## [[1]]$`_source`$BbMxAHH
## [1] 1.9
##
## [[1]]$`_source`$HTR
## [1] "D"
##
## [[1]]$`_source`$PSD
## [1] 3.77
##
## [[1]]$`_source`$BbOU
## [1] 39
##
## [[1]]$`_source`$FTAG
## [1] 0
##
## [[1]]$`_source`$HomeTeam
## [1] "Vallecano"
## [1] 73
## [1] 3910
## [1] "BbAHh" "HY" "HTHG" "HR" "HTAG" "BbAH"
## [7] "BbAvTwo" "BbMxD" "AwayTeam" "BbAvD" "BbMxA" "BbAvA"
## [13] "HC" "BbMxH" "Bb1X2" "BbAvH" "WHD" "IWD"
## [19] "WHA" "IWA" "AST" "HF" "WHH" "BbMxAHA"
## [25] "IWH" "LBA" "BWA" "BWD" "BbAvAHH" "HST"
## [31] "HS" "BWH" "LBH" "BbAvAHA" "LBD" "BbMxTwo"
## [37] "VCA" "AC" "FTR" "VCD" "AF" "VCH"
## [43] "FTHG" "Date" "AS" "AR" "BbMxLess" "AY"
## [49] "Div" "PSH" "B365H" "BbAvLess" "PSA" "B365A"
## [55] "B365D" "BbMxAHH" "HTR" "PSD" "BbOU" "FTAG"
## [61] "HomeTeam" "SJH" "SJA" "SJD" "GBD" "GBA"
## [67] "BSD" "BSH" "BSA" "GBH" "SBA" "SBD"
## [73] "SBH"
Variables
Description
Div
League Division
Date
Match Date (dd/mm/yy)
HomeTeam
Home Team
AwayTeam
Away Team
FTHG
Full Time Home Team Goals
FTAG
Full Time Away Team Goals
FTR
Full Time Result (H=Home Win, D=Draw, A=Away Win)
HTHG
Half Time Home Team Goals
HTAG
Half Time Away Team Goals
HTR
Half Time Result (H=Home Win, D=Draw, A=Away Win)
HS
Home Team Shots
AS
Away Team Shots
HST
Home Team Shots on Target
AST
Away Team Shots on Target
HC
Home Team Corners
AC
Away Team Corners
HF
Home Team Fouls Committed
AF
Away Team Fouls Committed
HY
Home Team Yellow Cards
AY
Away Team Yellow Cards
HR
Home Team Red Cards
AR
Away Team Red Cards
B365H
Bet365 home win odds
B365D
Bet365 draw odds
B365A
Bet365 away win odds
Load the libraries.
##
## Attaching package: 'plyr'
##
## The following object is masked from 'package:lubridate':
##
## here
##
## The following object is masked from 'package:elastic':
##
## count
##
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:plyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
##
## The following objects are masked from 'package:lubridate':
##
## intersect, setdiff, union
##
## The following objects are masked from 'package:elastic':
##
## count, explain
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
##
##
## Attaching package: 'data.table'
##
## The following objects are masked from 'package:dplyr':
##
## between, last
##
## The following objects are masked from 'package:lubridate':
##
## hour, mday, month, quarter, wday, week, yday, year
##
## The following objects are masked from 'package:reshape2':
##
## dcast, melt
##
##
##
## Rmetrics Package fBasics
## Analysing Markets and calculating Basic Statistics
## Copyright (C) 2005-2014 Rmetrics Association Zurich
## Educational Software for Financial Engineering and Computational Science
## Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
## https://www.rmetrics.org --- Mail to: [email protected]
## Loading required package: gplots
##
## Attaching package: 'gplots'
##
## The following object is masked from 'package:stats':
##
## lowess
##
## Loading required package: MASS
##
## Attaching package: 'MASS'
##
## The following object is masked from 'package:dplyr':
##
## select
##
## Loading required package: msm
## Loading required package: polycor
## Loading required package: mvtnorm
## Loading required package: sfsmisc
##
## Attaching package: 'sfsmisc'
##
## The following object is masked from 'package:data.table':
##
## last
##
## The following object is masked from 'package:dplyr':
##
## last
##
## Loading required package: cluster
## Loading required package: lattice
##
## Attaching package: 'e1071'
##
## The following objects are masked from 'package:timeDate':
##
## kurtosis, skewness
##
## randomForest 4.6-10
## Type rfNews() to see new features/changes/bug fixes.
##
## Attaching package: 'randomForest'
##
## The following object is masked from 'package:timeSeries':
##
## outlier
##
## The following object is masked from 'package:dplyr':
##
## combine
##
## Loading required package: survival
##
## Attaching package: 'survival'
##
## The following object is masked from 'package:caret':
##
## cluster
##
## Loading required package: splines
## Loading required package: parallel
## Loaded gbm 2.1.1
##
## Attaching package: 'car'
##
## The following object is masked from 'package:fBasics':
##
## densityPlot
we will change the date variable from char to date format.
## 'data.frame': 3910 obs. of 25 variables:
## $ Div : chr "SP1" "SP1" "SP1" "SP1" ...
## $ Date : chr "22/08/15" "23/08/15" "29/08/15" "11/09/15" ...
## $ HomeTeam: chr "Vallecano" "Ath Bilbao" "Sociedad" "Levante" ...
## $ AwayTeam: chr "Valencia" "Barcelona" "Sp Gijon" "Sevilla" ...
## $ FTHG : int 0 0 0 1 1 1 0 1 0 3 ...
## $ FTAG : int 0 1 0 1 0 3 0 0 0 1 ...
## $ FTR : chr "D" "A" "D" "D" ...
## $ HTHG : int 0 0 0 0 1 1 0 1 0 1 ...
## $ HTAG : int 0 0 0 1 0 2 0 0 0 1 ...
## $ HTR : chr "D" "D" "D" "A" ...
## $ HS : int 8 8 12 14 9 8 22 12 14 16 ...
## $ AS : int 10 10 7 8 15 14 3 18 9 9 ...
## $ HST : int 3 2 1 4 2 2 5 5 4 7 ...
## $ AST : int 4 4 2 3 3 8 1 3 2 4 ...
## $ HC : int 3 2 6 5 2 5 7 11 4 11 ...
## $ AC : int 3 4 4 4 4 4 1 3 2 4 ...
## $ HF : int 19 16 10 12 12 12 17 19 15 12 ...
## $ AF : int 11 11 15 8 9 10 15 20 19 9 ...
## $ HY : int 3 3 4 3 4 2 4 3 3 0 ...
## $ AY : int 1 3 5 3 3 2 2 3 4 4 ...
## $ HR : int 0 0 0 0 1 1 0 0 0 0 ...
## $ AR : int 0 0 0 0 0 0 1 0 0 0 ...
## $ B365A : num 2.05 1.5 4.5 1.75 3.2 3.5 6.5 7.5 3 3.2 ...
## $ B365H : num 3.6 6.5 1.85 4.75 2.3 2.1 1.5 1.45 2.4 2.3 ...
## $ B365D : num 3.5 4.33 3.5 3.75 3.3 3.5 4.33 4.5 3.2 3.3 ...
## Div Date HomeTeam
## Length:3910 Length:3910 Length:3910
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
## AwayTeam FTHG FTAG FTR
## Length:3910 Min. :0.000 Min. :0.000 Length:3910
## Class :character 1st Qu.:1.000 1st Qu.:0.000 Class :character
## Mode :character Median :1.000 Median :1.000 Mode :character
## Mean :1.569 Mean :1.131
## 3rd Qu.:2.000 3rd Qu.:2.000
## Max. :9.000 Max. :8.000
## HTHG HTAG HTR HS
## Min. :0.0000 Min. :0.0 Length:3910 Min. : 1.00
## 1st Qu.:0.0000 1st Qu.:0.0 Class :character 1st Qu.:11.00
## Median :0.0000 Median :0.0 Mode :character Median :14.00
## Mean :0.7031 Mean :0.5 Mean :14.13
## 3rd Qu.:1.0000 3rd Qu.:1.0 3rd Qu.:17.00
## Max. :6.0000 Max. :5.0 Max. :37.00
## AS HST AST HC
## Min. : 0.00 Min. : 0.000 Min. : 0.000 Min. : 0.000
## 1st Qu.: 8.00 1st Qu.: 3.000 1st Qu.: 2.000 1st Qu.: 4.000
## Median :11.00 Median : 5.000 Median : 4.000 Median : 6.000
## Mean :11.17 Mean : 5.105 Mean : 3.913 Mean : 6.018
## 3rd Qu.:14.00 3rd Qu.: 7.000 3rd Qu.: 5.000 3rd Qu.: 8.000
## Max. :39.00 Max. :20.000 Max. :16.000 Max. :20.000
## AC HF AF HY
## Min. : 0.000 Min. : 0.00 Min. : 1.0 Min. :0.000
## 1st Qu.: 3.000 1st Qu.:13.00 1st Qu.:12.0 1st Qu.:1.000
## Median : 4.000 Median :16.00 Median :16.0 Median :2.000
## Mean : 4.497 Mean :15.96 Mean :15.8 Mean :2.436
## 3rd Qu.: 6.000 3rd Qu.:19.00 3rd Qu.:19.0 3rd Qu.:3.000
## Max. :15.000 Max. :37.00 Max. :36.0 Max. :8.000
## AY HR AR B365A
## Min. :0.000 Min. :0.0000 Min. :0.0000 Min. : 1.080
## 1st Qu.:2.000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.: 2.700
## Median :3.000 Median :0.0000 Median :0.0000 Median : 3.500
## Mean :2.739 Mean :0.1565 Mean :0.1982 Mean : 4.934
## 3rd Qu.:4.000 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.: 5.000
## Max. :9.000 Max. :3.0000 Max. :4.0000 Max. :41.000
## B365H B365D
## Min. : 1.040 Min. : 2.50
## 1st Qu.: 1.670 1st Qu.: 3.25
## Median : 2.100 Median : 3.40
## Mean : 2.616 Mean : 3.95
## 3rd Qu.: 2.600 3rd Qu.: 3.80
## Max. :26.000 Max. :17.00
## Div Date HomeTeam AwayTeam FTHG FTAG FTR HTHG
## 0 0 0 0 0 0 0 0
## HTAG HTR HS AS HST AST HC AC
## 0 0 0 0 0 0 0 0
## HF AF HY AY HR AR B365A B365H
## 0 0 0 0 0 0 0 0
## B365D
## 0
The summary shows we do not have ANY missing values, which is a good sign.
## B365H HY HF HR AST
## B365H 1.00000000 0.13215325 0.10147804 0.04621253 0.34336354
## HY 0.13215325 1.00000000 0.34115254 0.07603195 0.09276903
## HF 0.10147804 0.34115254 1.00000000 0.08913677 0.07104472
## HR 0.04621253 0.07603195 0.08913677 1.00000000 0.12957502
## AST 0.34336354 0.09276903 0.07104472 0.12957502 1.00000000
## AS 0.32188312 0.08525692 0.11306150 0.11678856 0.67359755
## AF -0.19637023 0.01582631 0.21452114 0.03538310 -0.09370127
## FTAG 0.30989615 0.08648208 0.01859993 0.13906692 0.53902726
## AY -0.11271186 0.14810842 0.05208296 0.08037398 -0.05764811
## AC 0.17265169 0.01240168 0.01469868 0.04034878 0.25356915
## HC -0.21976070 -0.08718800 -0.16138520 -0.05671685 -0.12136288
## HTAG 0.20686395 0.09306622 -0.02144872 0.08190902 0.33950227
## AR -0.04413377 0.05799487 0.03925423 0.07945424 -0.10119154
## HS -0.30691791 -0.10474087 -0.17814171 -0.13252567 -0.14729281
## B365D 0.09765003 -0.14344286 -0.22682825 -0.04589713 -0.04547578
## B365A -0.37734715 -0.20103995 -0.24875693 -0.06591657 -0.21736807
## HST -0.28286141 -0.13718228 -0.14784480 -0.12300941 -0.13698328
## HTHG -0.18110856 -0.09826400 -0.04179785 -0.03848829 -0.03722421
## FTHG -0.24800411 -0.14343589 -0.12300575 -0.09378228 -0.08757578
## AS AF FTAG AY AC
## B365H 0.32188312 -0.196370228 0.309896151 -0.112711865 0.172651689
## HY 0.08525692 0.015826307 0.086482082 0.148108417 0.012401677
## HF 0.11306150 0.214521136 0.018599926 0.052082956 0.014698682
## HR 0.11678856 0.035383096 0.139066921 0.080373985 0.040348778
## AST 0.67359755 -0.093701268 0.539027259 -0.057648112 0.253569152
## AS 1.00000000 -0.111275633 0.267714004 -0.073649459 0.426966796
## AF -0.11127563 1.000000000 -0.046964111 0.300007030 -0.110290336
## FTAG 0.26771400 -0.046964111 1.000000000 -0.026042533 -0.006963058
## AY -0.07364946 0.300007030 -0.026042533 1.000000000 -0.039976198
## AC 0.42696680 -0.110290336 -0.006963058 -0.039976198 1.000000000
## HC -0.21442328 -0.002575533 -0.008396810 0.042960125 -0.183623381
## HTAG 0.11476458 -0.003962135 0.698577737 -0.007243269 -0.081037530
## AR -0.12660181 0.068808679 -0.070896802 0.032512935 -0.086186201
## HS -0.25394744 0.034103913 -0.025088148 0.037783252 -0.218843129
## B365D -0.08994141 -0.148239733 -0.042341453 -0.067785096 -0.043694122
## B365A -0.25819489 -0.024701519 -0.190630223 -0.008858044 -0.131061895
## HST -0.18888688 -0.023915624 -0.060199423 -0.004208289 -0.134362560
## HTHG -0.01412818 -0.075262280 -0.063424101 -0.026820207 0.064341655
## FTHG -0.08228505 -0.066318531 -0.063792873 -0.036728767 -0.013019559
## HC HTAG AR HS B365D
## B365H -0.219760696 0.206863949 -0.04413377 -0.30691791 0.09765003
## HY -0.087188001 0.093066218 0.05799487 -0.10474087 -0.14344286
## HF -0.161385202 -0.021448721 0.03925423 -0.17814171 -0.22682825
## HR -0.056716850 0.081909020 0.07945424 -0.13252567 -0.04589713
## AST -0.121362878 0.339502268 -0.10119154 -0.14729281 -0.04547578
## AS -0.214423285 0.114764584 -0.12660181 -0.25394744 -0.08994141
## AF -0.002575533 -0.003962135 0.06880868 0.03410391 -0.14823973
## FTAG -0.008396810 0.698577737 -0.07089680 -0.02508815 -0.04234145
## AY 0.042960125 -0.007243269 0.03251294 0.03778325 -0.06778510
## AC -0.183623381 -0.081037530 -0.08618620 -0.21884313 -0.04369412
## HC 1.000000000 0.051929143 0.03667052 0.45092710 0.08835332
## HTAG 0.051929143 1.000000000 -0.00907130 0.07028817 -0.02009578
## AR 0.036670518 -0.009071300 1.00000000 0.11936717 -0.04315774
## HS 0.450927095 0.070288168 0.11936717 1.00000000 0.20642606
## B365D 0.088353323 -0.020095782 -0.04315774 0.20642606 1.00000000
## B365A 0.188283528 -0.122089996 -0.01586220 0.33816827 0.85304120
## HST 0.269692200 0.028255561 0.10161076 0.67556933 0.28374686
## HTHG -0.067986334 -0.018854860 0.04378213 0.11900424 0.21802684
## FTHG -0.003601331 0.005624038 0.11347436 0.27693871 0.32141443
## B365A HST HTHG FTHG
## B365H -0.377347150 -0.282861412 -0.18110856 -0.248004111
## HY -0.201039948 -0.137182279 -0.09826400 -0.143435888
## HF -0.248756933 -0.147844803 -0.04179785 -0.123005750
## HR -0.065916571 -0.123009415 -0.03848829 -0.093782284
## AST -0.217368066 -0.136983281 -0.03722421 -0.087575782
## AS -0.258194894 -0.188886881 -0.01412818 -0.082285048
## AF -0.024701519 -0.023915624 -0.07526228 -0.066318531
## FTAG -0.190630223 -0.060199423 -0.06342410 -0.063792873
## AY -0.008858044 -0.004208289 -0.02682021 -0.036728767
## AC -0.131061895 -0.134362560 0.06434166 -0.013019559
## HC 0.188283528 0.269692200 -0.06798633 -0.003601331
## HTAG -0.122089996 0.028255561 -0.01885486 0.005624038
## AR -0.015862199 0.101610757 0.04378213 0.113474362
## HS 0.338168266 0.675569328 0.11900424 0.276938707
## B365D 0.853041202 0.283746863 0.21802684 0.321414430
## B365A 1.000000000 0.394991712 0.29178892 0.415923694
## HST 0.394991712 1.000000000 0.38478958 0.573429460
## HTHG 0.291788917 0.384789578 1.00000000 0.697456144
## FTHG 0.415923694 0.573429460 0.69745614 1.000000000
##
## FTHG FTAG HTHG HTAG HS AS HST AST HC
## FTHG ***** -0.064 0.697 0.006 0.277 -0.082 0.573 -0.088 -0.004
## FTAG <0.001 ***** -0.063 0.699 -0.025 0.268 -0.060 0.539 -0.008
## HTHG <0.001 <0.001 ***** -0.019 0.119 -0.014 0.385 -0.037 -0.068
## HTAG 0.725 <0.001 0.239 ***** 0.070 0.115 0.028 0.340 0.052
## HS <0.001 0.117 <0.001 <0.001 ***** -0.254 0.676 -0.147 0.451
## AS <0.001 <0.001 0.377 <0.001 <0.001 ***** -0.189 0.674 -0.214
## HST <0.001 <0.001 <0.001 0.077 <0.001 <0.001 ***** -0.137 0.270
## AST <0.001 <0.001 0.020 <0.001 <0.001 <0.001 <0.001 ***** -0.121
## HC 0.822 0.600 <0.001 0.001 <0.001 <0.001 <0.001 <0.001 *****
## AC 0.416 0.663 <0.001 <0.001 <0.001 <0.001 <0.001 <0.001 <0.001
## HF <0.001 0.245 0.009 0.180 <0.001 <0.001 <0.001 <0.001 <0.001
## AF <0.001 0.003 <0.001 0.804 0.033 <0.001 0.135 <0.001 0.872
## HY <0.001 <0.001 <0.001 <0.001 <0.001 <0.001 <0.001 <0.001 <0.001
## AY 0.022 0.103 0.094 0.651 0.018 <0.001 0.793 <0.001 0.007
## HR <0.001 <0.001 0.016 <0.001 <0.001 <0.001 <0.001 <0.001 <0.001
## AR <0.001 <0.001 0.006 0.571 <0.001 <0.001 <0.001 <0.001 0.022
## B365A <0.001 <0.001 <0.001 <0.001 <0.001 <0.001 <0.001 <0.001 <0.001
## B365H <0.001 <0.001 <0.001 <0.001 <0.001 <0.001 <0.001 <0.001 <0.001
## B365D <0.001 0.008 <0.001 0.209 <0.001 <0.001 <0.001 0.004 <0.001
## AC HF AF HY AY HR AR B365A B365H
## FTHG -0.013 -0.123 -0.066 -0.143 -0.037 -0.094 0.113 0.416 -0.248
## FTAG -0.007 0.019 -0.047 0.086 -0.026 0.139 -0.071 -0.191 0.310
## HTHG 0.064 -0.042 -0.075 -0.098 -0.027 -0.038 0.044 0.292 -0.181
## HTAG -0.081 -0.021 -0.004 0.093 -0.007 0.082 -0.009 -0.122 0.207
## HS -0.219 -0.178 0.034 -0.105 0.038 -0.133 0.119 0.338 -0.307
## AS 0.427 0.113 -0.111 0.085 -0.074 0.117 -0.127 -0.258 0.322
## HST -0.134 -0.148 -0.024 -0.137 -0.004 -0.123 0.102 0.395 -0.283
## AST 0.254 0.071 -0.094 0.093 -0.058 0.130 -0.101 -0.217 0.343
## HC -0.184 -0.161 -0.003 -0.087 0.043 -0.057 0.037 0.188 -0.220
## AC ***** 0.015 -0.110 0.012 -0.040 0.040 -0.086 -0.131 0.173
## HF 0.358 ***** 0.215 0.341 0.052 0.089 0.039 -0.249 0.101
## AF <0.001 <0.001 ***** 0.016 0.300 0.035 0.069 -0.025 -0.196
## HY 0.438 <0.001 0.322 ***** 0.148 0.076 0.058 -0.201 0.132
## AY 0.012 0.001 <0.001 <0.001 ***** 0.080 0.033 -0.009 -0.113
## HR 0.012 <0.001 0.027 <0.001 <0.001 ***** 0.079 -0.066 0.046
## AR <0.001 0.014 <0.001 <0.001 0.042 <0.001 ***** -0.016 -0.044
## B365A <0.001 <0.001 0.123 <0.001 0.580 <0.001 0.321 ***** -0.377
## B365H <0.001 <0.001 <0.001 <0.001 <0.001 0.004 0.006 <0.001 *****
## B365D 0.006 <0.001 <0.001 <0.001 <0.001 0.004 0.007 <0.001 <0.001
## B365D
## FTHG 0.321
## FTAG -0.042
## HTHG 0.218
## HTAG -0.020
## HS 0.206
## AS -0.090
## HST 0.284
## AST -0.045
## HC 0.088
## AC -0.044
## HF -0.227
## AF -0.148
## HY -0.143
## AY -0.068
## HR -0.046
## AR -0.043
## B365A 0.853
## B365H 0.098
## B365D *****
##
## upper diagonal part contains correlation coefficient estimates
## lower diagonal part contains corresponding p-values
some of the variables are slightly correlated (however it depends on the threshold we choose to subset or accept a particular variable, based on correlation value.) We would as of now, retain all the variables.
further exploring the data
Also the general understanding from the first plot is that Home advantage is significant and plays good role in most cases in determining the winner, as full time results has more home wins than aways.
Creating derived new metrics, by executing operations on various columns, and cleaning data (removing redundant variables).
we will further explore this part through visualization. We see that away team wins when home teams concedes more foul which turns into red cards. The insights are little unexpected as well. First we see that, in away teams win, maximum number of players red carded was 2, where home team accounted for 3 for a lossing cause. Secondy, even if away team gets 2 red cards and home team gets 0, away team wins, which could be credited to two reasons, one, that away team was stringer than home team and therefore, red cards played little or no part in the match against wekaer opponents for them, or second, the red cards plaayers were subjected to came into play very ate in the game, that is, towards the end of the game.
For home team winning, maximum cards away teams recieved were 4, and home team 2. However it is interesting to note that when away team got 4 cards in a game, which means out of 11 players, 4 were sent off, home team got NIL, so their team was more in the field and covered more and was able to dominate.
However for the game that ended in draw, away team got max 3 cards, while home team 2. Hence again, it could be cause away teams after getting their players sent off, approached a defensive mind set in to play and considered draw a favorable result for them. As they are involved in more red cards during draw than home teams, and it also makes sense, as the stadium and fans are behind home team,not away team. For away team, winning in such condition with players out from game is always tough.
create training and test dataset
Pre-model building.
##
## Attaching package: 'Hmisc'
##
## The following object is masked from 'package:randomForest':
##
## combine
##
## The following object is masked from 'package:e1071':
##
## impute
##
## The following object is masked from 'package:sfsmisc':
##
## errbar
##
## The following objects are masked from 'package:dplyr':
##
## combine, src, summarize
##
## The following objects are masked from 'package:plyr':
##
## is.discrete, summarize
##
## The following objects are masked from 'package:base':
##
## format.pval, round.POSIXt, trunc.POSIXt, units
## Standard deviations:
## [1] 1.6402121 1.3232471 1.2195191 1.1099054 1.0292901 1.0060514 0.9572216
## [8] 0.9173217 0.8958634 0.7768627 0.7571554 0.7063648 0.5263063 0.5049298
##
## Rotation:
## PC1 PC2 PC3 PC4 PC5
## HTHG 0.13074462 -0.26468610 0.05112461 -0.639443131 0.056916801
## HTAG -0.06704244 -0.17991626 0.46607980 0.347802425 0.153759613
## HS 0.44374738 -0.19648483 0.31406369 0.004757928 -0.055753736
## AS -0.42643661 -0.32229167 0.19135905 -0.068977424 -0.153082037
## HST 0.40617333 -0.28560147 0.26168922 -0.296240687 -0.008821227
## AST -0.36537148 -0.34517191 0.35648789 0.117491063 -0.077809058
## HC 0.32381788 -0.08680648 0.19758634 0.364648738 -0.109629723
## AC -0.29357357 -0.24748039 -0.08677332 -0.304219367 -0.260016181
## HF -0.19825144 0.33744991 0.23867198 -0.262428027 0.207247560
## AF 0.04195115 0.40748569 0.24600219 -0.106527670 -0.451424210
## HY -0.17298832 0.26419614 0.33253008 -0.072097270 0.329952031
## AY 0.03333306 0.32317092 0.29746004 -0.110044073 -0.536294130
## HR -0.15602361 0.09639027 0.22856677 0.009659805 0.132685611
## AR 0.11701169 0.14883643 0.18434717 -0.201660539 0.447209279
## PC6 PC7 PC8 PC9 PC10
## HTHG 0.012204414 -0.349494546 -0.21080549 0.05039828 -0.10336415
## HTAG -0.028146701 -0.489499192 0.02646767 0.23929186 -0.47179846
## HS -0.089120777 0.198702321 0.04600428 -0.12415101 0.09111704
## AS -0.008032278 0.159909601 0.15489254 -0.07476979 0.29467739
## HST -0.086608867 0.016271120 -0.03736035 -0.11418017 0.11407297
## AST -0.008546187 -0.024642964 0.16409881 -0.01212637 0.31821653
## HC -0.009334180 0.430727449 -0.06304866 -0.19466763 -0.23604181
## AC 0.072854578 0.427067500 0.03979066 0.07672861 -0.64295813
## HF -0.360482773 0.042211044 0.10563327 -0.46950326 -0.04149569
## AF 0.034343722 -0.236879087 0.42238363 -0.23697623 -0.19365017
## HY -0.379982481 0.288385471 -0.34900063 0.26157416 -0.05505038
## AY 0.126086728 0.060120066 -0.28793667 0.46651447 0.20976869
## HR 0.689321075 -0.004986885 -0.45957620 -0.43220485 -0.02443705
## AR 0.459899251 0.244349452 0.53794442 0.33582678 0.03669862
## PC11 PC12 PC13 PC14
## HTHG 0.45896543 0.24033813 -0.068024204 -0.21238854
## HTAG -0.03892798 -0.21413433 0.178989595 -0.03055714
## HS -0.33863448 -0.08635151 -0.171627119 -0.66171881
## AS 0.06261674 0.10129779 0.675273707 -0.19297760
## HST -0.30503097 -0.09795947 0.184382340 0.65214203
## AST 0.10977389 0.09245928 -0.645565122 0.18451864
## HC 0.61267429 0.15508628 0.069483633 0.12700294
## AC -0.18998640 -0.13759252 -0.143616904 0.02584655
## HF 0.21826965 -0.51342911 -0.034105254 -0.02412744
## AF -0.12471202 0.45867781 0.008498425 0.03433038
## HY -0.18314493 0.46981307 0.003479662 0.02341894
## AY 0.14715329 -0.34701691 0.010484409 0.00163866
## HR -0.14538866 0.03585492 -0.004401445 -0.01357496
## AR 0.11468923 -0.03335558 0.017413386 0.01466150
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 1.6402 1.3232 1.2195 1.10991 1.02929 1.0061 0.95722
## Proportion of Variance 0.1922 0.1251 0.1062 0.08799 0.07567 0.0723 0.06545
## Cumulative Proportion 0.1922 0.3172 0.4235 0.51146 0.58713 0.6594 0.72487
## PC8 PC9 PC10 PC11 PC12 PC13
## Standard deviation 0.91732 0.89586 0.77686 0.75716 0.70636 0.52631
## Proportion of Variance 0.06011 0.05733 0.04311 0.04095 0.03564 0.01979
## Cumulative Proportion 0.78498 0.84231 0.88542 0.92636 0.96200 0.98179
## PC14
## Standard deviation 0.50493
## Proportion of Variance 0.01821
## Cumulative Proportion 1.00000
Building the model.
## n= 3800
##
## node), split, n, loss, yval, (yprob)
## * denotes terminal node
##
## 1) root 3800 1982 H (0.28421053 0.23736842 0.47842105)
## 2) HTR=A,D 2461 1448 A (0.41162129 0.29459569 0.29378302)
## 4) HTR=A 859 253 A (0.70547148 0.16996508 0.12456345) *
## 5) HTR=D 1602 986 H (0.25405743 0.36142322 0.38451935)
## 10) HST< 5.5 1086 634 D (0.29650092 0.41620626 0.28729282)
## 20) AST>=3.5 533 308 A (0.42213884 0.36585366 0.21200750) *
## 21) AST< 3.5 553 296 D (0.17540687 0.46473779 0.35985533) *
## 11) HST>=5.5 516 212 H (0.16472868 0.24612403 0.58914729) *
## 3) HTR=H 1339 244 H (0.05003734 0.13218820 0.81777446) *
##
## Classification tree:
## rpart(formula = FTR ~ ., data = liga_train, method = "class",
## parms = list(split = "information"), control = rpart.control(usesurrogate = 0,
## maxsurrogate = 0))
##
## Variables actually used in tree construction:
## [1] AST HST HTR
##
## Root node error: 1982/3800 = 0.52158
##
## n= 3800
##
## CP nsplit rel error xerror xstd
## 1 0.146317 0 1.00000 1.00000 0.015537
## 2 0.105449 1 0.85368 0.85368 0.015458
## 3 0.070636 2 0.74823 0.74823 0.015172
## 4 0.015136 3 0.67760 0.70283 0.014987
## 5 0.010000 4 0.66246 0.67508 0.014855
## Rattle: A free graphical interface for data mining with R.
## Version 3.4.1 Copyright (c) 2006-2014 Togaware Pty Ltd.
## Type 'rattle()' to shake, rattle, and roll your data.
##
## Rule number: 4 [FTR=A cover=859 (23%) prob=0.71]
## HTR=A,D
## HTR=A
##
## Rule number: 20 [FTR=A cover=533 (14%) prob=0.42]
## HTR=A,D
## HTR=D
## HST< 5.5
## AST>=3.5
##
## Rule number: 21 [FTR=D cover=553 (15%) prob=0.18]
## HTR=A,D
## HTR=D
## HST< 5.5
## AST< 3.5
##
## Rule number: 11 [FTR=H cover=516 (14%) prob=0.16]
## HTR=A,D
## HTR=D
## HST>=5.5
##
## Rule number: 3 [FTR=H cover=1339 (35%) prob=0.05]
## HTR=H
##
## Call:
## randomForest(formula = (FTR) ~ ., data = liga_train, ntree = 500, mtry = 3, importance = TRUE, replace = FALSE, na.action = na.roughfix)
## Type of random forest: classification
## Number of trees: 500
## No. of variables tried at each split: 3
##
## OOB estimate of error rate: 33.18%
## Confusion matrix:
## A D H class.error
## A 759 140 181 0.2972222
## D 235 277 390 0.6929047
## H 149 166 1503 0.1732673
## A D H MeanDecreaseAccuracy MeanDecreaseGini
## HST 35.59 21.25 45.04 59.78 137.13
## AST 44.45 5.81 32.81 49.99 127.73
## HTR 40.99 15.21 31.30 44.06 170.40
## HTHG 26.48 9.28 30.06 33.99 98.89
## HTAG 29.40 8.94 17.36 30.44 76.17
## AS 4.77 -4.30 15.66 11.45 108.70
## HS 7.58 -0.05 15.55 15.49 116.76
## HR 3.49 4.25 13.88 13.94 24.36
## HY -0.83 2.03 6.80 5.05 77.84
## HC 6.42 4.64 6.44 10.21 102.89
## AY 0.53 1.75 4.57 4.40 79.17
## HF -1.24 4.30 3.85 4.10 114.72
## AR 11.31 -3.61 2.55 6.01 24.54
## AC 2.94 -0.43 1.97 2.95 93.71
## AF 3.17 1.37 0.93 3.04 116.83
## Random Forest Model 1
##
## -------------------------------------------------------------
## Tree 1 Rule 1 Node 190 Decision A
##
## 1: AR <= 0.5
## 2: HTHG <= 0.5
## 3: HTR IN ("A")
## 4: HF <= 16.5
## 5: HST <= 5.5
## 6: AS <= 11.5
## 7: HS <= 11.5
## 8: AF <= 11.5
## -----------------------------------------------------------------
## Tree 1 Rule 2 Node 310 Decision D
##
## 1: AR <= 0.5
## 2: HTHG <= 0.5
## 3: HTR IN ("A")
## 4: HF <= 16.5
## 5: HST <= 5.5
## 6: AS <= 11.5
## 7: HS <= 11.5
## 8: AF > 11.5
## 9: AF <= 12.5
## -----------------------------------------------------------------
## Tree 1 Rule 3 Node 640 Decision A
##
## 1: AR <= 0.5
## 2: HTHG <= 0.5
## 3: HTR IN ("A")
## 4: HF <= 16.5
## 5: HST <= 5.5
## 6: AS <= 11.5
## 7: HS <= 11.5
## 8: AF > 11.5
## 9: AF > 12.5
## 10: HY <= 1.5
## 11: AF <= 15
## -----------------------------------------------------------------
## Tree 1 Rule 4 Node 641 Decision H
##
## 1: AR <= 0.5
## 2: HTHG <= 0.5
## 3: HTR IN ("A")
## 4: HF <= 16.5
## 5: HST <= 5.5
## 6: AS <= 11.5
## 7: HS <= 11.5
## 8: AF > 11.5
## 9: AF > 12.5
## 10: HY <= 1.5
## 11: AF > 15
## -----------------------------------------------------------------
## Tree 1 Rule 5 Node 836 Decision A
##
## 1: AR <= 0.5
## 2: HTHG <= 0.5
## 3: HTR IN ("A")
## 4: HF <= 16.5
## 5: HST <= 5.5
## 6: AS <= 11.5
## 7: HS <= 11.5
## 8: AF > 11.5
## 9: AF > 12.5
## 10: HY > 1.5
## 11: HST <= 1.5
## 12: AC <= 5
## -----------------------------------------------------------------
## Tree 1 Rule 6 Node 837 Decision D
##
## 1: AR <= 0.5
## 2: HTHG <= 0.5
## 3: HTR IN ("A")
## 4: HF <= 16.5
## 5: HST <= 5.5
## 6: AS <= 11.5
## 7: HS <= 11.5
## 8: AF > 11.5
## 9: AF > 12.5
## 10: HY > 1.5
## 11: HST <= 1.5
## 12: AC > 5
## -----------------------------------------------------------------
## Tree 1 Rule 7 Node 1028 Decision D
##
## 1: AR <= 0.5
## 2: HTHG <= 0.5
## 3: HTR IN ("A")
## 4: HF <= 16.5
## 5: HST <= 5.5
## 6: AS <= 11.5
## 7: HS <= 11.5
## 8: AF > 11.5
## 9: AF > 12.5
## 10: HY > 1.5
## 11: HST > 1.5
## 12: AST <= 2.5
## 13: HF <= 12.5
## -----------------------------------------------------------------
## Tree 1 Rule 8 Node 1029 Decision A
##
## 1: AR <= 0.5
## 2: HTHG <= 0.5
## 3: HTR IN ("A")
## 4: HF <= 16.5
## 5: HST <= 5.5
## 6: AS <= 11.5
## 7: HS <= 11.5
## 8: AF > 11.5
## 9: AF > 12.5
## 10: HY > 1.5
## 11: HST > 1.5
## 12: AST <= 2.5
## 13: HF > 12.5
## -----------------------------------------------------------------
## Tree 1 Rule 9 Node 839 Decision A
##
## 1: AR <= 0.5
## 2: HTHG <= 0.5
## 3: HTR IN ("A")
## 4: HF <= 16.5
## 5: HST <= 5.5
## 6: AS <= 11.5
## 7: HS <= 11.5
## 8: AF > 11.5
## 9: AF > 12.5
## 10: HY > 1.5
## 11: HST > 1.5
## 12: AST > 2.5
## -----------------------------------------------------------------
## Tree 1 Rule 10 Node 458 Decision A
##
## 1: AR <= 0.5
## 2: HTHG <= 0.5
## 3: HTR IN ("A")
## 4: HF <= 16.5
## 5: HST <= 5.5
## 6: AS <= 11.5
## 7: HS > 11.5
## 8: AY <= 3.5
## 9: HY <= 1.5
## 10: HS <= 14.5
## -----------------------------------------------------------------
## Tree 1 Rule 11 Node 1204 Decision D
##
## 1: AR <= 0.5
## 2: HTHG <= 0.5
## 3: HTR IN ("A")
## 4: HF <= 16.5
## 5: HST <= 5.5
## 6: AS <= 11.5
## 7: HS > 11.5
## 8: AY <= 3.5
## 9: HY <= 1.5
## 10: HS > 14.5
## 11: HF <= 14.5
## 12: AF <= 15
## 13: AS <= 9
## 14: HC <= 9.5
## -----------------------------------------------------------------
## Tree 1 Rule 12 Node 1205 Decision H
##
## 1: AR <= 0.5
## 2: HTHG <= 0.5
## 3: HTR IN ("A")