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
423cd88b
Commit
423cd88b
authored
May 20, 2023
by
Kareshaan Logeswaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created It20229948 back end
parent
3568634c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
app final.py
app final.py
+56
-0
No files found.
app final.py
0 → 100644
View file @
423cd88b
import
joblib
from
flask
import
Flask
,
request
,
render_template
import
numpy
as
np
import
pickle
# # Load your machine learning model
model
=
joblib
.
load
(
'finalmodel.joblib'
)
# importing model
#model = pickle.load(open('finalmodel.pkl','rb'))
sc
=
pickle
.
load
(
open
(
'standscaler.pkl'
,
'rb'
))
ms
=
pickle
.
load
(
open
(
'minmaxscaler.pkl'
,
'rb'
))
# creating flask app
app
=
Flask
(
__name__
)
@
app
.
route
(
'/'
)
def
index
():
return
render_template
(
"index.html"
)
@
app
.
route
(
"/predict"
,
methods
=
[
'POST'
])
def
predict
():
N
=
request
.
form
[
'Nitrogen'
]
P
=
request
.
form
[
'Phosporus'
]
K
=
request
.
form
[
'Potassium'
]
temp
=
request
.
form
[
'Temperature'
]
humidity
=
request
.
form
[
'Humidity'
]
ph
=
request
.
form
[
'Ph'
]
feature_list
=
[
N
,
P
,
K
,
temp
,
humidity
,
ph
]
single_pred
=
np
.
array
(
feature_list
)
.
reshape
(
1
,
-
1
)
scaled_features
=
ms
.
transform
(
single_pred
)
final_features
=
sc
.
transform
(
scaled_features
)
prediction
=
model
.
predict
(
final_features
)
crop_dict
=
{
1
:
"AT 354"
,
2
:
"BG 250"
,
3
:
"BG 352"
,
4
:
'Mottaikaruppan'
,
5
:
'Suwandel'
}
if
prediction
[
0
]
in
crop_dict
:
crop
=
crop_dict
[
prediction
[
0
]]
result
=
"{} is the best crop to be cultivated right there"
.
format
(
crop
)
else
:
result
=
"Sorry, we could not determine the best crop to be cultivated with the provided data."
return
render_template
(
'index.html'
,
result
=
result
)
# python main
if
__name__
==
"__main__"
:
app
.
run
(
debug
=
True
)
\ No newline at end of file
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