Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
comp3217-lab2
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chauhan Chauhan
comp3217-lab2
Commits
b4f01715
Commit
b4f01715
authored
2 years ago
by
Chauhan Chauhan
Browse files
Options
Downloads
Patches
Plain Diff
Delete 3217-classification-lr-example5.py
parent
65cc8040
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
3217-classification-lr-example5.py
+0
-34
0 additions, 34 deletions
3217-classification-lr-example5.py
with
0 additions
and
34 deletions
3217-classification-lr-example5.py
deleted
100644 → 0
+
0
−
34
View file @
65cc8040
#Import scikit-learn dataset library
from
sklearn
import
datasets
from
sklearn.model_selection
import
train_test_split
from
sklearn
import
svm
,
metrics
#Load dataset
cancer
=
datasets
.
load_breast_cancer
()
# print the names of the features
print
(
"
Features:
"
,
cancer
.
feature_names
)
# print the label type of cancer('malignant' 'benign')
print
(
"
Labels:
"
,
cancer
.
target_names
)
# print data(feature)shape
print
(
cancer
.
data
.
shape
)
# Split dataset into training set and test set
X_train
,
X_test
,
y_train
,
y_test
=
train_test_split
(
cancer
.
data
,
cancer
.
target
,
test_size
=
0.2
)
# 70% training and 30% test
#Create a svm Classifier
clf
=
svm
.
SVC
(
kernel
=
'
linear
'
)
# Linear Kernel
#Train the model using the training sets
clf
.
fit
(
X_train
,
y_train
)
#Predict the response for test dataset
y_pred
=
clf
.
predict
(
X_test
)
print
(
"
Accuracy:
"
,
metrics
.
accuracy_score
(
y_test
,
y_pred
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment