Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +61 -0
- requirements.txt +57 -0
- student_rf_pipeline.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#gradio app
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
+
import pandas as pd
|
| 5 |
+
import pickle
|
| 6 |
+
import numpy as np
|
| 7 |
+
|
| 8 |
+
# 1. Load the Model
|
| 9 |
+
with open("student_rf_pipeline.pkl", "rb") as f:
|
| 10 |
+
model = pickle.load(f)
|
| 11 |
+
|
| 12 |
+
# 2. The Logic Function
|
| 13 |
+
def predict_gpa(gender, age, address, famsize,
|
| 14 |
+
Pstatus, M_Edu, F_Edu, M_Job, F_Job,
|
| 15 |
+
relationship, smoker, tuition_fee, time_friends,
|
| 16 |
+
ssc_result):
|
| 17 |
+
|
| 18 |
+
# Pack inputs into a DataFrame
|
| 19 |
+
# The column names must match your CSV file exactly
|
| 20 |
+
input_df = pd.DataFrame([[
|
| 21 |
+
gender, age, address, famsize, Pstatus,
|
| 22 |
+
M_Edu, F_Edu, M_Job, F_Job, relationship,
|
| 23 |
+
smoker, tuition_fee, time_friends, ssc_result
|
| 24 |
+
|
| 25 |
+
]],
|
| 26 |
+
columns=[
|
| 27 |
+
'gender', 'age', 'address', 'famsize', 'Pstatus', 'M_Edu', 'F_Edu', 'M_Job', 'F_Job', 'relationship', 'smoker', 'tuition_fee', 'time_friends', 'ssc_result'
|
| 28 |
+
])
|
| 29 |
+
|
| 30 |
+
# Predict
|
| 31 |
+
prediction = model.predict(input_df)[0]
|
| 32 |
+
|
| 33 |
+
# Return formatted result (Clipped 0-5)
|
| 34 |
+
return f"Predicted HSC Result: {np.clip(prediction, 0, 5):.2f}"
|
| 35 |
+
|
| 36 |
+
# 3. The App Interface
|
| 37 |
+
# Defining inputs in a list to keep it clean
|
| 38 |
+
inputs = [
|
| 39 |
+
gr.Radio(["M", "F"], label="Gender"),
|
| 40 |
+
gr.Number(label="Age", value=18),
|
| 41 |
+
gr.Radio(["Urban", "Rural"], label="Address"),
|
| 42 |
+
gr.Radio(["GT3", "LE3"], label="Family Size"),
|
| 43 |
+
gr.Radio(["Together", "Apart"], label="Parent Status"),
|
| 44 |
+
gr.Slider(0, 4, step=1, label="Mother's Edu"),
|
| 45 |
+
gr.Slider(0, 4, step=1, label="Father's Edu"),
|
| 46 |
+
gr.Dropdown(["At_home", "Health", "Other", "Services", "Teacher"], label="Mother's Job"),
|
| 47 |
+
gr.Dropdown(["Teacher", "Other", "Services", "Health", "Business", "Farmer"], label="Father's Job"),
|
| 48 |
+
gr.Radio(["Yes", "No"], label="Relationship"),
|
| 49 |
+
gr.Radio(["Yes", "No"], label="Smoker"),
|
| 50 |
+
gr.Number(label="Tuition Fee"),
|
| 51 |
+
gr.Slider(1, 5, step=1, label="Time with Friends"),
|
| 52 |
+
gr.Number(label="SSC Result (GPA)")
|
| 53 |
+
]
|
| 54 |
+
|
| 55 |
+
app = gr.Interface(
|
| 56 |
+
fn=predict_gpa,
|
| 57 |
+
inputs=inputs,
|
| 58 |
+
outputs="text",
|
| 59 |
+
title="HSC Predictor")
|
| 60 |
+
|
| 61 |
+
app.launch(share=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
aiofiles==24.1.0
|
| 2 |
+
annotated-doc==0.0.4
|
| 3 |
+
annotated-types==0.7.0
|
| 4 |
+
anyio==4.12.1
|
| 5 |
+
audioop-lts==0.2.2
|
| 6 |
+
brotli==1.2.0
|
| 7 |
+
certifi==2026.1.4
|
| 8 |
+
click==8.3.1
|
| 9 |
+
colorama==0.4.6
|
| 10 |
+
fastapi==0.128.0
|
| 11 |
+
ffmpy==1.0.0
|
| 12 |
+
filelock==3.20.3
|
| 13 |
+
fsspec==2026.1.0
|
| 14 |
+
gradio==6.5.1
|
| 15 |
+
gradio_client==2.0.3
|
| 16 |
+
groovy==0.1.2
|
| 17 |
+
h11==0.16.0
|
| 18 |
+
hf-xet==1.2.0
|
| 19 |
+
httpcore==1.0.9
|
| 20 |
+
httpx==0.28.1
|
| 21 |
+
huggingface_hub==1.3.5
|
| 22 |
+
idna==3.11
|
| 23 |
+
Jinja2==3.1.6
|
| 24 |
+
joblib==1.5.3
|
| 25 |
+
markdown-it-py==4.0.0
|
| 26 |
+
MarkupSafe==3.0.3
|
| 27 |
+
mdurl==0.1.2
|
| 28 |
+
numpy==2.4.1
|
| 29 |
+
orjson==3.11.6
|
| 30 |
+
packaging==26.0
|
| 31 |
+
pandas==3.0.0
|
| 32 |
+
pillow==12.1.0
|
| 33 |
+
pydantic==2.12.5
|
| 34 |
+
pydantic_core==2.41.5
|
| 35 |
+
pydub==0.25.1
|
| 36 |
+
Pygments==2.19.2
|
| 37 |
+
python-dateutil==2.9.0.post0
|
| 38 |
+
python-multipart==0.0.22
|
| 39 |
+
pytz==2025.2
|
| 40 |
+
PyYAML==6.0.3
|
| 41 |
+
rich==14.3.1
|
| 42 |
+
safehttpx==0.1.7
|
| 43 |
+
scikit-learn==1.8.0
|
| 44 |
+
scipy==1.17.0
|
| 45 |
+
semantic-version==2.10.0
|
| 46 |
+
shellingham==1.5.4
|
| 47 |
+
six==1.17.0
|
| 48 |
+
starlette==0.50.0
|
| 49 |
+
threadpoolctl==3.6.0
|
| 50 |
+
tomlkit==0.13.3
|
| 51 |
+
tqdm==4.67.2
|
| 52 |
+
typer==0.21.1
|
| 53 |
+
typer-slim==0.21.1
|
| 54 |
+
typing-inspection==0.4.2
|
| 55 |
+
typing_extensions==4.15.0
|
| 56 |
+
tzdata==2025.3
|
| 57 |
+
uvicorn==0.40.0
|
student_rf_pipeline.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3f37abb886223ab7f401134544852875c27636f2d26cfc3122ed77437cfa4963
|
| 3 |
+
size 14731925
|