Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
126a93c
added UUID for _id and fixed the start point issue
MakarandPundlik Oct 27, 2024
ebd5f02
added ride owner, unique username constraint and simplified db querying
MakarandPundlik Oct 27, 2024
eab2487
reomved route id by destination, used uuid instead
MakarandPundlik Oct 27, 2024
d7e602f
added google map integration
MakarandPundlik Oct 27, 2024
42354c6
changed db conn string
V4run14 Oct 27, 2024
35e7544
Added password hashing
V4run14 Oct 27, 2024
ad86c98
Merge pull request #2 from GradHackersGuild/varun_features
V4run14 Oct 27, 2024
027e2fb
Added GoogleMaps API autocomplete in create ride form. Added capacity…
V4run14 Oct 27, 2024
9f756b4
added option to join a ride and approve a ride for organizer
MakarandPundlik Oct 28, 2024
d19ec7e
Merge branch 'makarand_features' of https://github.com/GradHackersGui…
MakarandPundlik Oct 28, 2024
8c03c1d
Added feature to predict ride costs
michellevarghese Oct 28, 2024
1209d4d
Delete ride functionality fixed
V4run14 Oct 28, 2024
97bb35a
Added UI v2 temp files
michellevarghese Oct 28, 2024
1ae6c63
added approve requested user functionality from my rides
MakarandPundlik Oct 31, 2024
993452b
added requested ride and confrmed rides feature for user
MakarandPundlik Oct 31, 2024
2cb4a1b
Update testcases.yml
V4run14 Oct 31, 2024
27ad1e3
Modified files for tests
V4run14 Oct 31, 2024
65c7c8d
Merge branch 'varun_features' of https://github.com/GradHackersGuild/…
V4run14 Oct 31, 2024
22e4932
Update pip installs in testcases.yml
V4run14 Oct 31, 2024
5403da4
Update testcases.yml - Adding setuptools upgrade
V4run14 Oct 31, 2024
0eddd88
Updated python version in testcases.yml
V4run14 Oct 31, 2024
9adfcc1
Updated testcases.yml: DowngradedUbuntu version to support python
V4run14 Oct 31, 2024
bf4ef23
Update testcases.yml: Changing path for venv and requirements.txt
V4run14 Oct 31, 2024
c07ae49
Update README.md: Updated repos in all badges. Added Test badges.
V4run14 Oct 31, 2024
4b7765d
Update testcases.yml: Code coverage report upload
V4run14 Oct 31, 2024
564345b
Update testcases.yml: Renamed Workflow
V4run14 Oct 31, 2024
bd1a71e
Update README.md: Fixing workflow badges
V4run14 Oct 31, 2024
1dc5626
Update README.md: Path for test workflow badge
V4run14 Oct 31, 2024
b6258b9
Rename testcases.yml to run_test_cases.yml
V4run14 Oct 31, 2024
2e8a9e0
resolved a bug of redirecting to index page after request to ride
MakarandPundlik Oct 31, 2024
b9960bc
resolved a bug - same user was getting added on every approval
MakarandPundlik Oct 31, 2024
2e1aa5d
Update run_test_cases.yml: added branches to test workflows
V4run14 Oct 31, 2024
be00701
Update run_test_cases.yml: coverage report generation
V4run14 Oct 31, 2024
2ff0336
Update run_test_cases.yml: Adding codecov token
V4run14 Oct 31, 2024
968c830
Update README.md: Fixed codecov badge
V4run14 Oct 31, 2024
7980091
Update run_test_cases.yml: Run test workflows on all branches created
V4run14 Oct 31, 2024
d824918
Merge branch 'varun_features' into makarand_features
V4run14 Oct 31, 2024
dba86a3
Merge pull request #6 from GradHackersGuild/makarand_features
V4run14 Oct 31, 2024
bccf69a
Merge pull request #7 from GradHackersGuild/varun_features
V4run14 Oct 31, 2024
8ee6701
Update README.md: DOI Badge changed
V4run14 Oct 31, 2024
901a021
Update README.md: DOI Badge change
V4run14 Oct 31, 2024
8d36396
Revamped Navbar to new UI theme
michellevarghese Nov 1, 2024
c033ec4
Homepage Updated with new UI
michellevarghese Nov 1, 2024
e6da6e2
Updated UI of ride details page. Fixed Map not loading error
michellevarghese Nov 1, 2024
a746bfe
Revamped Search Rides UI. Integrated new navbar
michellevarghese Nov 1, 2024
b72a0db
Changed UI of add new ride page
michellevarghese Nov 1, 2024
265b3cd
Merge branch 'varun_features' of https://github.com/GradHackersGuild/…
michellevarghese Nov 1, 2024
454b4c9
Merge branch 'main_new' of https://github.com/GradHackersGuild/PackTr…
michellevarghese Nov 1, 2024
5c5fa66
Update nav to include ride_status
michellevarghese Nov 1, 2024
91fb473
Updated search to include request-to-join button
michellevarghese Nov 1, 2024
944871e
Built ride_status page+UI include all ride info
michellevarghese Nov 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/run_test_cases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: run_test_cases

on: [pull_request, push]

jobs:
test_python:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.10.2'

- run: pip install virtualenv

- run: |
python -m virtualenv newenv
source newenv/bin/activate

pip install django django-allauth pymongo setuptools --upgrade
pip install -r requirements.txt

python manage.py test
pip install coverage
coverage run manage.py test
coverage xml

- name: Upload coverage to Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash) -f coverage.xml
24 changes: 0 additions & 24 deletions .github/workflows/testcases.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Byte-compiled / optimized / DLL files
__pycache__/
config.ini
config.txt
PackTravel/__pycache__/
*.py[cod]
*$py.class
Expand Down Expand Up @@ -139,4 +140,5 @@ dmypy.json
.pytype/

# Cython debug symbols
cython_debug/
cython_debug/
templates/publish/route_old.html
4 changes: 4 additions & 0 deletions PackTravel/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'TEST': {
'NAME': 'my_test_database',
'MIRROR': None,
},
}
}

Expand Down
6 changes: 5 additions & 1 deletion PackTravel/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@
path('accounts/', include('allauth.urls')),
path('logout/', LogoutView.as_view()),
path('myrides/', userView.my_rides, name = 'search'),
path('delete_ride/<ride_id>', userView.delete_ride, name = 'delete_ride')
path('delete_ride/<ride_id>', userView.delete_ride, name = 'delete_ride'),
path('join_ride/<ride_id>',searchViews.join_ride,name='join_ride'),
path('approve_rides/<ride_id>',userView.approve_rides,name='approve_rides'),
path('approve_user/<ride_id>/<user_id>',userView.approve_user,name='approve_user'),
path('ride_status/',userView.requested_rides,name='rides_status')
]
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@



[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7178601.svg)](https://doi.org/10.5281/zenodo.7178601)
[![codecov](https://codecov.io/gh/amisha-w/PackTravel/branch/main/graph/badge.svg?token=HRFN97UEB7)](https://codecov.io/gh/Prachit99/PackTravel)
![Python Style Checker](https://github.com/Prachit99/PackTravel/actions/workflows/python_style_checker.yml/badge.svg)
![Lint Python](https://github.com/Prachit99/PackTravel/actions/workflows/pylint.yml/badge.svg)
[![DOI](https://zenodo.org/badge/879310431.svg)](https://doi.org/10.5281/zenodo.14020210)
![Tests](https://github.com/GradHackersGuild/PackTravel-Old/actions/workflows/run_test_cases.yml/badge.svg)
[![Codecov](https://codecov.io/gh/GradHackersGuild/PackTravel-Old/branch/main_new/graph/badge.svg)](https://codecov.io/gh/GradHackersGuild/PackTravel-Old)
![Python Style Checker](https://github.com/GradHackersGuild/PackTravel-Old/actions/workflows/python_style_checker.yml/badge.svg)
![Lint Python](https://github.com/GradHackersGuild/PackTravel-Old/actions/workflows/pylint.yml/badge.svg)

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
[![contributors](https://img.shields.io/github/contributors/Prachit99/PackTravel?style=for-the-badge)](https://github.com/Prachit99/PackTravel/graphs/contributors)
[![Total Lines](https://img.shields.io/tokei/lines/github/Prachit99/PackTravel?style=for-the-badge)](https://img.shields.io/tokei/lines/github/Prachit99/PackTravel)
[![Issues](https://img.shields.io/github/issues/Prachit99/PackTravel?style=for-the-badge)](https://github.com/Prachit99/PackTravel/issues)
[![Closed Issues](https://img.shields.io/github/issues-closed-raw/Prachit99/PackTravel?style=for-the-badge)](https://github.com/Prachit99/PackTravel/issues?q=is%3Aissue+is%3Aclosed)
[![Pull Requests](https://img.shields.io/github/issues-pr/Prachit99/PackTravel?style=for-the-badge)](https://github.com/Prachit99/PackTravel/pulls)
[![Commit Acitivity](https://img.shields.io/github/commit-activity/w/Prachit99/PackTravel?style=for-the-badge)](https://github.com/Prachit99/PackTravel/graphs/commit-activity)
[![Repo Size](https://img.shields.io/github/repo-size/Prachit99/PackTravel?style=for-the-badge)](https://github.com/Prachit99/PackTravel)
[![contributors](https://img.shields.io/github/contributors/GradHackersGuild/PackTravel-Old?style=for-the-badge)](https://github.com/GradHackersGuild/PackTravel-Old/graphs/contributors)
[![Total Lines](https://img.shields.io/tokei/lines/github/GradHackersGuild/PackTravel-Old?style=for-the-badge)](https://img.shields.io/tokei/lines/github/GradHackersGuild/PackTravel-Old)
[![Issues](https://img.shields.io/github/issues/GradHackersGuild/PackTravel-Old?style=for-the-badge)](https://github.com/GradHackersGuild/PackTravel-Old/issues)
[![Closed Issues](https://img.shields.io/github/issues-closed-raw/GradHackersGuild/PackTravel-Old?style=for-the-badge)](https://github.com/GradHackersGuild/PackTravel-Old/issues?q=is%3Aissue+is%3Aclosed)
[![Pull Requests](https://img.shields.io/github/issues-pr/GradHackersGuild/PackTravel-Old?style=for-the-badge)](https://github.com/GradHackersGuild/PackTravel-Old/pulls)
[![Commit Activity](https://img.shields.io/github/commit-activity/w/GradHackersGuild/PackTravel-Old?style=for-the-badge)](https://github.com/GradHackersGuild/PackTravel-Old/graphs/commit-activity)
[![Repo Size](https://img.shields.io/github/repo-size/GradHackersGuild/PackTravel-Old?style=for-the-badge)](https://github.com/GradHackersGuild/PackTravel-Old)



</div>
Expand Down
51 changes: 51 additions & 0 deletions cab_model/create_store_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import pandas as pd
import numpy as np
from sklearn.linear_model import LassoCV
import warnings
import pickle
from pathlib import Path
import os

BASE_DIR = Path(__file__).resolve().parent.parent
warnings.filterwarnings('ignore')

filepath = os.path.join(BASE_DIR, 'data')
df_cabs = pd.read_csv(filepath+r"/cab_rides.csv")
df_cabs['time_stamp'] = df_cabs['time_stamp'].astype(str).str[:-3].astype(np.int64)
df_cabs.dropna(inplace=True)

cab_company = pd.get_dummies(df_cabs.cab_type)
cab_company.columns = ['LyftCabs', 'UberCabs']
df_cabs = pd.concat([df_cabs, cab_company], axis=1)

cab_type = pd.get_dummies(df_cabs.name)
df_cabs = pd.concat([df_cabs, cab_type], axis=1)

df_cabs['time_stamp'] = pd.to_datetime(df_cabs['time_stamp'], unit='s')
df_cabs['timePeriodCategory'] = df_cabs.time_stamp.apply(lambda date: "EarlyMorning" if 3 <= date.hour <= 6 else "MorningNoon" if 6 < date.hour <= 17 else "Night" if 17 < date.hour <= 22 else "LateNight")
time_period = pd.get_dummies(df_cabs.timePeriodCategory)
df_cabs = pd.concat([df_cabs, time_period], axis=1)

df_cabs['weekend'] = df_cabs['time_stamp'].dt.day_name().isin(['Saturday', 'Sunday']).astype(int)
df_cabs['weekday'] = df_cabs.weekend.astype(bool).apply(lambda x: 0 if x == 1 else 1)

df_cabs.drop(['destination', 'surge_multiplier', 'source', 'id', 'time_stamp', 'cab_type', 'product_id', 'timePeriodCategory', 'name'], axis=1, inplace=True)

X = df_cabs.loc[:, df_cabs.columns != 'price']
y = pd.DataFrame(df_cabs['price'])

def lassoRegCV(x_train, y_train):
"""
Lasso regression model to predict cab prices.
Other models such as Linear Reg., Lasso Reg., KNN Reg. and Random forest Reg. explored and tested as well.
Performed different hyperparameter tuning for the models as well and data transformation such as normalizing data.
Selected Lasso regression as final model based on testing error rates.
"""
model_lassocv_ret = LassoCV(alphas=None, cv=10, max_iter=100000)
model_lassocv_ret.fit(x_train, y_train)
return model_lassocv_ret

save_model_path = str(BASE_DIR) + "/cab_model/model.pkl"
model_lassocv = lassoRegCV(X.to_numpy(), y.to_numpy())
with open(save_model_path, "wb") as f:
pickle.dump(model_lassocv, f)
Binary file added cab_model/model.pkl
Binary file not shown.
98 changes: 98 additions & 0 deletions cab_model/predict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
"""Module to contain functionality to predict cab price"""
from datetime import date
import pickle
import pandas as pd
from pathlib import Path


BASE_DIR = Path(__file__).resolve().parent.parent

class predict_price():
"""Class to contain functionality to predict cab price"""
def __init__(self, distance, date_time_str):
self.distance = distance
self.date_time_str = date_time_str.split(" ")
self.date = self.date_time_str[0]
self.time = self.date_time_str[1]
self.columns = ['distance', 'LyftCabs', 'UberCabs', 'Black', 'Black SUV', 'Lux', 'Lux Black', 'Lux Black XL', 'Lyft', 'Lyft XL', 'Shared', 'UberPool', 'UberX', 'UberXL', 'WAV', 'EarlyMorning', 'LateNight', 'MorningNoon', 'Night', 'weekend', 'weekday']

def populateTimePeriod(self, to_pred_data):
"""This method sanitizes the format of time"""
hour = [int(n) for n in self.time.split(":")][0]
if 3 <= hour and hour <= 6 :
to_pred_data['EarlyMorning'] = 1
elif 6 < hour and hour <= 17 :
to_pred_data['MorningNoon'] = 1
elif 17 < hour and hour <= 22 :
to_pred_data['Night'] = 1
else :
to_pred_data['LateNight'] = 1

date_list = self.date.split("-")
for i in range(len(date_list)):
if date_list[i] != "":
date_list[i] = int(date_list[i])
else:
date_list[i] = 0
d = date(day=date_list[0], month=date_list[1], year=date_list[2]).strftime('%A')

if d in ["Saturday", "Sunday"] :
to_pred_data["weekend"] = 1
else :
to_pred_data["weekday"] = 1
to_pred_data["weekend"] = 1

return to_pred_data

def dataframeFromDict(self, to_pred):
"""This method converts a dictionary to data frame"""
new_data = pd.DataFrame(to_pred.items()).transpose()
cols = new_data.iloc[0]
new_data = new_data[1:]
new_data.columns = cols
return new_data


def predictCabs(self, to_pred):
"""This method predicts cab price with input data"""
path_to_model = str(BASE_DIR) + r"/cab_model/model.pkl"
with open(path_to_model, 'rb') as f:
lasso_trained_model = pickle.load(f)

res1 = ""
res2 = ""
cabs = {
"UberCabs" : ['UberPool', 'Black SUV'],
"LyftCabs" : ['Shared', 'Lux Black XL']
}
price_range = []
for each_cab_comp in cabs.keys():
to_pred[each_cab_comp] = 1

for eachCabType in cabs[each_cab_comp]:
to_pred[eachCabType] = 1
to_pred_df = self.dataframeFromDict(to_pred)
price = lasso_trained_model.predict(to_pred_df.to_numpy())
price_range.append(price)
to_pred[eachCabType] = 0
#res += f"For {each_cab_comp}, price ranges from ${round(price_range[0][0], 2)} to ${round(price_range[1][0], 2)}\n"
to_pred[each_cab_comp] = 0
res1 = "For Uber, price range is from: $"+str(round(price_range[0][0], 2))+" to: $"+str(round(price_range[1][0], 2))
res2 = "For Lyft, price range is from: $"+str(round(price_range[2][0], 2))+" to: $"+str(round(price_range[3][0], 2))
return res1, res2

def createDataForPrice(self):
"""This method creates data to predict cab price"""
to_pred = {}
for each in self.columns:
to_pred[each] = 0
to_pred["distance"] = self.distance
to_pred = self.populateTimePeriod(to_pred)
return to_pred


def generate_data_return_price(self):
"""This method returns estimate price"""
data = self.createDataForPrice()
price_str = self.predictCabs(data)
return price_str
Loading