Here, we are taking a breast cancer dataset wherein we have classified according to whether the cancer is benign/malignant.
The following is for importing all the required libraries:
import pandas as pd import numpy as np from sklearn import svm, datasets from sklearn.svm import SVC import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.model_selection import GridSearchCV from sklearn.metrics import classification_report from sklearn.utils import shuffle %matplotlib inline
Now, let's load the breast cancer dataset:
BC_Data = datasets.load_breast_cancer()
The following allows us to check the details of the dataset:
print(BC_Data.DESCR)
This if for splitting the dataset into train and test:
X_train, X_test, y_train, y_test = train_test_split(BC_Data.data, BC_Data.target, random_state=0)
This is for setting the model with the linear kernel and finding out the accuracy:
C= 1.0 svm= SVC(kernel="linear...