0% found this document useful (0 votes)
5 views1 page

Practical 9

The document presents a Python script that utilizes the SVC (Support Vector Classification) from the sklearn library to classify breast cancer data. It trains three different models using linear, polynomial, and RBF kernels, evaluates their accuracy on a test set, and prints the results. The accuracy scores for each kernel model are displayed for comparison.

Uploaded by

ayushx312
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Practical 9

The document presents a Python script that utilizes the SVC (Support Vector Classification) from the sklearn library to classify breast cancer data. It trains three different models using linear, polynomial, and RBF kernels, evaluates their accuracy on a test set, and prints the results. The accuracy scores for each kernel model are displayed for comparison.

Uploaded by

ayushx312
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Practical 9

import pandas as pd
from sklearn import datasets
from sklearn.model_selection import train_test_split
from [Link] import SVC
from [Link] import accuracy_score

data = datasets.load_breast_cancer()
X = [Link]
y = [Link]

X_train, X_test, y_train, y_test = train_test_split(


X, y, test_size=0.2, random_state=42
)
linear_model = SVC(kernel='linear')
linear_model.fit(X_train, y_train)
linear_pred = linear_model.predict(X_test)
linear_acc = accuracy_score(y_test, linear_pred)
print("Ayush Yadav -59\nLinear Kernel Accuracy:", linear_acc)

poly_model = SVC(kernel='poly', degree=3)


poly_model.fit(X_train, y_train)
poly_pred = poly_model.predict(X_test)
poly_acc = accuracy_score(y_test, poly_pred)
print("Ayush Yadav-59\nPolynomial Kernel Accuracy:", poly_acc)

rbf_model = SVC(kernel='rbf')
rbf_model.fit(X_train, y_train)
rbf_pred = rbf_model.predict(X_test)
rbf_acc = accuracy_score(y_test, rbf_pred)
print("Ayush Yadav\nRBF Kernel Accuracy:", rbf_acc)

You might also like