0% found this document useful (0 votes)
15 views2 pages

SVM Ass

Uploaded by

madhuri thorat
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)
15 views2 pages

SVM Ass

Uploaded by

madhuri thorat
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

9/24/24, 12:03 PM SVM Code - Jupyter Notebook

In [36]: import numpy as np


import [Link] as plt
from sklearn import datasets
from sklearn.model_selection import train_test_split
from [Link] import SVC

In [37]: iris = datasets.load_iris()


X = [Link]
y = [Link]

In [38]: X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random


In [39]: clf = SVC(kernel='linear')


[Link](X_train, y_train)

Out[39]: SVC(kernel='linear')

In [40]: y_pred = [Link](X_test)

In [41]: from [Link] import accuracy_score


print("Accuracy:", accuracy_score(y_test, y_pred))

Accuracy: 1.0

In [47]: X_train_reduced = X_train[:, :2]


[Link](X_train_reduced, y_train)
plot_decision_boundary(X_test[:, :2], y_test, clf)

localhost:8888/notebooks/SVM [Link]# 1/2


9/24/24, 12:03 PM SVM Code - Jupyter Notebook

localhost:8888/notebooks/SVM [Link]# 2/2

You might also like