Indian Railway Network Coverage Analysis and Station Site Planning
Back to ProjectTotal time from zip file to a live dashboard: about 20 to 25 minutes, and most of that is just waiting for pip and the notebook. Follow this in order and don't skip step 5, because step 5 is where almost everyone gets stuck.
python --version.pip --version.Extract the project folder you downloaded, or clone it:
git clone <your-repository-url> railgrid-ai
cd railgrid-ai
Now the dataset. Download india_railway_stations.csv from the Kaggle "Indian Railway Stations and Routing Network" dataset and drop it in the project root — the same folder as app.py. Not inside a subfolder. Root.
This keeps the project's packages away from the rest of your system. Skipping it is the number one cause of ModuleNotFoundError later.
Windows
python -m venv venv
venv\Scripts\activate
macOS and Linux
python3 -m venv venv
source venv/bin/activate
You'll know it worked when (venv) appears at the start of your terminal prompt. If it isn't there, the environment isn't active and nothing you install will land in the right place.
pip install -r requirements.txt
Then the extras the training notebook needs:
pip install jupyter matplotlib seaborn scipy
This takes two or three minutes on a decent connection. Some pip warnings in yellow are normal. Red errors are not.
jupyter notebook railgrid_ai_training.ipynb
Your browser opens the notebook. Run every cell from the top, in order — Cell menu, then Run All, or just hit Shift+Enter through all 56 of them. On a normal laptop this finishes in 3 to 6 minutes.
Watch for these four confirmations as it runs:
is_junction against route_count. Screenshot this one — it's report material.Three new folders appear when it's done: models/, figures/ and outputs/.
Here's the thing — Flask looks for models/ and outputs/ sitting directly beside app.py. If you ran Jupyter from a different directory, they landed somewhere else and the app won't find them.
cp -r /path/to/notebook/models ./models
cp -r /path/to/notebook/outputs ./outputs
Verify these three paths exist before moving on:
app.py
models/metadata.json
outputs/stations_enriched.csv
python app.py
Open http://127.0.0.1:5000 in your browser.
Visit http://127.0.0.1:5000/api/health. A healthy install returns:
{"ready": true, "warnings": []}
If warnings has anything in it, read what it names — it'll tell you which .pkl file is missing.
Then do the real test. Go to the Live Prediction page and click somewhere on the map, say around Kolkata. You should get back a predicted zone with a probability chart, a junction likelihood, an expected route count, and distances to nearby stations. If that returns data, all three models loaded correctly and you're done.
| What you see | What to do |
|---|---|
| A setup notice instead of the dashboard | outputs/stations_enriched.csv is missing. Go back to step 5. |
| Warnings in /api/health about .pkl files | The models/ folder isn't beside app.py. Copy it across. |
| ModuleNotFoundError | The virtual environment isn't active, or you installed packages before activating it. Reactivate and reinstall. |
| Blank grey map, but station points render | Tile server unreachable. Check your internet. |
| Route tracer says no corridor exists | Those two stations sit in different connected components. Try two mainland codes. |
| Corridor mesh takes forever to load | It's drawing up to 9,000 polylines. Lower the limit parameter in static/js/network.js. |
| Prediction endpoint throws an error | The zone classifier or label encoder didn't load. Scroll up in your terminal to the startup output — the reason is printed there. |
For a demo on a college server or anything not local, put it behind a WSGI server:
pip install gunicorn
gunicorn -w 2 -b 0.0.0.0:8000 app:app
Stick to two workers. Each one loads its own copy of the models and the spatial index into memory, so four workers will eat four times the RAM for no real gain at demo traffic.
Our team is here to assist you with installation and setup.