88import pickle
99
1010def main ():
11+ # Get the dataset from the users GitHub repository
1112 dataset_path = "https://raw.githubusercontent.com/" + os .environ ["GITHUB_REPOSITORY" ] + "/master/dataset.csv"
1213 data = pd .read_csv (dataset_path )
1314 print ()
1415 print (data .describe ())
1516
1617 x = data .iloc [:,:- 1 ]
1718 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
2120 x_train , x_test , y_train , y_test = train_test_split (x , y , test_size = 0.2 , random_state = 0 )
2221
22+ #define a pipeline
2323 pipe = make_pipeline (column_trans ,SVC ())
24-
25- pipe .fit (x_train ,y_train )
24+ pipe .fit (x_train ,y_train ) #training the model
2625 print ("\n Model Training Finished" )
2726 accuracy = pipe .score (x_test ,y_test )
28-
2927 print ("\n Accuracy of the Model: " + str (accuracy * 100 ))
28+
3029 if pipe :
31- pickle .dump (pipe ,open ('model.pkl' ,'wb' ))
30+ pickle .dump (pipe ,open ('model.pkl' ,'wb' )) # store the artifact in docker container
3231
3332 if not os .environ ["INPUT_MYINPUT" ] == 'zeroinputs' :
3433 inputs = ast .literal_eval (os .environ ["INPUT_MYINPUT" ])
@@ -38,11 +37,12 @@ def main():
3837 else :
3938 output = ["None" ]
4039 print ("\n User didn't provided inputs to predict" )
40+
4141 print ("\n =======================Action Completed========================" )
42-
43-
4442 print (f"::set-output name=myOutput::{ output [0 ]} " )
4543
44+
45+
4646
4747if __name__ == "__main__" :
48- main ()
48+ main ()
0 commit comments