-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (25 loc) · 853 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pandas as pd
import numpy as np
import warnings
warnings.filterwarnings('ignore')
import joblib
# get input from shell
import sys
def main():
model = joblib.load(open('model.pkl', 'rb'))
# Load column names
column_names = joblib.load(open('model_columns.pkl', 'rb'))
# Read the test data
df = pd.read_csv('df_test.csv')
# Select a single row from the dataframe (assuming it's a DataFrame)
df_row = df.head(1)
# Use the same columns used during training
df_row = df_row[column_names]
# Predict using the loaded model
prediction = model.predict(df_row)
prediction_proba = model.predict_proba(df_row)
# return result
return {"prediciton": int(prediction[0]), "probability": float(f"{np.max(prediction_proba)*100:.2f}")}
if __name__ == '__main__':
result = main()
print(result)