To write a program to implement the SVM For Spam Mail Detection.
- Hardware โ PCs
- Anaconda โ Python 3.7 Installation / Jupyter notebook
STEP 1 : Start STEP 2 : Preprocessing the data STEP 3 : Feature Extraction STEP 4 : Training the SVM model STEP 5 : Model Evalutaion STEP 6 : Stop
/*
Program to implement the SVM For Spam Mail Detection..
Developed by: MANOJ KUMAR S
RegisterNumber: 212223240082
*/
import pandas as pd
data=pd.read_csv("C:/Users/admin/Downloads/spam.csv",encoding = 'Windows-1252')
from sklearn.model_selection import train_test_split
data
data.shape
x=data["v2"].values
y=data["v1"].values
x.shape
y.shape
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2,random_state=0)
x_train
x_train.shape
from sklearn.feature_extraction.text import CountVectorizer
cv=CountVectorizer()
x_train=cv.fit_transform(x_train)
x_test=cv.transform(x_test)
from sklearn.svm import SVC
svc=SVC()
svc.fit(x_train,y_train)
y_pred=svc.predict(x_test)
y_pred
from sklearn.metrics import accuracy_score,confusion_matrix,classification_report
acc=accuracy_score(y_test,y_pred)
acc
con=confusion_matrix(y_test,y_pred)
print(con)
cl=classification_report(y_test,y_pred)
print(cl)
Thus the program to implement the SVM For Spam Mail Detection is written and verified using python programming.