Skip to content

Commit 9efa5c5

Browse files
author
Stephen McGough
committed
Added files
1 parent 55e8151 commit 9efa5c5

File tree

4 files changed

+201
-0
lines changed

4 files changed

+201
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
# BadAI
2+
Data and code to go with the Blog post: The Danger of Learning the Wrong Thing
3+
Please see post at:

predict.csv

+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
qdate,year,month,day,week,hour,min,id,owner,command,actual duration
2+
1263821073,2010,1,18,2,13,24,149969,4,8,934
3+
1263821914,2010,1,18,2,13,38,149970,4,8,24327
4+
1263846751,2010,1,18,2,20,32,149971,4,9,3
5+
1263848977,2010,1,18,2,21,9,149972,4,10,1223
6+
1263850223,2010,1,18,2,21,30,149973,4,10,3
7+
1263915682,2010,1,19,3,15,41,149975,4,11,3
8+
1263919050,2010,1,19,3,16,37,149976,4,11,3
9+
1263919345,2010,1,19,3,16,42,149977,4,11,3
10+
1263920377,2010,1,19,3,16,59,149978,4,11,3
11+
1263924242,2010,1,19,3,18,4,149979,4,11,3
12+
1263924728,2010,1,19,3,18,12,149980,4,11,4
13+
1263931520,2010,1,19,3,20,5,149981,4,11,494
14+
1263932284,2010,1,19,3,20,18,149982,4,11,3
15+
1264072945,2010,1,21,5,11,22,149986,4,11,287
16+
1264073258,2010,1,21,5,11,27,149987,4,11,3
17+
1264074453,2010,1,21,5,11,47,149988,4,11,4
18+
1264071357,2010,1,21,5,10,55,149985,5,11,3258
19+
1264075019,2010,1,21,5,11,56,149990,4,11,245
20+
1264074603,2010,1,21,5,11,50,149989,4,11,1585
21+
1264075726,2010,1,21,5,12,8,149991,4,11,476
22+
1264076053,2010,1,21,5,12,14,149992,5,11,3
23+
1264076346,2010,1,21,5,12,19,149993,4,11,219
24+
1264076780,2010,1,21,5,12,26,149995,4,11,438
25+
1264076709,2010,1,21,5,12,25,149994,5,11,786
26+
1264077509,2010,1,21,5,12,38,149996,5,11,3
27+
1264077699,2010,1,21,5,12,41,149997,5,11,624
28+
1264078289,2010,1,21,5,12,51,149998,5,11,144
29+
1264078593,2010,1,21,5,12,56,149999,5,11,659
30+
1264079354,2010,1,21,5,13,9,150000,5,11,3
31+
1264080184,2010,1,21,5,13,23,150001,5,11,4
32+
1264080394,2010,1,21,5,13,26,150002,5,11,3
33+
1264080646,2010,1,21,5,13,30,150003,5,11,498
34+
1264081538,2010,1,21,5,13,45,150004,5,11,49
35+
1264081918,2010,1,21,5,13,51,150005,5,11,52
36+
1264083321,2010,1,21,5,14,15,150006,5,12,8
37+
1264083886,2010,1,21,5,14,24,150007,5,12,7
38+
1264083994,2010,1,21,5,14,26,150008,5,12,7
39+
1264084571,2010,1,21,5,14,36,150009,5,12,7
40+
1264087183,2010,1,21,5,15,19,150010,5,11,39
41+
1264087847,2010,1,21,5,15,30,150011,5,11,48
42+
1264088406,2010,1,21,5,15,40,150013,5,11,22
43+
1264088365,2010,1,21,5,15,39,150012,5,11,68
44+
1264088440,2010,1,21,5,15,40,150014,5,11,883
45+
1264089384,2010,1,21,5,15,56,150015,5,11,49
46+
1264090333,2010,1,21,5,16,12,150016,5,11,453
47+
1264090802,2010,1,21,5,16,20,150017,5,11,57
48+
1264091227,2010,1,21,5,16,27,150018,5,11,57
49+
1264092287,2010,1,21,5,16,44,150019,5,11,30
50+
1264092449,2010,1,21,5,16,47,150020,5,11,29
51+
1264093366,2010,1,21,5,17,2,150021,5,11,26
52+
1264093637,2010,1,21,5,17,7,150022,5,11,25
53+
1264094063,2010,1,21,5,17,14,150023,5,11,21
54+
1264094229,2010,1,21,5,17,17,150024,5,11,30
55+
1264168189,2010,1,22,6,13,49,150025,4,13,147
56+
1264168560,2010,1,22,6,13,56,150026,4,13,211
57+
1264168902,2010,1,22,6,14,1,150027,4,13,505
58+
1264170198,2010,1,22,6,14,23,150028,4,11,26
59+
1264170894,2010,1,22,6,14,34,150029,4,11,30
60+
1264171330,2010,1,22,6,14,42,150030,4,11,16
61+
1264172626,2010,1,22,6,15,3,150031,4,11,26
62+
1264173287,2010,1,22,6,15,14,150032,4,11,25
63+
1264173918,2010,1,22,6,15,25,150033,4,11,25
64+
1264174092,2010,1,22,6,15,28,150034,4,11,4
65+
1264174324,2010,1,22,6,15,32,150036,4,11,14
66+
1264174308,2010,1,22,6,15,31,150035,4,11,1324
67+
1264175644,2010,1,22,6,15,54,150037,4,11,31
68+
1264176009,2010,1,22,6,16,0,150038,4,11,30
69+
1264179308,2010,1,22,6,16,55,150040,5,14,13
70+
1264181119,2010,1,22,6,17,25,150041,5,11,4
71+
1264182196,2010,1,22,6,17,43,150042,5,11,3
72+
1264185014,2010,1,22,6,18,30,150043,5,11,24
73+
1264185432,2010,1,22,6,18,37,150044,5,11,23
74+
1264186268,2010,1,22,6,18,51,150045,5,11,112
75+
1264186427,2010,1,22,6,18,53,150046,5,11,23
76+
1264190614,2010,1,22,6,20,3,150047,4,11,131
77+
1264190903,2010,1,22,6,20,8,150048,4,11,52
78+
1264191891,2010,1,22,6,20,24,150049,4,11,302
79+
1264192633,2010,1,22,6,20,37,150050,4,11,57
80+
1264193039,2010,1,22,6,20,43,150051,4,11,12
81+
1264193302,2010,1,22,6,20,48,150052,4,11,250
82+
1264193567,2010,1,22,6,20,52,150053,4,11,12
83+
1264193823,2010,1,22,6,20,57,150054,4,11,11
84+
1264194045,2010,1,22,6,21,0,150055,4,11,12
85+
1264197883,2010,1,22,6,22,4,150056,4,11,12
86+
1264198249,2010,1,22,6,22,10,150057,4,11,595
87+
1264198853,2010,1,22,6,22,20,150058,4,11,372
88+
1264199235,2010,1,22,6,22,27,150059,4,11,12
89+
1264199668,2010,1,22,6,22,34,150060,4,11,598
90+
1264200291,2010,1,22,6,22,44,150061,4,11,12
91+
1264241661,2010,1,23,7,10,14,150062,4,11,1006
92+
1264242781,2010,1,23,7,10,33,150063,4,11,13
93+
1264246188,2010,1,23,7,11,29,150064,4,11,332
94+
1264246598,2010,1,23,7,11,36,150065,4,11,1128
95+
1264247745,2010,1,23,7,11,55,150066,4,11,3
96+
1264270237,2010,1,23,7,18,10,150067,4,11,4
97+
1264270351,2010,1,23,7,18,12,150068,4,11,11
98+
1264270521,2010,1,23,7,18,15,150069,4,11,12
99+
1264271152,2010,1,23,7,18,25,150070,4,11,12
100+
1264274335,2010,1,23,7,19,18,150071,5,11,24
101+
1264274502,2010,1,23,7,19,21,150072,5,11,32
102+
1264274834,2010,1,23,7,19,27,150073,5,11,12
103+
1264285743,2010,1,23,7,22,29,150074,4,11,18
104+
1264424357,2010,1,25,2,12,59,150075,4,11,55
105+
1264430177,2010,1,25,2,14,36,150077,4,11,23
106+
1264430563,2010,1,25,2,14,42,150078,4,11,12
107+
1264430856,2010,1,25,2,14,47,150079,4,11,12
108+
1264431062,2010,1,25,2,14,51,150080,4,11,12
109+
1264431736,2010,1,25,2,15,2,150081,4,11,240
110+
1264432000,2010,1,25,2,15,6,150082,4,11,12
111+
1264432476,2010,1,25,2,15,14,150083,4,11,23
112+
1264432732,2010,1,25,2,15,18,150084,4,11,23
113+
1264433403,2010,1,25,2,15,30,150085,4,11,11
114+
1264433548,2010,1,25,2,15,32,150086,4,11,11
115+
1264433727,2010,1,25,2,15,35,150087,4,11,11
116+
1264434713,2010,1,25,2,15,51,150091,0,0,73
117+
1264434788,2010,1,25,2,15,53,150092,4,11,1469
118+
1264436279,2010,1,25,2,16,17,150093,4,11,24
119+
1264437234,2010,1,25,2,16,33,150094,4,11,24
120+
1264437440,2010,1,25,2,16,37,150095,4,11,23
121+
1264437697,2010,1,25,2,16,41,150098,4,11,23
122+
1264437852,2010,1,25,2,16,44,150099,4,11,23
123+
1264438260,2010,1,25,2,16,51,150100,4,11,23
124+
1264438814,2010,1,25,2,17,0,150101,4,11,24
125+
1264496826,2010,1,26,3,9,7,150102,4,11,7209
126+
1264504331,2010,1,26,3,11,12,150103,4,11,4
127+
1264504534,2010,1,26,3,11,15,150104,4,11,45
128+
1264510270,2010,1,26,3,12,51,150105,4,11,12
129+
1264511336,2010,1,26,3,13,8,150106,4,11,11
130+
1264511983,2010,1,26,3,13,19,150107,4,11,188
131+
1264512181,2010,1,26,3,13,23,150108,4,11,667
132+
1264512860,2010,1,26,3,13,34,150109,4,11,150
133+
1264513025,2010,1,26,3,13,37,150110,4,11,11
134+
1264513512,2010,1,26,3,13,45,150111,4,11,11
135+
1264514553,2010,1,26,3,14,2,150112,4,11,56
136+
1264434713,2010,1,25,2,15,51,150088,0,0,80944
137+
1264434713,2010,1,25,2,15,51,150089,0,0,80951
138+
1264434713,2010,1,25,2,15,51,150090,0,0,80953
139+
1264515879,2010,1,26,3,14,24,150114,4,12,8
140+
1264515522,2010,1,26,3,14,18,150113,4,11,12
141+
1264516127,2010,1,26,3,14,28,150115,4,11,12
142+
1264516500,2010,1,26,3,14,35,150116,4,12,741
143+
1264517033,2010,1,26,3,14,43,150117,4,11,214
144+
1264517257,2010,1,26,3,14,47,150118,4,11,11
145+
1264517646,2010,1,26,3,14,54,150119,4,11,12
146+
1264520243,2010,1,26,3,15,37,150120,4,11,12
147+
1264520321,2010,1,26,3,15,38,150121,4,11,11
148+
1264520322,2010,1,26,3,15,38,150122,4,11,13
149+
1264520353,2010,1,26,3,15,39,150123,4,11,11
150+
1264520402,2010,1,26,3,15,40,150124,4,11,11
151+
1264520404,2010,1,26,3,15,40,150125,4,11,11
152+
1264680495,2010,1,28,5,12,8,150126,4,11,62
153+
1264680741,2010,1,28,5,12,12,150127,4,11,12
154+
1264681306,2010,1,28,5,12,21,150128,4,11,11
155+
1264693114,2010,1,28,5,15,38,150130,5,11,24
156+
1264701032,2010,1,28,5,17,50,150131,0,0,1
157+
1264701193,2010,1,28,5,17,53,150132,0,0,135
158+
1264701341,2010,1,28,5,17,55,150133,0,0,21
159+
1264701381,2010,1,28,5,17,56,150134,0,0,679
160+
1264763189,2010,1,29,6,11,6,150135,4,11,58
161+
1264768732,2010,1,29,6,12,38,150136,4,11,58
162+
1264770383,2010,1,29,6,13,6,150138,4,11,74
163+
1264770091,2010,1,29,6,13,1,150137,4,11,57
164+
1264771865,2010,1,29,6,13,31,150139,4,11,252703
165+
1264771904,2010,1,29,6,13,31,150140,4,11,252667
166+
1264692165,2010,1,28,5,15,22,150129,5,11,543754

rfCode.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import pandas as pd
2+
from sklearn.model_selection import train_test_split
3+
4+
data=pd.read_csv("train.csv")
5+
print (data.columns)
6+
del data['year']
7+
8+
X_train, X_test, y_train, y_test = train_test_split(data, data.loc[: ,'actual duration'], test_size=0.3, random_state=123456)
9+
10+
del X_train['actual duration']
11+
del X_test['actual duration']
12+
13+
from sklearn.ensemble import RandomForestRegressor
14+
15+
rf = RandomForestRegressor(n_estimators=50, random_state=123456, n_jobs=-1)
16+
rf.fit(X_train, y_train)
17+
18+
r2s = rf.score(X_test, y_test)
19+
20+
print ('R^2 from test set = ', r2s)
21+
22+
print (rf.feature_importances_)
23+
24+
predict=pd.read_csv("predict.csv")
25+
26+
predict_label = predict.loc[: ,'actual duration']
27+
28+
del predict['year']
29+
del predict['actual duration']
30+
31+
score = rf.score(predict, predict_label)
32+
33+
print ('R^2 from predicion set = ', score)

train.csv.zip

568 KB
Binary file not shown.

0 commit comments

Comments
 (0)