Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
21_22-J 31
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J 31
21_22-J 31
Commits
5e89f65f
Commit
5e89f65f
authored
Jan 09, 2022
by
Withana R.D.K
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Employee Efficiency
parent
a62106af
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
729 additions
and
107 deletions
+729
-107
Data/WorkHistory.csv
Data/WorkHistory.csv
+516
-102
User/forms.py
User/forms.py
+6
-2
User/urls.py
User/urls.py
+1
-0
User/views.py
User/views.py
+87
-2
templates/Admin/Employee_Efficiency.html
templates/Admin/Employee_Efficiency.html
+118
-0
templates/Admin/Sidebar2.html
templates/Admin/Sidebar2.html
+1
-1
No files found.
Data/WorkHistory.csv
View file @
5e89f65f
This diff is collapsed.
Click to expand it.
User/forms.py
View file @
5e89f65f
...
@@ -6,7 +6,11 @@ from . import models
...
@@ -6,7 +6,11 @@ from . import models
MODE_CHOICES
=
[
MODE_CHOICES
=
[
(
'0'
,
'Select Work'
),
(
'0'
,
'Select Work'
),
(
'1'
,
'Engine Repairering'
),
(
'1'
,
'Engine Repairering'
),
(
'2'
,
'Painting'
)
(
'2'
,
'Painting'
),
(
'3'
,
'Oil Changing'
),
(
'4'
,
'Interior Cleaning'
),
(
'5'
,
'Body Wash'
),
(
'6'
,
'Under Wash'
)
]
]
MODE_DEMAND
=
[
MODE_DEMAND
=
[
...
@@ -23,7 +27,7 @@ class MyForm4(forms.Form):
...
@@ -23,7 +27,7 @@ class MyForm4(forms.Form):
inputdate
=
forms
.
DateField
(
widget
=
DateInput
)
inputdate
=
forms
.
DateField
(
widget
=
DateInput
)
class
MyForm
(
forms
.
Form
):
class
MyForm
5
(
forms
.
Form
):
customerid
=
forms
.
IntegerField
(
label
=
"Select Work To be Done"
,
widget
=
forms
.
Select
(
choices
=
MODE_CHOICES
))
customerid
=
forms
.
IntegerField
(
label
=
"Select Work To be Done"
,
widget
=
forms
.
Select
(
choices
=
MODE_CHOICES
))
...
...
User/urls.py
View file @
5e89f65f
...
@@ -12,6 +12,7 @@ urlpatterns = [
...
@@ -12,6 +12,7 @@ urlpatterns = [
path
(
'AdminHome/'
,
responseapp_views
.
AdminHome
),
path
(
'AdminHome/'
,
responseapp_views
.
AdminHome
),
path
(
'Employee_Data/'
,
responseapp_views
.
Employee_Data
),
path
(
'Employee_Data/'
,
responseapp_views
.
Employee_Data
),
path
(
'EmployeeStatus_Update/'
,
responseapp_views
.
EmployeeStatus_Update
),
path
(
'EmployeeStatus_Update/'
,
responseapp_views
.
EmployeeStatus_Update
),
path
(
'Employee_Efficiency/'
,
responseapp_views
.
Employee_Efficiency
),
path
(
'PurchaseHistory/'
,
responseapp_views
.
PurchaseHistory
),
path
(
'PurchaseHistory/'
,
responseapp_views
.
PurchaseHistory
),
path
(
'Forecasting/'
,
responseapp_views
.
Forecasting
),
path
(
'Forecasting/'
,
responseapp_views
.
Forecasting
),
path
(
'Result/'
,
responseapp_views
.
Forecasting
),
path
(
'Result/'
,
responseapp_views
.
Forecasting
),
...
...
User/views.py
View file @
5e89f65f
...
@@ -2,7 +2,9 @@ from datetime import datetime
...
@@ -2,7 +2,9 @@ from datetime import datetime
from
django.shortcuts
import
render
,
redirect
,
reverse
from
django.shortcuts
import
render
,
redirect
,
reverse
from
django.template
import
loader
from
django.template
import
loader
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
User.forms
import
MyForm
,
MyForm2
,
MyForm3
,
MyForm4
from
sklearn.tree
import
DecisionTreeClassifier
from
User.forms
import
MyForm
,
MyForm2
,
MyForm3
,
MyForm4
,
MyForm5
from
django.contrib.auth
import
authenticate
,
login
from
django.contrib.auth
import
authenticate
,
login
from
User
import
models
as
Umodels
from
User
import
models
as
Umodels
from
django.http
import
HttpResponseRedirect
from
django.http
import
HttpResponseRedirect
...
@@ -35,7 +37,90 @@ def Homepage(request):
...
@@ -35,7 +37,90 @@ def Homepage(request):
return
render
(
request
,
'Admin/Homepage.html'
);
return
render
(
request
,
'Admin/Homepage.html'
);
# End CompanyHome
# End CompanyHome
# Employee_Efficency
# Employee_Efficiency
def
Employee_Efficiency
(
request
):
if
request
.
method
==
'POST'
:
myForm
=
MyForm5
(
request
.
POST
)
if
myForm
.
is_valid
():
workid
=
myForm
.
cleaned_data
[
'customerid'
]
DateSet
=
pd
.
read_csv
(
"Data/WorkHistory.csv"
,
skipinitialspace
=
True
)
DateSet
[
'JobDone'
]
.
replace
({
'Engine Repairering'
:
1
,
'Painting'
:
2
,
'Oil Changing'
:
3
,
'Interior Cleaning'
:
4
,
'Body Wash'
:
5
,
'Under Wash'
:
6
},
inplace
=
True
)
DateSet
=
DateSet
[(
DateSet
.
WorkQuality
>
1
)]
# search for job need to be done
DateSet
=
DateSet
.
drop
(
columns
=
[
'WorkQuality'
])
x
=
DateSet
[[
'JobDone'
,
'TakenTime'
]]
y
=
DateSet
[[
'StaffID'
]]
grouped_df
=
DateSet
[(
DateSet
[
"JobDone"
]
==
workid
)]
# get selected work
grouped_df
=
grouped_df
.
groupby
(
"StaffID"
)
# group job staff
grouped_df
=
grouped_df
[
'TakenTime'
]
# get only taken time to complete work
mean_df
=
grouped_df
.
mean
()
# avarage time to complete work
min_df
=
mean_df
.
min
()
# get less time taken to complete work
# x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.3, random_state=2)
# lm = LinearRegression()
# lm.fit(x_train, y_train)
#
# new_input = [[workid, min_df]] # Best WorkQuality Work
# pred = lm.predict(new_input)
# workid = (int(pred.round())) # final employee ID by ML
#
# print("--------------Accuracy-----------------")
# accuracy = lm.score(x_test, y_test)
# print(accuracy)
X_train
,
X_test
,
y_train
,
y_test
=
train_test_split
(
x
,
y
,
test_size
=
0.3
,
random_state
=
2
)
clf
=
DecisionTreeClassifier
()
clf
=
clf
.
fit
(
X_train
,
y_train
)
y_pred
=
clf
.
predict
(
X_test
)
new_input
=
[[
workid
,
min_df
]]
# Best WorkQuality Work
pred
=
clf
.
predict
(
new_input
)
workid
=
(
int
(
pred
.
round
()))
# final employee ID by ML
print
(
"Accuracy:"
,
metrics
.
accuracy_score
(
y_test
,
y_pred
))
DateSetLoad
=
pd
.
read_csv
(
"Data/WorkHistory.csv"
,
skipinitialspace
=
True
)
data2
=
pd
.
read_csv
(
'Data/EmployeeStatus.csv'
)
# using merge function by setting how='inner'
output1
=
pd
.
merge
(
DateSetLoad
,
data2
,
on
=
'StaffID'
,
how
=
'inner'
)
DateSetResult
=
DateSetLoad
[(
output1
.
StaffID
==
workid
)
&
(
output1
.
Availability
==
"Yes"
)]
df
=
DateSetResult
[:
1
]
# data = data.to_html()
# ----------------------------------------------------------------------- aaAccuracy section
# ----------------------------------------------------------------------- aaAccuracy section
json_records
=
df
.
reset_index
()
.
to_json
(
orient
=
'records'
)
arr
=
[]
arr
=
json
.
loads
(
json_records
)
if
(
arr
==
[]
):
DateSetResult
=
DateSetLoad
[(
output1
.
Availability
==
"Yes"
)]
df
=
DateSetResult
[:
1
]
# data = data.to_html()
json_records
=
df
.
reset_index
()
.
to_json
(
orient
=
'records'
)
arr
=
[]
arr
=
json
.
loads
(
json_records
)
else
:
a
=
2
form
=
MyForm5
()
context
=
{
'form'
:
form
,
'd'
:
arr
}
return
render
(
request
,
'Admin/Employee_Efficiency.html'
,
context
)
else
:
form
=
MyForm5
()
return
render
(
request
,
'Admin/Employee_Efficiency.html'
,
{
'form'
:
form
});
def
Employee_Data
(
request
):
def
Employee_Data
(
request
):
data1
=
pd
.
read_csv
(
'Data/WorkHistory.csv'
)
data1
=
pd
.
read_csv
(
'Data/WorkHistory.csv'
)
data2
=
pd
.
read_csv
(
'Data/EmployeeStatus.csv'
)
data2
=
pd
.
read_csv
(
'Data/EmployeeStatus.csv'
)
...
...
templates/Admin/Employee_Efficiency.html
0 → 100644
View file @
5e89f65f
{% extends 'Admin/Sidebar2.html' %}
{% block content %}
{% load widget_tweaks %}
{%load static%}
<head>
<!-- Font special for pages-->
<link
href=
"https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i"
rel=
"stylesheet"
>
<!-- Main CSS-->
<link
href=
"{% static "
css
/
main
.
css
"
%}"
rel=
"stylesheet"
media=
"all"
>
</head>
<div
class=
" >
<div class="
wrapper
wrapper
0
"
>
<div
style=
"margin-left: 0px;"
class=
"card card-5"
>
{% if messages %}
<ul
class=
"messages"
>
{% for message in messages %}
<li
{%
if
message
.
tags
%}
class=
" {{ message.tags }} "
{%
endif
%}
>
{{ message }}
</li>
{% endfor %}
</ul>
{% endif %}
<div
class=
"card-heading"
>
<h2
class=
"title"
>
EMPLOYEE EFFICIENCY PREDICTION
</h2>
</div>
<div
id=
"myDiv"
>
<div
id=
"div_print"
>
<div
class=
"card card-body printableArea"
>
<div
role=
"alert"
>
<div
class=
"container"
style=
"overflow-x:auto;"
>
<table
class=
"table table-striped"
>
<thead>
<tr>
<th>
StaffID
</th>
<th>
EmployeeName
</th>
<th>
Available Status
</th>
</tr>
</thead>
<tbody>
{% if d %}
{% for i in d %}
<tr>
<td>
{{i.StaffID}}
</td>
<td>
{{i.EmployeeName}}
</td>
<td><div
class=
"alert alert-success"
>
Available
</div></td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
</div>
</div></div></div>
<script
language=
"javascript"
>
function
printdiv
(
printpage
)
{
var
headstr
=
"
<html><head><title></title></head><body>
"
;
var
footstr
=
"
</body>
"
;
var
newstr
=
document
.
all
.
item
(
printpage
).
innerHTML
;
var
oldstr
=
document
.
body
.
innerHTML
;
document
.
body
.
innerHTML
=
headstr
+
newstr
+
footstr
;
window
.
print
();
document
.
body
.
innerHTML
=
oldstr
;
location
.
reload
();
return
false
;
}
</script>
<div
class=
"card-body"
>
<form
action=
"/Admin/Employee_Efficiency/"
method=
"post"
>
{% csrf_token %}
<table
class=
"table table-light"
>
{{form.as_table}}
</table>
<input
type=
"submit"
value=
"PREDICT EMPLOYEE"
class=
"btn btn--radius-2 btn-primary"
/>
</form>
<br><div
class=
"text-right"
>
<input
name=
"b_print"
type=
"button"
class=
"btn btn-primary btn-print"
onClick=
"printdiv('div_print');"
value=
" Print "
>
</div>
<br>
</div>
</div>
</div>
<div
class=
"alert alert-primary"
role=
"alert"
>
© SMART SERVICE STATION 2022
</div>
</div>
{% endblock content %}
templates/Admin/Sidebar2.html
View file @
5e89f65f
...
@@ -178,7 +178,7 @@ body{
...
@@ -178,7 +178,7 @@ body{
<ul>
<ul>
<li><a
style=
"text-decoration:none;"
href=
"/Admin/AdminHome/"
><i
class=
"fas fa-desktop"
></i>
Home
</a></li>
<li><a
style=
"text-decoration:none;"
href=
"/Admin/AdminHome/"
><i
class=
"fas fa-desktop"
></i>
Home
</a></li>
<li><a
style=
"text-decoration:none;"
href=
"#"
><i
class=
"fas fa-car "
></i>
Customer Registration
</a>
<li><a
style=
"text-decoration:none;"
href=
"#"
><i
class=
"fas fa-car "
></i>
Customer Registration
</a>
<li><a
style=
"text-decoration:none;"
href=
"
#
"
><i
class=
"fas fa-barcode"
></i>
Employee Efficiency
</a>
<li><a
style=
"text-decoration:none;"
href=
"
/Admin/Employee_Efficiency/
"
><i
class=
"fas fa-barcode"
></i>
Employee Efficiency
</a>
<li><a
style=
"text-decoration:none;"
href=
"/Admin/Employee_Data/"
><i
class=
"fas fa-paper-plane "
></i>
Employee Data
</a>
<li><a
style=
"text-decoration:none;"
href=
"/Admin/Employee_Data/"
><i
class=
"fas fa-paper-plane "
></i>
Employee Data
</a>
<li><a
style=
"text-decoration:none;"
href=
"/Admin/EmployeeStatus_Update/"
><i
class=
"fas fa-upload"
></i>
Assign Employee
</a>
<li><a
style=
"text-decoration:none;"
href=
"/Admin/EmployeeStatus_Update/"
><i
class=
"fas fa-upload"
></i>
Assign Employee
</a>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment