You are on page 1of 3

Name: Sandeep kaleshriya

Scholar no. 201112040


Section : cse1
Machine learning final lab
Q2)
Dataset
Q3)

from sklearn import svm

from sklearn.model_selection import train_test_split

X = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]
y = [1, 1, 1, 2, 2, 2]

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

clf = svm.SVC(kernel='linear')

clf.fit(X_train, y_train)

accuracy = clf.score(X_test, y_test)

coef = clf.coef_

intercept = clf.intercept_

print("Hyperplane equation:")

print("{0}x1 + {1}x2 + {2} = 0".format(coef[0][0], coef[0][1], intercept[0]))

output :

Hyperplane equation:

1.0x1 + 1.0x2 + -7.0 = 0

You might also like