SlideShare a Scribd company logo
1 of 13
Spam Detection:
A Deep Learning
Approach with
Tensorflow and
CNN in Python
What is Spam?
Spam is unsolicited and unwanted email. It often
contains malicious content or scams.Spam can
be difficult to detect because it can come in
many forms and use various tactics to avoid
detection. However, with the use of deep
learning and CNNs,we can build more effective
spam detection systems.
What are Convolutional Neural Networks?
Convolutional neural networks
(CNNs) are a type of deep learning
model that is particularly effective for
image recognition tasks.CNNs use
convolutional layers to extract
features from images,and then use
fully connected layers to make
predictions based on those features.In
spam detection,we can use CNNs to
extract features from email messages.
Preparing the Data
Before we can train our spam detection system,
we need to prepare our data.This involves
cleaning and preprocessing the data, and
splitting it into training and testing sets. We will
also need to vectorize our text data so that it can
be used as input to our CNN.
import tensorflow as tf
from tensorflow.keras.datasets
import imdb
from
tensorflow.keras.preprocessing.seque
nce import pad_sequences
import numpy as np
import pandas as pd
Training the Model
Once our data is prepared,we can
begin training our CNN model.This
involves defining the architecture
of the model,compiling it with
appropriate loss and optimization
functions,and then fitting it to our
training data.We will also need to
tune our model's hyperparameters
to achieve the best performance.
(x_train, y_train), (x_test, y_test) =
imdb.load_data(num_words=10000)
x_train = pad_sequences(x_train, value=0, padding='post',
maxlen=256)
x_test = pad_sequences(x_test, value=0, padding='post',
maxlen=256)
x_train = pad_sequences(x_train, value=0, padding='post',
maxlen=256)
x_test = pad_sequences(x_test, value=0, padding='post',
maxlen=256)
Evaluating theM odel
After our model is trained,we need to
evaluate its performance on our testing
data.We will use accuracy and
precision metrics to measure how well
our model is able to detect spam.We
can also use confusion matrices and
ROC curves to gain a deeper
understanding of our model's
performance.
import os
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))
data=pd.read_csv('/content/spam.csv')
data
data.columns
data.info()
data.isna().sum()
data['Spam']=data['Category'].apply(lambda x:1 if x=='spam' else 0)
data.head(5)
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(data.Message,data.Spa
m,test_size=0.25)
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(data.Message,data.Spa
m,test_size=0.25)
from sklearn.naive_bayes import MultinomialNB
from sklearn.pipeline import Pipeline
clf=Pipeline([
('vectorizer',CountVectorizer()),
('nb',MultinomialNB())
])
clf.fit(X_train,y_train)
emails=[
'Sounds great! Are you home now?',
'Will u meet ur dream partner soon? Is ur career
off 2 a flying start? 2 find out free, txt HORO
followed by ur star sign, e. g. HORO ARIES'
]
clf.predict(emails)
clf.score(X_test,y_test)
Conclusion
In conclusion,deep learning and CNNs are powerful tools for
building effective spam detection systems. By using these
technologies, we can improve the accuracy and precision of our
spam detection,and better protect ourselves from malicious
content and scams.With the knowledge gained from this
presentation,you are now equipped to build your own spam
detection system using deep learning and CNNs in Python.
Thanks!
Do you have any questions? addyouremail@freepik.com
+
91620 421838
yourcompany.com

More Related Content

Similar to wepik-breaking-down-spam-detection-a-deep-learning-approach-with-tensorflow-and-cnn-in-python-20231003161544kCx8.pptx

The ABC of Implementing Supervised Machine Learning with Python.pptx
The ABC of Implementing Supervised Machine Learning with Python.pptxThe ABC of Implementing Supervised Machine Learning with Python.pptx
The ABC of Implementing Supervised Machine Learning with Python.pptxRuby Shrestha
 
Use of artificial neural networks to identify fake profiles
Use of artificial neural networks to identify fake profilesUse of artificial neural networks to identify fake profiles
Use of artificial neural networks to identify fake profilesVenkat Projects
 
House price prediction
House price predictionHouse price prediction
House price predictionSabahBegum
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3Max Kleiner
 
Open CV Implementation of Object Recognition Using Artificial Neural Networks
Open CV Implementation of Object Recognition Using Artificial Neural NetworksOpen CV Implementation of Object Recognition Using Artificial Neural Networks
Open CV Implementation of Object Recognition Using Artificial Neural Networksijceronline
 
MCL309_Deep Learning on a Raspberry Pi
MCL309_Deep Learning on a Raspberry PiMCL309_Deep Learning on a Raspberry Pi
MCL309_Deep Learning on a Raspberry PiAmazon Web Services
 
The Validity of CNN to Time-Series Forecasting Problem
The Validity of CNN to Time-Series Forecasting ProblemThe Validity of CNN to Time-Series Forecasting Problem
The Validity of CNN to Time-Series Forecasting ProblemMasaharu Kinoshita
 
maXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIImaXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIIMax Kleiner
 
Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)Julien SIMON
 
A new architecture of internet of things and big data ecosystem for
A new architecture of internet of things and big data ecosystem forA new architecture of internet of things and big data ecosystem for
A new architecture of internet of things and big data ecosystem forVenkat Projects
 
Svm and maximum entropy model for sentiment analysis of tweets
Svm and maximum entropy model for sentiment analysis of tweetsSvm and maximum entropy model for sentiment analysis of tweets
Svm and maximum entropy model for sentiment analysis of tweetsS M Raju
 
Getting started with Machine Learning
Getting started with Machine LearningGetting started with Machine Learning
Getting started with Machine LearningGaurav Bhalotia
 
Neural basics
Neural basicsNeural basics
Neural basicscoursesub
 
Workshop - Introduction to Machine Learning with R
Workshop - Introduction to Machine Learning with RWorkshop - Introduction to Machine Learning with R
Workshop - Introduction to Machine Learning with RShirin Elsinghorst
 
maxbox starter60 machine learning
maxbox starter60 machine learningmaxbox starter60 machine learning
maxbox starter60 machine learningMax Kleiner
 

Similar to wepik-breaking-down-spam-detection-a-deep-learning-approach-with-tensorflow-and-cnn-in-python-20231003161544kCx8.pptx (20)

The ABC of Implementing Supervised Machine Learning with Python.pptx
The ABC of Implementing Supervised Machine Learning with Python.pptxThe ABC of Implementing Supervised Machine Learning with Python.pptx
The ABC of Implementing Supervised Machine Learning with Python.pptx
 
Use of artificial neural networks to identify fake profiles
Use of artificial neural networks to identify fake profilesUse of artificial neural networks to identify fake profiles
Use of artificial neural networks to identify fake profiles
 
House price prediction
House price predictionHouse price prediction
House price prediction
 
maXbox starter65 machinelearning3
maXbox starter65 machinelearning3maXbox starter65 machinelearning3
maXbox starter65 machinelearning3
 
Open CV Implementation of Object Recognition Using Artificial Neural Networks
Open CV Implementation of Object Recognition Using Artificial Neural NetworksOpen CV Implementation of Object Recognition Using Artificial Neural Networks
Open CV Implementation of Object Recognition Using Artificial Neural Networks
 
IEEE
IEEEIEEE
IEEE
 
MCL309_Deep Learning on a Raspberry Pi
MCL309_Deep Learning on a Raspberry PiMCL309_Deep Learning on a Raspberry Pi
MCL309_Deep Learning on a Raspberry Pi
 
The Validity of CNN to Time-Series Forecasting Problem
The Validity of CNN to Time-Series Forecasting ProblemThe Validity of CNN to Time-Series Forecasting Problem
The Validity of CNN to Time-Series Forecasting Problem
 
maXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VIImaXbox starter69 Machine Learning VII
maXbox starter69 Machine Learning VII
 
Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)Deep Learning with Apache MXNet (September 2017)
Deep Learning with Apache MXNet (September 2017)
 
A new architecture of internet of things and big data ecosystem for
A new architecture of internet of things and big data ecosystem forA new architecture of internet of things and big data ecosystem for
A new architecture of internet of things and big data ecosystem for
 
Svm and maximum entropy model for sentiment analysis of tweets
Svm and maximum entropy model for sentiment analysis of tweetsSvm and maximum entropy model for sentiment analysis of tweets
Svm and maximum entropy model for sentiment analysis of tweets
 
Getting started with Machine Learning
Getting started with Machine LearningGetting started with Machine Learning
Getting started with Machine Learning
 
SVM & MLP on Matlab program
 SVM & MLP on Matlab program  SVM & MLP on Matlab program
SVM & MLP on Matlab program
 
Neural basics
Neural basicsNeural basics
Neural basics
 
PythonML.pptx
PythonML.pptxPythonML.pptx
PythonML.pptx
 
Human Emotion Recognition
Human Emotion RecognitionHuman Emotion Recognition
Human Emotion Recognition
 
svm.pptx
svm.pptxsvm.pptx
svm.pptx
 
Workshop - Introduction to Machine Learning with R
Workshop - Introduction to Machine Learning with RWorkshop - Introduction to Machine Learning with R
Workshop - Introduction to Machine Learning with R
 
maxbox starter60 machine learning
maxbox starter60 machine learningmaxbox starter60 machine learning
maxbox starter60 machine learning
 

More from NANDHINIS900805

More from NANDHINIS900805 (9)

3b318431-df9f-4a2c-9909-61ecb6af8444.pptx
3b318431-df9f-4a2c-9909-61ecb6af8444.pptx3b318431-df9f-4a2c-9909-61ecb6af8444.pptx
3b318431-df9f-4a2c-9909-61ecb6af8444.pptx
 
Alligation OR mixture.pptx
Alligation OR mixture.pptxAlligation OR mixture.pptx
Alligation OR mixture.pptx
 
AP&GP.pptx
AP&GP.pptxAP&GP.pptx
AP&GP.pptx
 
PERMUTATION AND COMBINATION.pptx
PERMUTATION AND COMBINATION.pptxPERMUTATION AND COMBINATION.pptx
PERMUTATION AND COMBINATION.pptx
 
ARCHITECTURE.pptx
ARCHITECTURE.pptxARCHITECTURE.pptx
ARCHITECTURE.pptx
 
after 10th (1).pptx
after 10th (1).pptxafter 10th (1).pptx
after 10th (1).pptx
 
nnnn.pptx
nnnn.pptxnnnn.pptx
nnnn.pptx
 
DBMS.pptx
DBMS.pptxDBMS.pptx
DBMS.pptx
 
.n.pptx
.n.pptx.n.pptx
.n.pptx
 

Recently uploaded

ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGSIVASHANKAR N
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 

Recently uploaded (20)

ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 

wepik-breaking-down-spam-detection-a-deep-learning-approach-with-tensorflow-and-cnn-in-python-20231003161544kCx8.pptx

  • 1. Spam Detection: A Deep Learning Approach with Tensorflow and CNN in Python
  • 2. What is Spam? Spam is unsolicited and unwanted email. It often contains malicious content or scams.Spam can be difficult to detect because it can come in many forms and use various tactics to avoid detection. However, with the use of deep learning and CNNs,we can build more effective spam detection systems.
  • 3. What are Convolutional Neural Networks? Convolutional neural networks (CNNs) are a type of deep learning model that is particularly effective for image recognition tasks.CNNs use convolutional layers to extract features from images,and then use fully connected layers to make predictions based on those features.In spam detection,we can use CNNs to extract features from email messages.
  • 4. Preparing the Data Before we can train our spam detection system, we need to prepare our data.This involves cleaning and preprocessing the data, and splitting it into training and testing sets. We will also need to vectorize our text data so that it can be used as input to our CNN. import tensorflow as tf from tensorflow.keras.datasets import imdb from tensorflow.keras.preprocessing.seque nce import pad_sequences import numpy as np import pandas as pd
  • 5. Training the Model Once our data is prepared,we can begin training our CNN model.This involves defining the architecture of the model,compiling it with appropriate loss and optimization functions,and then fitting it to our training data.We will also need to tune our model's hyperparameters to achieve the best performance.
  • 6. (x_train, y_train), (x_test, y_test) = imdb.load_data(num_words=10000) x_train = pad_sequences(x_train, value=0, padding='post', maxlen=256) x_test = pad_sequences(x_test, value=0, padding='post', maxlen=256) x_train = pad_sequences(x_train, value=0, padding='post', maxlen=256) x_test = pad_sequences(x_test, value=0, padding='post', maxlen=256)
  • 7. Evaluating theM odel After our model is trained,we need to evaluate its performance on our testing data.We will use accuracy and precision metrics to measure how well our model is able to detect spam.We can also use confusion matrices and ROC curves to gain a deeper understanding of our model's performance.
  • 8. import os for dirname, _, filenames in os.walk('/kaggle/input'): for filename in filenames: print(os.path.join(dirname, filename)) data=pd.read_csv('/content/spam.csv') data data.columns data.info() data.isna().sum()
  • 9. data['Spam']=data['Category'].apply(lambda x:1 if x=='spam' else 0) data.head(5) from sklearn.model_selection import train_test_split X_train,X_test,y_train,y_test=train_test_split(data.Message,data.Spa m,test_size=0.25) from sklearn.model_selection import train_test_split X_train,X_test,y_train,y_test=train_test_split(data.Message,data.Spa m,test_size=0.25) from sklearn.naive_bayes import MultinomialNB
  • 10. from sklearn.pipeline import Pipeline clf=Pipeline([ ('vectorizer',CountVectorizer()), ('nb',MultinomialNB()) ]) clf.fit(X_train,y_train)
  • 11. emails=[ 'Sounds great! Are you home now?', 'Will u meet ur dream partner soon? Is ur career off 2 a flying start? 2 find out free, txt HORO followed by ur star sign, e. g. HORO ARIES' ] clf.predict(emails) clf.score(X_test,y_test)
  • 12. Conclusion In conclusion,deep learning and CNNs are powerful tools for building effective spam detection systems. By using these technologies, we can improve the accuracy and precision of our spam detection,and better protect ourselves from malicious content and scams.With the knowledge gained from this presentation,you are now equipped to build your own spam detection system using deep learning and CNNs in Python.
  • 13. Thanks! Do you have any questions? addyouremail@freepik.com + 91620 421838 yourcompany.com