Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-323
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
1
Merge Requests
1
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
2023-323
2023-323
Commits
92efee9e
Commit
92efee9e
authored
May 22, 2023
by
Kareshaan Logeswaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created It20008628 backend
parent
99ffd648
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
cost.py
cost.py
+50
-0
No files found.
cost.py
0 → 100644
View file @
92efee9e
from
flask
import
Flask
,
request
,
render_template
import
numpy
as
np
from
joblib
import
load
app
=
Flask
(
__name__
)
model
=
load
(
'XGB_All_1_model.joblib'
)
@
app
.
route
(
'/predictcost'
,
methods
=
[
'POST'
])
def
predict
():
Year
=
int
(
request
.
form
[
'Year'
])
Season
=
int
(
request
.
form
[
'Season'
])
Preliminary_Dev
=
int
(
request
.
form
[
'Preliminary_Dev'
])
Ploughing
=
int
(
request
.
form
[
'Ploughing'
])
Levelling
=
int
(
request
.
form
[
'Levelling'
])
Transplanting
=
int
(
request
.
form
[
'Transplanting'
])
Plastering
=
int
(
request
.
form
[
'Plastering'
])
Fertilization
=
int
(
request
.
form
[
'Fertilization'
])
Harvesting
=
int
(
request
.
form
[
'Harvesting'
])
Threshing
=
int
(
request
.
form
[
'Threshing'
])
Winnowing
=
int
(
request
.
form
[
'Winnowing'
])
Tot_without_Imputed
=
int
(
request
.
form
[
'Tot_without_Imputed'
])
Seeding
=
int
(
request
.
form
[
'Seeding'
])
Hired_Labour
=
int
(
request
.
form
[
'Hired_Labour'
])
Family_Labour
=
int
(
request
.
form
[
'Family_Labour'
])
Fertilizer_Purchase
=
int
(
request
.
form
[
'Fertilizer_Purchase'
])
Average_Yield
=
int
(
request
.
form
[
'Average_Yield'
])
feature_list
=
[
Year
,
Season
,
Preliminary_Dev
,
Ploughing
,
Levelling
,
Transplanting
,
Plastering
,
Fertilization
,
Harvesting
,
Threshing
,
Winnowing
,
Tot_without_Imputed
,
Seeding
,
Hired_Labour
,
Family_Labour
,
Fertilizer_Purchase
,
Average_Yield
]
single_pred
=
np
.
array
(
feature_list
)
.
reshape
(
1
,
-
1
)
prediction
=
model
.
predict
(
single_pred
)
result
=
"Predicted Price: {:.2f}"
.
format
(
prediction
[
0
])
+
" Rs/kg"
return
render_template
(
'cost.html'
,
result
=
result
)
@
app
.
route
(
'/'
)
def
index
():
return
render_template
(
'cost.html'
)
# python main
if
__name__
==
'__main__'
:
#app.run(debug=True)
app
.
run
(
host
=
'127.0.0.1'
,
port
=
5010
)
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