From 8546eed23bb04fe7937d4fe5a66b387dca936496 Mon Sep 17 00:00:00 2001 From: Ritheesh Date: Tue, 16 Jun 2020 16:49:11 +0530 Subject: [PATCH] Update app.py --- app.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app.py b/app.py index 9e645d3..7deba8d 100644 --- a/app.py +++ b/app.py @@ -8,6 +8,7 @@ import pickle def main(): + # Get the dataset from the users GitHub repository dataset_path = "https://raw.githubusercontent.com/" + os.environ["GITHUB_REPOSITORY"] +"/master/dataset.csv" data = pd.read_csv(dataset_path) print() @@ -15,20 +16,18 @@ def main(): x=data.iloc[:,:-1] y=data.iloc[:,-1] - - - column_trans = make_column_transformer((OneHotEncoder(),[-1]),remainder='passthrough') + column_trans = make_column_transformer((OneHotEncoder(),[-1]),remainder='passthrough') # apply encoding on output variable x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.2, random_state=0) + #define a pipeline pipe = make_pipeline(column_trans,SVC()) - - pipe.fit(x_train,y_train) + pipe.fit(x_train,y_train) #training the model print("\nModel Training Finished") accuracy = pipe.score(x_test,y_test) - print("\nAccuracy of the Model: "+str(accuracy*100)) + if pipe: - pickle.dump(pipe,open('model.pkl','wb')) + pickle.dump(pipe,open('model.pkl','wb')) # store the artifact in docker container if not os.environ["INPUT_MYINPUT"] == 'zeroinputs': inputs = ast.literal_eval(os.environ["INPUT_MYINPUT"]) @@ -38,11 +37,12 @@ def main(): else: output = ["None"] print("\nUser didn't provided inputs to predict") + print("\n=======================Action Completed========================") - - print(f"::set-output name=myOutput::{output[0]}") + + if __name__ == "__main__": - main() \ No newline at end of file + main()