Practical 9.docx

  • Uploaded by: Amandeep Singh
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Practical 9.docx as PDF for free.

More details

  • Words: 91
  • Pages: 3
VISHAL KUMAR

17MCA8247 Practical 9

Aim:- Write a program to implement Support Vector Machine using the dataset Coding:import numpy as np import matplotlib.pyplot as plt import pandas as pd df= pd.read_csv('data.csv') print(df.head(10)) from sklearn.model_selection import train_test_split

x=df[["grade1","grade2"]] y=df['label'] x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.35,random_state=4)

print(x_train.shape) print(y_train.shape)

print(x_test.shape) print(y_test.shape) print(x_test.head())

from sklearn import svm model=svm.SVC(gamma='auto') model.fit(x_train,y_train)

#Getting model score score=model.score(x_test,y_test) print("Prediction Accuracy",score,"%")

UNIVERSITY INSTITUTE OF COMPUTING

VISHAL KUMAR

17MCA8247

f=np.array([60.6,60.9]).reshape(1,-1) print(f) res=model.predict(f) print(res)

#plotting yp=model.predict(x_test) plt.plot(x_train['grade1'],y_train,'o',color='red') plt.plot(x_test['grade1'],yp,'.',color='blue') plt.legend(['Training Values' , 'Predicted Values']) plt.title('support vector machine',color='blue')

Output:-

UNIVERSITY INSTITUTE OF COMPUTING

VISHAL KUMAR

17MCA8247

UNIVERSITY INSTITUTE OF COMPUTING

Related Documents

Practical
April 2020 22
Practical
May 2020 20
Practical
October 2019 36
Cn-practical
November 2019 20
Dsp Practical
October 2019 23
Practical # 01
June 2020 11

More Documents from ""

April 2020 7
April 2020 14
Asliat Kya Hai.pdf
October 2019 18
Practical 9.docx
June 2020 6