From 30db98c299c683b7979d80e5bdcb7656157ecc8c Mon Sep 17 00:00:00 2001 From: srikruthiamballa Date: Sat, 4 Apr 2026 12:18:29 +0530 Subject: [PATCH 1/3] changed predictexamscore api --- api_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_main.py b/api_main.py index bd9dada..67f0a78 100644 --- a/api_main.py +++ b/api_main.py @@ -185,7 +185,7 @@ async def health_check(): raise HTTPException(status_code=500, detail="Service unhealthy") -@app.get("/api/v1/predict") +@app.post("/api/v1/predict") async def predict_exam_score(data: StudentProfile): """Predict a student's exam score from their profile.""" if not MODEL_READY: From a5d39561f3cf04da6a7c5723fe613fe6182b71ed Mon Sep 17 00:00:00 2001 From: srikruthiamballa Date: Sat, 4 Apr 2026 12:24:49 +0530 Subject: [PATCH 2/3] changed order of commit and close --- api_main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api_main.py b/api_main.py index 67f0a78..06b217e 100644 --- a/api_main.py +++ b/api_main.py @@ -221,8 +221,8 @@ async def predict_exam_score(data: StudentProfile): "INSERT INTO students (name, age, study_hours_per_day, predicted_score) VALUES (?,?,?,?)", (data.name, data.age, data.studyHours, score), ) - conn.close() - conn.commit() + conn.commit() + conn.close() except Exception as e: raise HTTPException(status_code=500, detail=f"DB write failed: {e}") From 735f87dc30ebc69b04821834cf338b1862ce7a2e Mon Sep 17 00:00:00 2001 From: srikruthiamballa Date: Sat, 4 Apr 2026 12:33:14 +0530 Subject: [PATCH 3/3] added if-else for avg_score --- api_main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api_main.py b/api_main.py index 06b217e..f664856 100644 --- a/api_main.py +++ b/api_main.py @@ -268,8 +268,10 @@ async def get_analytics(): scores = [r["predicted_score"] for r in rows if r["predicted_score"] is not None] num_students = len(scores) total_score = sum(scores) - - avg_score = total_score / num_students +if num_students>0 : + avg_score = total_score / num_students +else : + avg_score = 0 distribution = { "A (90-100)" : sum(1 for s in scores if s >= 90),