Commit 4ee6d524 authored by Chalaka Tharindu Jayasinghe's avatar Chalaka Tharindu Jayasinghe

Merge branch 'ServiceChargePrediction' into 'master'

service charge prediction completed

See merge request !33
parents 9c42be55 f9f1b865
This diff is collapsed.
......@@ -912,33 +912,24 @@ def NextMaintain(request):
# message_count = int(parts[0])
# print(message_count)
# ARIMA SECTION
# inputdate = '12/01/2020'
# HERE I USE AN EXMAMPLE FROM MATPLOTLIB SITE
# Data for plotting
# t = np.arange(0.0, 2.0, 0.01)
# s = 1 + np.sin(2 * np.pi * t)
import numpy as np
import matplotlib.pyplot as plt
#ARIMA SECTION
df2 = pd.read_csv('Data/MaintainData.csv')
df2 = df2[(df2["Customer"] == customerid)]
df2 = df2[(df2["Service"] == ServiceType)]
df = df2[(df2["VehicleNumber"] == Vnumber)]
#df.drop('Service','ServiceName','TakenTime','Customer','VehicleType','VehicleMake','VehicleModel','VehicleNumber','MeterReading','VehicleManufacturedYear','AvergeUsage','mailID', axis=1, inplace=True)
df = df.drop(columns=['Service','ServiceName','TakenTime','Customer','VehicleType','VehicleMake','VehicleModel','VehicleNumber','MeterReading','VehicleManufacturedYear','AvergeUsage','mailID', ])
# df.drop('Service','ServiceName','TakenTime','Customer','VehicleType','VehicleMake','VehicleModel','VehicleNumber','MeterReading','VehicleManufacturedYear','AvergeUsage','mailID', axis=1, inplace=True)
df = df.drop(columns=['Service', 'ServiceName', 'TakenTime', 'Customer', 'VehicleType', 'VehicleMake',
'VehicleModel', 'VehicleNumber', 'MeterReading', 'VehicleManufacturedYear',
'AvergeUsage', 'mailID', ])
df.head()
## Cleaning up the data
df.columns = ["Date", "Price"]
rrr = df.head()
## Drop last 2 rows
#df.drop(106, axis=0, inplace=True)
#df.tail()
# df.drop(106, axis=0, inplace=True)
# df.tail()
# df.drop(105, axis=0, inplace=True)
# df.tail()
......@@ -996,26 +987,23 @@ def NextMaintain(request):
future_df = pd.concat([df, future_datest_df])
print(future_df)
Datefinding = int(df.shape[1] + 15)
print(Datefinding)
forecastedPrice = future_df['forecast'] = results.predict(start=Datefinding, end=Datefinding, dynamic=True)
print("its Arima output")
forecastedPrice = (forecastedPrice.to_string())
print("Arima output - Servport price prediction")
forecastedPrice = str(forecastedPrice.to_list()[0])
forecastedPrice = int(float(forecastedPrice))
forecastedPrice = str(forecastedPrice)
print(forecastedPrice)
print(forecastedPrice[5:13])
else:
form = MyFormServices()
context = {'form': form,'d': "CUSTOMER NOT FOUND"}
context = {'form': form, 'd': "CUSTOMER NOT FOUND"}
return render(request, 'Admin/NextMaintain.html', context)
context = { 'form': form, 'd': enddate , 'forecastedPrice':' Rs ' + forecastedPrice[5:13] }
context = {'form': form, 'd': enddate, 'forecastedPrice': ' Rs ' + forecastedPrice}
return render(request, 'Admin/NextMaintain.html', context)
else:
......@@ -1027,7 +1015,7 @@ def NextMaintain(request):
def MaintainData(request):
data1 = pd.read_csv('Data/MaintainData.csv')
finalpt = data1.head(10)
finalpt = data1.head(518)
json_records = finalpt.reset_index().to_json(orient='records')
arr = []
arr = json.loads(json_records)
......@@ -1062,10 +1050,3 @@ def AdminHome(request):
No preview for this file type
......@@ -24,7 +24,7 @@
{% endif %}
<div class="card-heading">
<h2 class="title"> MAINTAINS DATA </h2>
<h2 class="title mt-3" style="color: #02111f;"> MAINTENANCE DATA </h2>
</div>
......@@ -33,57 +33,41 @@
<div class="card card-body printableArea">
<div class="container" style="overflow-x:auto;">
Customer Maintains Data
<table class="table table-striped">
<thead>
<tr>
<th> Service Date </th>
<th> Service </th>
<th> Taken Time </th>
<th> Price </th>
<th> Customer </th>
<th> Vehicle Type </th>
<th> Vehicle Make </th>
<th> Vehicle Model </th>
<th> Vehicle Number </th>
<th> Meter Reading </th>
<th> Vehicle Manufactured Year </th>
<th> Average Usage </th>
<th>Service Date</th>
<th>Service</th>
<th>Taken Time</th>
<th>Price</th>
<th>Customer</th>
<th>Vehicle Type</th>
<th>Vehicle Make</th>
<th>Vehicle Model</th>
<th>Vehicle Number</th>
<th>Meter Reading</th>
<th>Vehicle Manufactured Year</th>
<th>Average Usage</th>
</tr>
</thead>
<tbody>
{% if d %}
{% for i in d %}
<tr>
<td>{{i.Date}}</td>
<td>{{i.ServiceName}}</td>
<td>{{i.TakenTime}}</td>
<td>{{i.Price}}</td>
<td>{{i.Customer}}</td>
<td>{{i.VehicleType}} </td>
<td>{{i.VehicleMake}} </td>
<td>{{i.VehicleModel}} </td>
<td>{{i.VehicleNumber}} </td>
<td>{{i.MeterReading}} </td>
<td>{{i.VehicleManufacturedYear}} </td>
<td>{{i.AverageUsage}} </td>
<td>{{i.VehicleType}}</td>
<td>{{i.VehicleMake}}</td>
<td>{{i.VehicleModel}}</td>
<td>{{i.VehicleNumber}}</td>
<td>{{i.MeterReading}}</td>
<td>{{i.VehicleManufacturedYear}}</td>
<td>{{i.AverageUsage}}</td>
</tr>
{% endfor %}
{% endif %}
......@@ -115,10 +99,10 @@
<div class="card-body">
<input name="b_print" type="button" class="btn btn-primary btn-print" onClick="printdiv('div_print');" value=" Print ">
<input name="b_print" type="button" class="btn btn-print" onClick="printdiv('div_print');" value=" Print " style="background: #02111f;">
</div>
<div class="alert alert-primary" role="alert" >© SMART SERVICE STATION 2022 </div>
<div class="alert alert-primary fixed-bottom mb-0 text-center" style="background: #747578; border: none; color: white;" role="alert" > © SERVPORT 2022 </div>
</div>
......
......@@ -15,16 +15,18 @@
<div style="margin-left: 0px;" class="card card-5">
<br/><br/>
{% if messages %}
<ul class="messages">
<div class="alert alert-danger" role="alert">
{% for message in messages %}
<li {% if message.tags %} class=" {{ message.tags }} " {% endif %}> {{ message }} </li>
{% if message.tags %} {% endif %} {{ message }}
{% endfor %}
</ul>
</div>
{% endif %}
<div class="card-heading">
<h2 class="title"> NEXT MAINTAIN DATE PREDICTION </h2>
<h2 class="title" style="color:#02111f"> NEXT MAINTAIN DATE PREDICTION </h2>
</div>
......@@ -40,38 +42,42 @@
</table>
<input type="submit" value="NEXT MAINTAIN DATE" class="btn btn--radius-2 btn-primary"/>
<input type="submit" value="NEXT MAINTAIN DATE" class="btn btn--radius-2 btn" style="background:#02111f"/>
</form>
<br>
{% if d %}
<center> <div class="alert alert-success">
{{ d }}
{{ forecastedPrice }}
Predicted Date: {{ d }}
<br/>
Approximate Price: {{ forecastedPrice }}
</div> </center>
{% endif %}
<br>
</div>
</div>
</div>
<br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br>
</div>
</div>
</div>
<div class="alert alert-primary" role="alert" >© SMART SERVICE STATION 2022 </div>
<div class="alert alert-primary fixed-bottom mb-0 text-center" style="background: #747578; border: none; color: white;" role="alert" > © SERVPORT 2022 </div>
</div>
{% endblock content %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment