Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2021-210
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
2021-210
2021-210
Commits
0c73f140
Commit
0c73f140
authored
Jul 05, 2021
by
isurugunarathna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Python model
parent
a1c993d4
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1050 additions
and
0 deletions
+1050
-0
diet_plan/logistic_regression_weight.py
diet_plan/logistic_regression_weight.py
+50
-0
diet_plan/weight_data.csv
diet_plan/weight_data.csv
+1000
-0
No files found.
diet_plan/logistic_regression_weight.py
0 → 100644
View file @
0c73f140
#import pandas
import
pandas
as
pd
col_names
=
[
'breed'
,
'age'
,
'weight'
,
'label'
]
# load dataset
pima
=
pd
.
read_csv
(
"weight_data.csv"
,
header
=
None
,
names
=
col_names
)
print
(
"==================="
)
print
(
"Dataset head"
)
print
(
"==================="
)
print
(
pima
.
head
())
#split dataset in features and target variable
feature_cols
=
[
'breed'
,
'age'
,
'weight'
]
X
=
pima
[
feature_cols
]
# Features
y
=
pima
.
label
# Target variable
from
sklearn.model_selection
import
train_test_split
X_train
,
X_test
,
y_train
,
y_test
=
train_test_split
(
X
,
y
,
test_size
=
0.25
,
random_state
=
0
)
# import the class
from
sklearn.linear_model
import
LogisticRegression
# instantiate the model (using the default parameters)
logreg
=
LogisticRegression
()
# fit the model with data
logreg
.
fit
(
X_train
,
y_train
)
#
y_pred
=
logreg
.
predict
(
X_test
)
# import the metrics class
from
sklearn
import
metrics
cnf_matrix
=
metrics
.
confusion_matrix
(
y_test
,
y_pred
)
print
(
"==================="
)
print
(
"Confusion matrix"
)
print
(
"==================="
)
print
(
cnf_matrix
)
print
(
"==================="
)
print
(
"Accuracy"
)
print
(
"==================="
)
print
(
"Accuracy:"
,
metrics
.
accuracy_score
(
y_test
,
y_pred
))
# print("Precision:",metrics.precision_score(y_test, y_pred))
# print("Recall:",metrics.recall_score(y_test, y_pred))
# Prediction test
y_prediction_test
=
logreg
.
predict
([[
12
,
3
,
48
]])
y_labels
=
[
"Overweight"
,
"Normal"
,
"Underweight"
]
print
(
y_labels
[
y_prediction_test
[
0
]])
diet_plan/weight_data.csv
0 → 100644
View file @
0c73f140
This diff is collapsed.
Click to expand it.
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