Skip to content
Snippets Groups Projects
Commit b4f01715 authored by Chauhan Chauhan's avatar Chauhan Chauhan
Browse files

Delete 3217-classification-lr-example5.py

parent 65cc8040
No related branches found
No related tags found
No related merge requests found
#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))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment