Skip to content

Commit

Permalink
Integrated everything
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi98khandelwal committed Mar 24, 2017
1 parent 1b0a397 commit 12c80b2
Show file tree
Hide file tree
Showing 29 changed files with 118 additions and 23 deletions.
81 changes: 81 additions & 0 deletions HintApp/.data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Started On,Status,Delay,Reach Time
2017-01-01 21:50:00,Late,50 Mins,2017-01-03 07:40:00
2017-01-02 21:50:00,Late,22 Mins,2017-01-04 07:12:00
2017-01-03 21:50:00,Late,15 Mins,2017-01-05 07:05:00
2017-01-04 21:50:00,On Time,-,2017-01-06 06:50:00
2017-01-05 21:50:00,Late,01 Hr 10 Mins,2017-01-07 08:00:00
2017-01-06 22:00:00,Late,15 Mins,2017-01-08 07:05:00
2017-01-07 22:00:00,Late,50 Mins,2017-01-09 07:40:00
2017-01-08 21:50:00,Late,35 Mins,2017-01-10 07:25:00
2017-01-09 21:50:00,Late,01 Hr 00 Min,2017-01-11 07:50:00
2017-01-10 21:50:00,Late,10 Mins,2017-01-12 07:00:00
2017-01-11 21:50:00,Late,01 Hr 00 Min,2017-01-13 07:50:00
2017-01-12 21:50:00,Late,15 Mins,2017-01-14 07:05:00
2017-01-13 22:05:00,Late,10 Mins,2017-01-15 07:00:00
2017-01-14 21:50:00,On Time,-,2017-01-16 06:50:00
2017-01-15 21:50:00,Late,04 Hrs 18 Mins,2017-01-17 11:08:00
2017-01-16 21:50:00,Late,45 Mins,2017-01-19 07:35:00
2017-01-17 21:50:00,Late,30 Mins,2017-01-19 07:20:00
2017-01-18 21:50:00,Late,10 Mins,2017-01-20 07:00:00
2017-01-19 22:00:00,Late,01 Hr 10 Mins,2017-01-21 08:00:00
2017-01-20 22:00:00,Late,15 Mins,2017-01-23 07:05:00
2017-01-21 21:50:00,Late,15 Mins,2017-01-23 07:05:00
2017-01-22 21:50:00,Late,30 Mins,2017-01-24 07:20:00
2017-01-23 21:50:00,Late,19 Mins,2017-01-25 07:09:00
2017-01-24 21:50:00,Late,04 Hrs 05 Mins,2017-01-26 10:55:00
2017-01-25 21:50:00,Late,15 Mins,2017-01-27 07:05:00
2017-01-26 21:50:00,Late,15 Mins,2017-01-28 07:05:00
2017-01-27 21:58:00,On Time,-,2017-01-30 06:50:00
2017-01-28 22:03:00,Late,15 Mins,2017-01-30 07:05:00
2017-01-29 21:50:00,Late,10 Mins,2017-01-31 07:00:00
2017-01-30 21:50:00,Late,15 Mins,2017-02-01 07:05:00
2017-01-31 21:50:00,On Time,-,2017-02-02 06:50:00
2017-02-01 21:50:00,Before,-,2017-02-03 06:35:00
2017-02-02 21:50:00,On Time,-,2017-02-04 06:50:00
2017-02-03 21:50:00,Late,03 Hrs 55 Mins,2017-02-05 10:45:00
2017-02-04 22:00:00,On Time,-,2017-02-07 06:50:00
2017-02-05 21:50:00,Late,02 Hrs 30 Mins,2017-02-07 09:20:00
2017-02-06 22:00:00,Late,04 Hrs 20 Mins,2017-02-08 11:10:00
2017-02-07 21:50:00,Late,15 Mins,2017-02-09 07:05:00
2017-02-08 21:50:00,Late,33 Mins,2017-02-10 07:23:00
2017-02-09 21:50:00,Late,15 Mins,2017-02-11 07:05:00
2017-02-10 21:58:00,On Time,-,2017-02-12 06:50:00
2017-02-11 21:50:00,Late,02 Hrs 30 Mins,2017-02-13 09:20:00
2017-02-12 21:50:00,Late,05 Mins,2017-02-14 06:55:00
2017-02-13 21:50:00,Late,10 Mins,2017-02-15 07:00:00
2017-02-14 21:50:00,Late,15 Mins,2017-02-17 07:05:00
2017-02-15 21:50:00,Late,02 Hrs 10 Mins,2017-02-17 09:00:00
2017-02-16 21:50:00,Late,15 Mins,2017-02-19 07:05:00
2017-02-17 21:58:00,Before,-,2017-02-19 06:35:00
2017-02-18 21:50:00,On Time,-,2017-02-20 06:50:00
2017-02-19 22:25:00,Late,10 Mins,2017-02-22 07:00:00
2017-02-20 22:02:00,Late,10 Mins,2017-02-22 07:00:00
2017-02-21 21:50:00,Late,15 Mins,2017-02-23 07:05:00
2017-02-22 21:58:00,Before,-,2017-02-25 06:40:00
2017-02-23 21:50:00,On Time,-,2017-02-26 06:50:00
2017-02-24 21:50:00,Late,10 Mins,2017-02-27 07:00:00
2017-02-25 21:50:00,Late,05 Hrs 50 Mins,2017-02-27 12:40:00
2017-02-26 21:50:00,Late,15 Mins,2017-02-28 07:05:00
2017-02-27 21:50:00,Late,15 Mins,2017-03-01 07:05:00
2017-02-28 21:50:00,Late,01 Hr 55 Mins,2017-03-02 08:45:00
2017-03-01 21:50:00,Late,01 Hr 25 Mins,2017-03-03 08:15:00
2017-03-02 21:50:00,Late,15 Mins,2017-03-05 07:05:00
2017-03-03 21:50:00,Late,15 Mins,2017-03-06 07:05:00
2017-03-04 21:58:00,On Time,-,2017-03-06 06:50:00
2017-03-05 21:50:00,Late,30 Mins,2017-03-07 07:20:00
2017-03-06 21:57:00,Late,15 Mins,2017-03-08 07:05:00
2017-03-07 21:50:00,Before,-,2017-03-09 06:45:00
2017-03-08 21:50:00,Before,-,2017-03-10 06:35:00
2017-03-09 21:57:00,Before,-,2017-03-11 06:45:00
2017-03-11 22:00:00,Before,-,2017-03-14 06:45:00
2017-03-12 21:50:00,Late,15 Mins,2017-03-14 07:05:00
2017-03-13 21:50:00,Late,10 Mins,2017-03-15 07:00:00
2017-03-14 21:50:00,Late,08 Mins,2017-03-17 06:58:00
2017-03-15 21:50:00,Late,01 Hr 10 Mins,2017-03-17 08:00:00
2017-03-16 21:50:00,Late,05 Mins,2017-03-18 06:55:00
2017-03-17 22:00:00,Late,15 Mins,2017-03-20 07:05:00
2017-03-18 21:50:00,Late,10 Mins,2017-03-20 07:00:00
2017-03-19 21:50:00,Late,15 Mins,2017-03-21 07:05:00
2017-03-20 22:00:00,Late,13 Mins,2017-03-23 07:03:00
2017-03-21 21:50:00,Late,15 Mins,2017-03-23 07:05:00
2017-03-22 21:50:00,Late,15 Mins,2017-03-24 07:05:00
File renamed without changes.
Empty file added HintApp/HintApp/__init__.py
Empty file.
Binary file added HintApp/HintApp/__init__.pyc
Binary file not shown.
Binary file removed HintApp/HintApp/__pycache__/__init__.cpython-35.pyc
Binary file not shown.
Binary file removed HintApp/HintApp/__pycache__/settings.cpython-35.pyc
Binary file not shown.
Binary file removed HintApp/HintApp/__pycache__/wsgi.cpython-35.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions HintApp/HintApp/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Django settings for HintApp project.
Generated by 'django-admin startproject' using Django 1.10.6.
Generated by 'django-admin startproject' using Django 1.10.5.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
Expand All @@ -20,7 +20,7 @@
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '*#=__$2p_!089h=u49k+()8p8rhn%5elb@-+u534-*e@qkd&$k'
SECRET_KEY = '3lwuwkdyd6unj$sbz(x-ksxc!zj5+tj=kr#*rfpntamg6byk+r'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand Down
Binary file added HintApp/HintApp/settings.pyc
Binary file not shown.
5 changes: 3 additions & 2 deletions HintApp/HintApp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from django.contrib import admin
from predictor import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$',views.index,name='index'),
url(r'^admin/', admin.site.urls),\
url(r'^$',views.handle_query,name='index'),
url(r'^predict/$',views.result,name='pred')
]
Binary file not shown.
Binary file added HintApp/HintApp/wsgi.pyc
Binary file not shown.
Binary file modified HintApp/db.sqlite3
Binary file not shown.
Empty file modified HintApp/manage.py
100644 → 100755
Empty file.
15 changes: 10 additions & 5 deletions HintApp/predictor/NEO.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pandas as pd
from sklearn.neighbors import KNeighborsClassifier
from sklearn.preprocessing import LabelEncoder
import Neon.get_online_data as get_online_data
from . import get_online_data
from oauth2client.service_account import ServiceAccountCredentials
import gspread

Expand All @@ -25,16 +25,16 @@ def getdata_and_train(self,train_no):
# Train the model of particular locomotive
# Example : Get train data from user. convert results to DataFrame and feed it.

def predict_delay(self):
X = preprocess_and_add_data()
def predict_delay(self,data):
X = preprocess_and_add_data(data)
prediction = self.clf.predict(X)
return prediction
#based on training will predict delay of locomotive next day




def preprocess_and_add_data():
def preprocess_and_add_data(data):
df = pd.read_csv('.data.csv')
df.fillna(value=0, inplace=True)
columns = df.columns.values
Expand Down Expand Up @@ -73,4 +73,9 @@ def Get_UserData():
ind = (len(sheet.get_all_values()))
return ((sheet.row_values(ind))[:2])

print Get_UserData()
n = Neon_Engine()
l = Get_UserData()
print l[0]
print l[1]
n.getdata_and_train(l[0])
print(n.predict_delay(l[1]))
Binary file added HintApp/predictor/NEO.pyc
Binary file not shown.
Empty file added HintApp/predictor/__init__.py
Empty file.
Binary file added HintApp/predictor/__init__.pyc
Binary file not shown.
Binary file added HintApp/predictor/admin.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions HintApp/predictor/get_online_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import urllib.request
import urllib
from bs4 import BeautifulSoup
import datetime
def StartTime_DateTime_Conveter(string):
Expand Down Expand Up @@ -26,7 +26,7 @@ def ReachTime_DateTime_Conveter(string):

def Create_DataFile(train_no):
data_file = open(".data.csv","w")
f = urllib.request.urlopen("http://runningstatus.in/history/"+str(train_no)+"/thisyear")
f = urllib.urlopen("http://runningstatus.in/history/"+str(train_no)+"/thisyear")
soup = BeautifulSoup(f,"html.parser")
table = soup.body.table
l = table.get_text().split("\n")
Expand Down
Binary file added HintApp/predictor/get_online_data.pyc
Binary file not shown.
Empty file.
Binary file added HintApp/predictor/migrations/__init__.pyc
Binary file not shown.
Binary file not shown.
Binary file added HintApp/predictor/models.pyc
Binary file not shown.
30 changes: 19 additions & 11 deletions HintApp/predictor/views.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
from django.shortcuts import render
from Neon import NEO
from Neon import get_online_data
from django.shortcuts import HttpResponseRedirect
from . import NEO
from . import get_online_data
# Create your views here.


from .NEO import Get_UserData

def index(request):
return render(request,'index.html',{'title':'Welcome To Train Prediction'})

def handle_query(request):
if request.menthod == 'POST':
train_no = request['train_no']
myneon = NEO.Neon_Engine()
myneon.getdata_and_train(train_no=train_no)
res = str(myneon.predict_delay())
return render(request,'result.html',{'title':'Status',
'result':res}
)
if request.method == 'POST':
HttpResponseRedirect("/predict")

else:
return render(request, 'index.html', {'title': 'Welcome To Train Prediction'})

def result(request):
l = Get_UserData()
train_no = l[0]
date = l[1]
myneon = NEO.Neon_Engine()
myneon.getdata_and_train(train_no=train_no)
res = str(myneon.predict_delay(data=date))
return render(request, 'result.html', {'title': 'Status',
'result': res}
)

Binary file added HintApp/predictor/views.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion Neon/get_online_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def ReachTime_DateTime_Conveter(string):

def Create_DataFile(train_no):
data_file = open(".data.csv","w")
f = urllib.request.urlopen("http://runningstatus.in/history/"+str(train_no)+"/thisyear")
f = urllib.urlopen("http://runningstatus.in/history/"+str(train_no)+"/thisyear")
soup = BeautifulSoup(f,"html.parser")
table = soup.body.table
l = table.get_text().split("\n")
Expand Down
Binary file modified Neon/get_online_data.pyc
Binary file not shown.

0 comments on commit 12c80b2

Please sign in to comment.