This project implements a distributed system for predicting station occupancy and seat availability for trains. It includes a web interface and can be simulated in a network environment.
- System Overview
- Prerequisites
- Installation
- Usage
- System Components
- Network Integration
- Cisco Packet Tracer Simulation
The Train Prediction System consists of three main components:
- Station Occupancy Prediction
- Seat Availability Prediction
- Web Interface
These components communicate over a network to provide real-time predictions based on user input.
- Python 3.7+
- pip (Python package manager)
- Cisco Packet Tracer (for network simulation)
-
Clone the repository:
git clone https://github.com/yourusername/train-prediction-system.git cd train-prediction-system -
Install required Python packages:
pip install flask pandas scikit-learn joblib -
Prepare your data:
- Ensure you have a CSV file named
train_schedules.csvin the project root directory. - The CSV should contain columns: 'Station_Code', 'Train_No', 'Distance', '1A', '2A', '3A', 'SL'.
- Ensure you have a CSV file named
-
Start the prediction servers and web application:
python distributed_train_prediction.py -
Open a web browser and navigate to
http://localhost:5000to access the web interface. -
Use the forms to make predictions:
- Enter a station code to predict occupancy.
- Enter train details to predict seat availability.
- Uses a Random Forest Regressor to predict the number of trains at a station.
- Features used: Station_Code (encoded)
- Target: Number of trains (Occupancy)
- Uses a Random Forest Classifier to predict seat availability in 1A class.
- Features used: Train_No, Distance, 2A, 3A, SL
- Target: 1A_Available (binary)
- Built with Flask
- Provides forms for user input
- Communicates with prediction servers over sockets
The system uses socket programming for network communication:
- Occupancy Prediction Server: Listens on port 65432
- Availability Prediction Server: Listens on port 65433
- Web Server: Communicates with prediction servers and serves on port 5000
Data is serialized using pickle for transmission over the network.
To simulate the network aspect of this system using Cisco Packet Tracer:
-
Open Cisco Packet Tracer and create a new project.
-
Add the following devices:
- 1 Router (e.g., 2811 Router)
- 1 Switch (e.g., 2960 Switch)
- 4 PCs (to represent Client, Web Server, Occupancy Server, Availability Server)
-
Connect devices:
- Connect all PCs to the Switch
- Connect the Switch to the Router
-
Configure IP addresses:
- Router: 192.168.1.1
- Client PC: 192.168.1.10
- Web Server PC: 192.168.1.20
- Occupancy Server PC: 192.168.1.30
- Availability Server PC: 192.168.1.40
-
Configure port numbers:
- Web Server: 5000
- Occupancy Server: 65432
- Availability Server: 65433
-
Use the "Add Simple PDU" tool to simulate requests:
- From Client to Web Server (port 5000)
- From Web Server to Occupancy Server (port 65432)
- From Web Server to Availability Server (port 65433)
-
Run the simulation to visualize data flow between components.
This simulation demonstrates the network topology and communication flow of the Train Prediction System in a simplified network environment.
Note: The actual implementation of the prediction algorithms and web server cannot be directly run in Packet Tracer. This simulation focuses on visualizing the network communication aspect of the system.