Skip to content

Commit 8546eed

Browse files
author
Ritheesh
authored
Update app.py
1 parent 3d7b6da commit 8546eed

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

app.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,26 @@
88
import pickle
99

1010
def 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("\nModel Training Finished")
2726
accuracy = pipe.score(x_test,y_test)
28-
2927
print("\nAccuracy 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("\nUser 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

4747
if __name__ == "__main__":
48-
main()
48+
main()

0 commit comments

Comments
 (0)