- A web application to manage taxi ridesharing using Java Servlets, Python, AngularJS and Machine Learning.
- The application has 3 user roles: Rider/Customer, Driver, Admin.
- Riders/Customers can book individual or shared taxi rides, cancel rides & rate drivers.
- Drivers can cancel rides & rate riders.
- Riders can view data like day-wise booking and cancellation, rides taken from zip codes, rating etc. on their dashboard.
- Drivers can view data like day-wise number of rides, day-wise earnings, zipcode-wise pickups & drops, rating etc. on their dashboard.
- Lines of code for AngularJS UI : 2,972
- Lines of code for Java backend : 2,290
- Lines of code for Fare Estimate ML Modeling : 331
- Lines of code for Python Fare API : 82
Total Lines of Code = 5,675
Topics from Assignments:
- Java Servlets
- HTML & CSS
- MySQL Database
- MySQL CRUD Operations
- Application User Roles (Rider/Driver/Admin)
- Data Analytics & Visualizations
- Python
- Jupyter Notebooks
- JavaScript
Others:
- Google Maps, Places & Distance Matrix APIs
- REST API
- AngularJS & TypeScript
- Dask for handling large amount of data (100 million records which don't fit in memory) and extraction useful data from the said data.
- Numpy, Scipy & Pandas for Data - Cleaning & Analysis.
- scikit-learn for Machine Learning Model - Selection, Creation & Evaluation.
- RandomForestRegression - machine learning algorithm to estimate fare for a ride based on the distance, duration (from google distance matrix api) & number of perople sharing the ride.
The Chicago City Data Portal's Transportation Network Providers - Trips dataset has been used for this application. The dataset contains 100,717,116 records of ridesharing trips, starting November 2018, reported by Transportation Network Providers (sometimes called rideshare companies) to the City of Chicago as part of routine reporting required by ordinance. It contains trip start & end times, trip miles, trip total, pickup areas and many more informations for each trip.
From this dataset, we took 1 million records with only [Trip Miles, Trip Total, Shared Trip Authorized, Trips Pooled] columns using random sampling. This was done as the 100 million records did not fit into memory and the random sampling feature of pandas gives a very good sub sample of a dataset with same mean, variance & standard deviation.
- Java >= 11.0.4
- Python >= 3.7.5
- Tomcat Server 7.0.34 (with CORS filter enabled)
- Node.js == 8.16.2
- MySQL >= 8.0.18
- Java Dependencies:
servlet-api.jar
,mysql-jdbc-5-bin.jar
,gson-2.6.2.jar
(Already present in lib) - Python Dependencies:
pandas
,scikit-learn
,joblib
,flask
,flask-cors
(See requirements.txt) - JavaScript Dependencies: See package.json
Assuming that MySQL is installed and the server is running...
-
Create the RideShare MySQL User. (Login to mysql shell as root
$ mysql -u root -p
)mysql> CREATE USER 'rideshareAdmin'@'localhost' IDENTIFIED BY 'rd@123'; mysql> GRANT ALL PRIVILEGES ON * . * TO 'rideshareAdmin'@'localhost'; mysql> FLUSH PRIVILEGES; mysql> \q
-
Import the database schema and data from the dump file. (Database dump file: rideshare_db_dump.sql)
$ mysql -u rideshareAdmin -prd@123 < server/rideshare_db_dump.sql mysql: [Warning] Using a password on the command line interface can be insecure.
(Make sure the mysql bin
folder is in PATH)
2. Enable Cross-Origin Resource Sharing (CORS) in Tomcat Server
Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell browsers to give a web application running at one origin, access to selected resources from a different origin. A web application executes a cross-origin HTTP request when it requests a resource that has a different origin (domain, protocol, or port) from its own.
Reference: https://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#CORS_Filter
-
Copy the JAR files in
tomcat_cors_filters
(see tomcat_cors_filters.zip) to thelib
folder in tomcat directory.$ unzip tomcat_cors_filter.zip $ cp tomcat_cors_filter/*.jar <path_to_tomcat_server_folder>/lib/
-
Open the
web.xml
config file located in theconf
folder in tomcat server directory & add the following lines inside<web-app>
tag:<filter> <filter-name>CorsFilter</filter-name> <filter-class>org.apache.catalina.filters.CorsFilter</filter-class> </filter> <filter-mapping> <filter-name>CorsFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
2 Ways:
- Virtual environment with python and package creation using conda.
- Standalone python installation and package installation using pip.
Create Virtual Environmnet with python3 and required packages
Environment File: rideshare.yml
Assuming that Miniconda/Anaconda (python-3) is installed and working as expected:
# Load conda base environment first
$ source <miniconda-installation-path>/bin/activate
# Create the virtual environment using the environment YAML file
(base) $ conda env create -f rideshare.yml
# Activate the new environmnet
(base) $ conda activate rideshare
(rideshare) $
-or-
Standalone python installation and package installation using pip.
Assuming that python 3 has been installed:
Requirements File: requirements.txt
$ python --version
Python 3.6.8
$ python -m pip install -U -r fare_estimation/requirements.txt
Install Node.js (https://nodejs.org/en/)
Then, assuming that you are currently inside the folder ui
in RideShare and nodejs and npm are added to PATH:
# Install the javascript packages using npm
$ npm install
Server Source Code Folder: rideshare
Dependency JAR Files: lib
Assuming you are currently in the RideShare
folder
$ cp -rf server/rideshare <path_to_tomcat_server_folder>/webapps
$ cp -f server/rideshare/lib/* <path_to_tomcat_server_folder>/lib
Assuming you are currently in the RideShare
folder
If using conda: assuming rideshare enviroment is created as per step 3 & base
conda environment is activated*
(base) $ conda activate rideshare
(rideshare) $ python fare_estimation/estimate_fare_api.py
-or-
If using system python: assuming required packages have been installed as per step 3
$ python fare_estimation/estimate_fare_api.py
(Runs on port=555. Make sure port=5555 is free on your computer.)
$ <path_to_tomcat_server_folder>/bin/catalina.sh run
Assuming you are currently in the RideShare/ui
folder and step 4 is done.
$ npm start