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
c7733665
Commit
c7733665
authored
Oct 23, 2023
by
Nirmal M.D.S
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
final models
parent
1df50156
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
0 deletions
+48
-0
IT20074340/TaskAllocation/Sachintha/model/classifier.pickle
IT20074340/TaskAllocation/Sachintha/model/classifier.pickle
+0
-0
IT20074340/TaskAllocation/Sachintha/model/train.py
IT20074340/TaskAllocation/Sachintha/model/train.py
+48
-0
IT20074340/TaskAllocation/Sachintha/model/vectorizer.pickle
IT20074340/TaskAllocation/Sachintha/model/vectorizer.pickle
+0
-0
No files found.
IT20074340/TaskAllocation/Sachintha/model/classifier.pickle
0 → 100644
View file @
c7733665
File added
IT20074340/TaskAllocation/Sachintha/model/train.py
0 → 100644
View file @
c7733665
from
flask
import
Flask
,
jsonify
,
request
import
pandas
as
pd
from
sklearn.feature_extraction.text
import
TfidfVectorizer
from
sklearn.svm
import
SVC
from
sklearn.model_selection
import
train_test_split
from
sklearn.model_selection
import
GridSearchCV
import
pickle
app
=
Flask
(
__name__
)
def
save_pickle
(
obj
,
filename
):
with
open
(
filename
,
'wb'
)
as
file
:
pickle
.
dump
(
obj
,
file
)
def
train_model
(
data_path
):
# Load and preprocess the data
df
=
pd
.
read_csv
(
data_path
)
X_train
,
_
,
y_train
,
_
=
train_test_split
(
df
[
'TaskDescription'
],
df
[
'Level'
],
test_size
=
0.2
,
random_state
=
42
)
vectorizer
=
TfidfVectorizer
()
X_train_vec
=
vectorizer
.
fit_transform
(
X_train
)
# Initialize GridSearchCV
param_grid
=
{
'C'
:
[
0.1
,
1
,
10
,
100
,
1000
],
'gamma'
:
[
1
,
0.1
,
0.01
,
0.001
,
0.0001
],
'kernel'
:
[
'linear'
,
'rbf'
,
'sigmoid'
]}
grid
=
GridSearchCV
(
SVC
(),
param_grid
,
refit
=
True
,
verbose
=
3
)
grid
.
fit
(
X_train_vec
,
y_train
)
# Save the trained classifier and vectorizer as .pickle files
save_pickle
(
grid
,
'classifier.pickle'
)
save_pickle
(
vectorizer
,
'vectorizer.pickle'
)
return
'Model trained and saved successfully'
@
app
.
route
(
'/train'
,
methods
=
[
'GET'
])
def
trigger_training
():
try
:
result
=
train_model
(
"TaskDescCopy3.csv"
)
return
jsonify
({
'message'
:
result
})
except
Exception
as
e
:
return
jsonify
({
'error'
:
str
(
e
)})
if
__name__
==
'__main__'
:
app
.
run
(
host
=
'127.0.0.1'
,
port
=
5001
,
debug
=
False
)
IT20074340/TaskAllocation/Sachintha/model/vectorizer.pickle
0 → 100644
View file @
c7733665
File added
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