Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
College Affordability Prediction
This project provides an end-to-end pipeline for predicting net cost after aid and admission probability for U.S. colleges and universities. It includes:
ETL scripts to ingest and merge data from JSON and National Center for Education Statistics (NCES) Scorecard CSVs (institution-level & program-level debt).
Model training scripts that fit regression and classification models using scikit-learn.
Prediction wrappers to load the latest data and models, and make predictions by school ID or name.
Streamlit app for interactive exploration, allowing users to select a school and override personal academic stats to see admission chances.
⸻
Prerequisites
Python 3.12
Installation
1. Clone the repo
cd college-affordability
2. Create & activate a virtual environment
python3 -m venv .venv
source .venv/bin/activate
.\.venv\Scripts\activate
3. Install Python dependencies
pip install --upgrade pip
pip install pandas sqlalchemy scikit-learn joblib python-dotenv rapidfuzz streamlit
4. (Optional) API dependencies
pip install fastapi uvicorn
Data & Configuration
Place raw data files under data/raw/:
schoolInfo.json (base JSON with 39 profile fields)
Most-Recent-Cohorts-Institution_05192025.csv (institution-level NCES Scorecard)
Most-Recent-Cohorts-Field-of-Study.csv (program-level debt)
By default, the SQLite database is db/app.db. No other configuration is needed. If you wish to point to a different database, set DB_URL in a .env file at the project root:
DB_URL=sqlite:///db/app.db
🗄️ ETL Pipeline
Run the ETL script to load and merge all data into the universities table:
python etl/etl.py
Output:
Institution merge: 311/311 rows matched.
FoS merge: 311/311 rows matched.
Loaded 311 rows -> db/app.db (table 'universities')
Model Training
Train both regression and classification models:
python models/train.py
You’ll see metrics printed:
Regression — MAE: 4,009 | RMSE: 4,797 | R²: 0.286
Positive rate for classification: 21.0%
Classification (GPA/SAT/ACT only) — 5-fold CV F1: 0.756 ± 0.121
Saved models → models/
Models are saved to models/cost_regressor.joblib and models/selectivity_classifier.joblib.
Predictions Wrapper
A helper module models/predict.py provides:
predict_cost(school_id_or_name) → float
predict_selectivity(school_id_or_name) → dict(label, probability)
Example usage:
python - <<'PY'
from models.predict import predict_cost, predict_selectivity
print(predict_cost("3471")) # by numeric ID
print(predict_selectivity("Rice University")) # by name
PY
Streamlit App
Launch an interactive UI:
streamlit run app/streamlit_app.py
Features:
1. General Predictions: Dropdown to select any school.
2. Personalize: Override HS GPA, SAT, and ACT to see personalized admission chance.
3. Metrics: Displays net cost after aid and admission probability.
Project Structure
college-affordability/
├─ data/raw/ # raw data files (JSON + CSVs)
├─ db/app.db # SQLite database
├─ etl/etl.py # ETL pipeline script
├─ models/
│ ├─ train.py # train regression & classification
│ ├─ predict.py # wrapper to load models & predict
│ ├─ accept_rate_regressor.joblib # saved regression model
│ └─ selectivity_classifier_calibrated.joblib # saved classifier
└─ app/
├─ streamlit_app.py # Streamlit front-end