Live Demo: https://harshithk-5e98bim4d-harshith-kumars-projects-7f4b7494.vercel.app
Update this link after deployment (e.g., Vercel URL for the frontend). If your backend is hosted separately, ensure NEXT_PUBLIC_API_BASE in frontend/.env.local points to your public FastAPI API URL.
Note: Links like http://localhost:3000 or http://localhost:8000 only work on your own computer while the servers are running. They will not work for others viewing the README on GitHub. Use the public Deploy Link above for sharing.
- Frontend: Next.js (React) + TailwindCSS + Chart.js
- Backend: FastAPI (Python)
- ML: Naive Bayes (scikit-learn)
- Data: Synthetic CSV
- Open a terminal in
backend/and create a virtual env (optional). - Install deps: pip install -r requirements.txt
- Generate data (optional, backend auto-generates if missing): python generate_student_data.py
- Run API: uvicorn main:app --reload --host 0.0.0.0 --port 8000
- Open a terminal in
frontend/. - Install deps: npm install
- Run dev server: npm run dev
- Optionally configure API URL by creating
frontend/.env.local: NEXT_PUBLIC_API_BASE=http://localhost:8000
- Home: Title and Bayes’ theorem explanation.
- Predict: Input form, probability result, factor contribution chart, and report download.
- Data: Preview of dataset from
/sample-data.
- GET
/sample-data-> preview rows. - POST
/predictbody: { study_hours, attendance, sleep_hours, internet_usage: 'Low|Medium|High', prev_grade: 'A|B|C|D|F' }
Response: { probability_pass: number, predicted_label: 'Pass'|'Fail', feature_likelihoods: {feature, score}[] }
Gaussian Naive Bayes assumes feature independence: log posterior is prior + sum of per-feature log-likelihoods. We normalize the per-feature log-likelihood differences for visualization.
-
Start backend
- In
backend/:- Create venv (optional) and install deps:
pip install -r requirements.txt - Run API:
uvicorn main:app --reload --host 0.0.0.0 --port 8000
- Create venv (optional) and install deps:
- Test: open http://localhost:8000 and http://localhost:8000/sample-data
- In
-
Start frontend
- In
frontend/:- Install deps:
npm install - Run dev server:
npm run dev
- Install deps:
- Open: http://localhost:3000
- In
-
If your backend is remote
- Set
NEXT_PUBLIC_API_BASEinfrontend/.env.localto your backend URL (e.g., Render):NEXT_PUBLIC_API_BASE=https://YOUR-API.onrender.com
- Rebuild/redeploy the frontend.
- Set