subbunanepalli commited on
Commit
059c0a6
·
verified ·
1 Parent(s): 4fd6dd6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from train import train_model
3
+ from predict import predict_labels
4
+ from test import test_model
5
+ from validate import validate_files
6
+ from schemas import TransactionData
7
+
8
+ app = FastAPI(title="LogReg Multi-Output Classifier API")
9
+
10
+ @app.post("/train")
11
+ def train():
12
+ result = train_model()
13
+ return {"message": "Model trained and saved successfully", "accuracy": result}
14
+
15
+ @app.post("/predict")
16
+ def predict(input_data: TransactionData):
17
+ prediction = predict_labels(input_data)
18
+ return {"predictions": prediction}
19
+
20
+ @app.post("/test")
21
+ def test():
22
+ return test_model()
23
+
24
+ @app.post("/validate")
25
+ def validate():
26
+ return validate_files()