8
8
import pickle
9
9
10
10
def main ():
11
+ # Get the dataset from the users GitHub repository
11
12
dataset_path = "https://raw.githubusercontent.com/" + os .environ ["GITHUB_REPOSITORY" ] + "/master/dataset.csv"
12
13
data = pd .read_csv (dataset_path )
13
14
print ()
14
15
print (data .describe ())
15
16
16
17
x = data .iloc [:,:- 1 ]
17
18
y = data .iloc [:,- 1 ]
18
-
19
-
20
- column_trans = make_column_transformer ((OneHotEncoder (),[- 1 ]),remainder = 'passthrough' )
19
+ column_trans = make_column_transformer ((OneHotEncoder (),[- 1 ]),remainder = 'passthrough' ) # apply encoding on output variable
21
20
x_train , x_test , y_train , y_test = train_test_split (x , y , test_size = 0.2 , random_state = 0 )
22
21
22
+ #define a pipeline
23
23
pipe = make_pipeline (column_trans ,SVC ())
24
-
25
- pipe .fit (x_train ,y_train )
24
+ pipe .fit (x_train ,y_train ) #training the model
26
25
print ("\n Model Training Finished" )
27
26
accuracy = pipe .score (x_test ,y_test )
28
-
29
27
print ("\n Accuracy of the Model: " + str (accuracy * 100 ))
28
+
30
29
if pipe :
31
- pickle .dump (pipe ,open ('model.pkl' ,'wb' ))
30
+ pickle .dump (pipe ,open ('model.pkl' ,'wb' )) # store the artifact in docker container
32
31
33
32
if not os .environ ["INPUT_MYINPUT" ] == 'zeroinputs' :
34
33
inputs = ast .literal_eval (os .environ ["INPUT_MYINPUT" ])
@@ -38,11 +37,12 @@ def main():
38
37
else :
39
38
output = ["None" ]
40
39
print ("\n User didn't provided inputs to predict" )
40
+
41
41
print ("\n =======================Action Completed========================" )
42
-
43
-
44
42
print (f"::set-output name=myOutput::{ output [0 ]} " )
45
43
44
+
45
+
46
46
47
47
if __name__ == "__main__" :
48
- main ()
48
+ main ()
0 commit comments