Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-362
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
0
Merge Requests
0
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-362
2023-362
Commits
698a53a5
Commit
698a53a5
authored
Oct 23, 2023
by
Nirmal M.D.S
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial commit predict.py
parent
809ec1d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
IT20074340/TaskAllocation/Sachintha/model/predict.py
IT20074340/TaskAllocation/Sachintha/model/predict.py
+34
-0
No files found.
IT20074340/TaskAllocation/Sachintha/model/predict.py
0 → 100644
View file @
698a53a5
from
flask
import
Flask
,
request
,
jsonify
import
pickle
import
requests
from
flask_cors
import
CORS
app
=
Flask
(
__name__
)
CORS
(
app
,
resources
=
{
r"/*"
:
{
"origins"
:
"*"
}})
@
app
.
route
(
'/predict'
,
methods
=
[
'POST'
])
def
predict
():
try
:
data
=
request
.
get_json
()
task_description
=
data
[
'task_description'
]
# Load the classifier and vectorizer from the .pickle files
with
open
(
'classifier.pickle'
,
'rb'
)
as
classifier_file
:
classifier
=
pickle
.
load
(
classifier_file
)
with
open
(
'vectorizer.pickle'
,
'rb'
)
as
vectorizer_file
:
vectorizer
=
pickle
.
load
(
vectorizer_file
)
task_vec
=
vectorizer
.
transform
([
task_description
])
# Predict using the loaded model
prediction
=
classifier
.
predict
(
task_vec
)[
0
]
return
jsonify
({
'prediction'
:
prediction
})
except
Exception
as
e
:
return
jsonify
({
'error'
:
str
(
e
)})
if
__name__
==
'__main__'
:
app
.
run
(
host
=
'127.0.0.1'
,
port
=
5000
,
debug
=
False
)
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