Spam Comments Detection
Objective: -
Spam comments on social media platforms are the type of comments posted to redirect the user to another social media account, website or any piece of content.Spam is content or correspondences that create a negative experience by making it difficult to find more relevant and substantive material. It can sometimes be used to indiscriminately send unsolicited bulk messages on YouTube.
The goal of this challenge is to build a machine learning model that classify whether the comment is spam or not. Further accurate classification of comment can help in identifying the spam.
Dataset: -
The dataset is openly available at Kaggle.
Five real-valued features are computed for each cell nucleus:
- Comment ID
- Author
- Date
- Class
- Content
Step 1: Import all the required libraries
- Pandas : In computer programming, pandas is a software library written for the Python programming language for data manipulation and analysis and storing in a proper way. In particular, it offers data structures and operations for manipulating numerical tables and time series
- Sklearn : Scikit-learn (formerly scikits.learn) is a free software machine learning library for the Python programming language. It features various classification, regression and clustering algorithms including support vector machines, random forests, gradient boosting, k-means and DBSCAN, and is designed to interoperate with the Python numerical and scientific libraries NumPy and SciPy. The library is built upon the SciPy (Scientific Python) that must be installed before you can use scikit-learn.
- Pickle : Python pickle module is used for serializing and de-serializing a Python object structure. Pickling is a way to convert a python object (list, dict, etc.) into a character stream. The idea is that this character stream contains all the information necessary to reconstruct the object in another python script.
- Seaborn : Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics.
- Matplotlib : Matplotlib is a plotting library for the Python programming language and its numerical mathematics extension NumPy. It provides an object-oriented API for embedding plots into applications using general-purpose GUI toolkits like Tkinter, wxPython, Qt, or GTK.
#Loading libraries
import pandas as pd
import seaborn as sns
import pickle
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import KFold, cross_val_score, train_test_split
from sklearn.naive_bayes import BernoulliNB
import warnings
warnings.filterwarnings('ignore')
Step 2 : Read dataset and basic details of dataset
Goal:- In this step we are going to read the dataset, view the dataset and analysis the basic details like total number of rows and columns, what are the column data types and see to need to create new column or not.
In this stage we are going to read our problem dataset and have a look on it.
#loading the dataset
try:
df = pd.read_csv('C:/My Sample Notebook/Notebook Template/Spam Comments Detection/data/Youtube01-Psy.csv') #Path for the file
print('Data read done successfully...')
except (FileNotFoundError, IOError):
print("Wrong file or file path")Data read done successfully...# To view the content inside the dataset we can use the head() method that returns a specified number of rows, string from the top.
# The head() method returns the first 5 rows if a number is not specified.
df.head()
Step3: Data Preprocessing
Why need of Data Preprocessing?
Preprocessing data is an important step for data analysis. The following are some benefits of preprocessing data:
- It improves accuracy and reliability. Preprocessing data removes missing or inconsistent data values resulting from human or computer error, which can improve the accuracy and quality of a dataset, making it more reliable.
- It makes data consistent. When collecting data, it’s possible to have data duplicates, and discarding them during preprocessing can ensure the data values for analysis are consistent, which helps produce accurate results.
- It increases the data’s algorithm readability. Preprocessing enhances the data’s quality and makes it easier for machine learning algorithms to read, use, and interpret it.
Why we drop column?
By analysing the first five rows we found that there is a column named [‘Comment ID’], it contains unuseful information which isn’t good for our model, se we gonna drop it using the below method:
df = df.drop(['COMMENT_ID'], axis =1)
Axis are defined for arrays with more than one dimension. A 2-dimensional array has two corresponding axes: the first running vertically downwards across rows (axis 0) and the second running horizontally across columns (axis 1).
After we read the data, we can look at the data using:
# count the total number of rows and columns.
print ('The train data has {0} rows and {1} columns'.format(df.shape[0],df.shape[1]))The train data has 350 rows and 4 columns
By analysing the problem statement and the dataset, we get to know that the target variable is “CLASS” column which says if the cancer is (0 = Not spam) or (1 = Spam).
df['CLASS'].value_counts()1 175
0 175
Name: CLASS, dtype: int64
The df.value_counts() method counts the number of types of values a particular column contains.
df.shape(350, 4)
The df.shape method shows the shape of the dataset.
df.info()<class 'pandas.core.frame.DataFrame'>
RangeIndex: 350 entries, 0 to 349
Data columns (total 4 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 AUTHOR 350 non-null object
1 DATE 350 non-null object
2 CONTENT 350 non-null object
3 CLASS 350 non-null int64
dtypes: int64(1), object(3)
memory usage: 11.1+ KB
The df.info() method prints information about a DataFrame including the index dtype and columns, non-null values and memory usage.
df.iloc[1]AUTHOR adam riyati
DATE 2013-11-07T12:37:15
CONTENT Hey guys check out my new channel and our firs...
CLASS 1
Name: 1, dtype: object
df.iloc[ ] is primarily integer position based (from 0 to length-1 of the axis), but may also be used with a boolean array. The iloc property gets, or sets, the value(s) of the specified indexes.
Data Type Check for every column
Why data type check is required?
Data type check helps us with understanding what type of variables our dataset contains. It helps us with identifying whether to keep that variable or not. If the dataset contains contiguous data, then only float and integer type variables will be beneficial and if we have to classify any value then categorical variables will be beneficial.
objects_cols = ['object']
objects_lst = list(df.select_dtypes(include=objects_cols).columns)print("Total number of categorical columns are ", len(objects_lst))
print("There names are as follows: ", objects_lst)Total number of categorical columns are 3
There names are as follows: ['AUTHOR', 'DATE', 'CONTENT']int64_cols = ['int64']
int64_lst = list(df.select_dtypes(include=int64_cols).columns)print("Total number of numerical columns are ", len(int64_lst))
print("There names are as follows: ", int64_lst)Total number of numerical columns are 1
There names are as follows: ['CLASS']float64_cols = ['float64']
float64_lst = list(df.select_dtypes(include=float64_cols).columns)print("Total number of float64 columns are ", len(float64_lst))
print("There name are as follow: ", float64_lst)Total number of float64 columns are 0
There name are as follow: []
Step 2 Insights: -
- We have total 4 features where 3 of them are object type and 1 is integer type.
- Drop “COMMENT_ID” columns.
After this step we have to calculate various evaluation parameters which will help us in cleaning and analysing the data more accurately.
Step 3: Descriptive Analysis
Goal/Purpose: Finding the data distribution of the features. Visualization helps to understand data and also to explain the data to another person.
Things we are going to do in this step:
- Mean
- Median
- Mode
- Standard Deviation
- Variance
- Null Values
- NaN Values
- Min value
- Max value
- Count Value
- Quatilers
- Correlation
- Skewness
df.describe()
The df.describe() method returns description of the data in the DataFrame. If the DataFrame contains numerical data, the description contains these information for each column: count — The number of not-empty values. mean — The average (mean) value.
Measure the variability of data of the dataset
Variability describes how far apart data points lie from each other and from the center of a distribution.
1. Standard Deviation
The standard deviation is the average amount of variability in your dataset.
It tells you, on average, how far each data point lies from the mean. The larger the standard deviation, the more variable the data set is and if zero variance then there is no variability in the dataset that means there no use of that dataset.
So, it helps in understanding the measurements when the data is distributed. The more the data is distributed, the greater will be the standard deviation of that data.Here, you as an individual can determine which company is beneficial in long term. But, if you didn’t know the SD you would have choosen a wrong compnay for you.
df.std()CLASS 0.500716
dtype: float64
We can also understand the standard deviation using the below function.
def std_cal(df,float64_lst):
cols = ['normal_value', 'zero_value']
zero_value = 0
normal_value = 0
for value in float64_lst:
rs = round(df[value].std(),6)
if rs > 0:
normal_value = normal_value + 1
elif rs == 0:
zero_value = zero_value + 1
std_total_df = pd.DataFrame([[normal_value, zero_value]], columns=cols)
return std_total_df
2. Variance
The variance is the average of squared deviations from the mean. A deviation from the mean is how far a score lies from the mean.
Variance is the square of the standard deviation. This means that the units of variance are much larger than those of a typical value of a data set.
Why do we used Variance ?
By Squairng the number we get non-negative computation i.e. Disperson cannot be negative. The presence of variance is very important in your dataset because this will allow the model to learn about the different patterns hidden in the data
df.var()CLASS 0.250716
dtype: float64
We can also understand the Variance using the below function.
zero_cols = []
def var_cal(df,float64_lst):
cols = ['normal_value', 'zero_value']
zero_value = 0
normal_value = 0
for value in float64_lst:
rs = round(df[value].var(),6)
if rs > 0:
normal_value = normal_value + 1
elif rs == 0:
zero_value = zero_value + 1
zero_cols.append(value)
var_total_df = pd.DataFrame([[normal_value, zero_value]], columns=cols)
return var_total_df
Measure central tendency
A measure of central tendency is a single value that attempts to describe a set of data by identifying the central position within that set of data. As such, measures of central tendency are sometimes called measures of central location. They are also classed as summary statistics.
Null and Nan values
- Null Values
A null value in a relational database is used when the value in a column is unknown or missing. A null is neither an empty string (for character or datetime data types) nor a zero value (for numeric data types).
df.isnull().sum()AUTHOR 0
DATE 0
CONTENT 0
CLASS 0
dtype: int64
As we notice that there are no null values in our dataset.
- Nan Values
NaN, standing for Not a Number, is a member of a numeric data type that can be interpreted as a value that is undefined or unrepresentable, especially in floating-point arithmetic.
df.isna().sum()AUTHOR 0
DATE 0
CONTENT 0
CLASS 0
dtype: int64
As we notice that there are no nan values in our dataset.
Another way to remove null and nan values is to use the method “df.dropna(inplace=True)”.
df['CLASS']0 1
1 1
2 1
3 1
4 1
..
345 0
346 0
347 1
348 1
349 0
Name: CLASS, Length: 350, dtype: int64
Step 3 Insights: -
With the statistical analysis we have found that the data have a lot of skewness in them all the columns are positively skewed with mostly zero variance.
Statistical analysis is little difficult to understand at one glance so to make it more understandable we will perform visulatization on the data which will help us to understand the process easily.
Why we are calculating all these metrics?
Mean / Median /Mode/ Variance /Standard Deviation are all very basic but very important concept of statistics used in data science. Almost all the machine learning algorithm uses these concepts in data preprocessing steps. These concepts are part of descriptive statistics where we basically used to describe and understand the data for features in Machine learning
sns.countplot(x=df['CLASS'])<AxesSubplot: xlabel='CLASS', ylabel='count'>
The ratio for both the values are equal.
Step 4: Data Exploration
Goal/Purpose:
Graphs we are going to develop in this step
- Histogram of all columns to check the distrubution of the columns
- Distplot or distribution plot of all columns to check the variation in the data distribution
- Heatmap to calculate correlation within feature variables
- Boxplot to find out outlier in the feature columns
1. Histogram
A histogram is a bar graph-like representation of data that buckets a range of classes into columns along the horizontal x-axis.The vertical y-axis represents the number count or percentage of occurrences in the data for each column
# Distribution in attributes
%matplotlib inline
import matplotlib.pyplot as plt
df.hist(bins=50, figsize=(30,30))
plt.show()
Histogram Insight: -
Histogram helps in identifying the following:
- View the shape of your data set’s distribution to look for outliers or other significant data points.
- Determine whether something significant has boccurred from one time period to another.
Why Histogram?
It is used to illustrate the major features of the distribution of the data in a convenient form. It is also useful when dealing with large data sets (greater than 100 observations). It can help detect any unusual observations (outliers) or any gaps in the data.
From the above graphical representation we can identify that the highest bar represents the outliers which is above the maximum range.
We can also identify that the values are moving on the right side, which determines positive and the centered values determines normal skewness.
2. Distplot
A Distplot or distribution plot, depicts the variation in the data distribution. Seaborn Distplot represents the overall distribution of continuous data variables. The Seaborn module along with the Matplotlib module is used to depict the distplot with different variations in it
num = [f for f in df.columns if df.dtypes[f] != 'object']
nd = pd.melt(df, value_vars = num)
n1 = sns.FacetGrid (nd, col='variable', col_wrap=4, sharex=False, sharey = False)
n1 = n1.map(sns.distplot, 'value')
n1<seaborn.axisgrid.FacetGrid at 0x2196dc26890>
Distplot Insights: -
Above is the distrution bar graphs to confirm about the statistics of the data about the skewness, the above results are:
- 1 column i.e CLASSS which is our target variable ~ which is also +ve skewed. In that case we’ll need to log transform this variable so that it becomes normally distributed. A normally distributed (or close to normal) target variable helps in better modeling the relationship between target and independent variables
Why Distplot?
Skewness is demonstrated on a bell curve when data points are not distributed symmetrically to the left and right sides of the median on a bell curve. If the bell curve is shifted to the left or the right, it is said to be skewed.
We can observe that the bell curve is shifted to left we indicates positive skewness.As all the column are positively skewed we don’t need to do scaling.
Let’s proceed and check the distribution of the target variable.
#+ve skewed
df['CLASS'].skew()0.0
The target variable is positively skewed.A normally distributed (or close to normal) target variable helps in better modeling the relationship between target and independent variables.
3. Heatmap
A heatmap (or heat map) is a graphical representation of data where values are depicted by color.Heatmaps make it easy to visualize complex data and understand it at a glance
Correlation — A positive correlation is a relationship between two variables in which both variables move in the same direction. Therefore, when one variable increases as the other variable increases, or one variable decreases while the other decreases.
Correlation can have a value:
- 1 is a perfect positive correlation
- 0 is no correlation (the values don’t seem linked at all)
- -1 is a perfect negative correlation
#correlation plot
sns.set(rc = {'figure.figsize':(25,20)})
corr = df.corr().abs()
sns.heatmap(corr,annot=True)
plt.show()
Notice the last column from right side of this map. We can see the correlation of all variables against diagnosis. As you can see, some variables seem to be strongly correlated with the target variable. Here, a numeric correlation score will help us understand the graph better.
corr
Heatmap insights: -
As we know, it is recommended to avoid correlated features in your dataset. Indeed, a group of highly correlated features will not bring additional information (or just very few), but will increase the complexity of the algorithm, hence increasing the risk of errors.
Why Heatmap?
Heatmaps are used to show relationships between two variables, one plotted on each axis. By observing how cell colors change across each axis, you can observe if there are any patterns in value for one or both variables.
4. Boxplot
A boxplot is a standardized way of displaying the distribution of data based on a five number summary (“minimum”, first quartile [Q1], median, third quartile [Q3] and “maximum”).
Basically, to find the outlier in a dataset/column.
sns.catplot(data=df, x='CLASS', kind="box")<seaborn.axisgrid.FacetGrid at 0x2196fe6ed50>
The dark points are known as Outliers. Outliers are those data points that are significantly different from the rest of the dataset. They are often abnormal observations that skew the data distribution, and arise due to inconsistent data entry, or erroneous observations.
Boxplot Insights: -
- Sometimes outliers may be an error in the data and should be removed. In this case these points are correct readings yet they are different from the other points that they appear to be incorrect.
- The best way to decide wether to remove them or not is to train models with and without these data points and compare their validation accuracy.
- So we will keep it unchanged as it won’t affect our model.
Here, we can see that most of the variables possess outlier values. It would take us days if we start treating these outlier values one by one. Hence, for now we’ll leave them as is and let our algorithm deal with them. As we know, tree-based algorithms are usually robust to outliers.
Why Boxplot?
Box plots are used to show distributions of numeric data values, especially when you want to compare them between multiple groups. They are built to provide high-level information at a glance, offering general information about a group of data’s symmetry, skew, variance, and outliers.
In the next step we will divide our cleaned data into training data and testing data.
As the problem is based on Natural Language Processing so data visualization isn’t needed because majority columns are categorical.
We only need the content and class column from the dataset for the rest of the task. So let’s select both the columns and move further:
data = df[["CONTENT", "CLASS"]]
print(data.sample(5))CONTENT CLASS
258 C'mon 3 billion views!!!!!!!! 0
303 im sorry for the spam but My name is Jenny. I ... 1
187 I'm here to check the views.. holy shit 0
315 PLEASE SUBSCRIBE ME!!!!!!!!!!!!!!!!!!!!!!!!!!!... 1
299 I am so awesome and smart!!! Sucscribe to me! 1
The class column contains values 0 and 1. 0 indicates not spam, and 1 indicates spam. So to make it look better, I will use spam and not spam labels instead of 1 and 0:
data["CLASS"] = data["CLASS"].map({0: "Not Spam",
1: "Spam Comment"})
print(data.sample(5))CONTENT CLASS
252 This video is so cool, again and again! Not Spam
303 im sorry for the spam but My name is Jenny. I ... Spam Comment
234 What Can i say....This Song He Just Change The... Not Spam
131 PSY GOT LOTS OF MONEY FROM YOUTUBE THAT HE GO... Not Spam
296 If i reach 100 subscribers i will tazz my self... Spam Comment
Step 2: Data Preparation
Goal:-
Tasks we are going to in this step:
- Now we will spearate the target variable and feature columns in two different dataframe and will check the shape of the dataset for validation purpose.
- Split dataset into train and test dataset.
- Scaling on train dataset.
1. Now we spearate the target variable and feature columns in two different dataframe and will check the shape of the dataset for validation purpose.
# Separate target and feature column in X and y variable
# X will be the features
X = np.array(data["CONTENT"])
#y will be the target variable
y = np.array(data["CLASS"])Xarray(['Huh, anyway check out this you[tube] channel: kobyoshi02',
"Hey guys check out my new channel and our first vid THIS IS US THE MONKEYS!!! I'm the monkey in the white shirt,please leave a like comment and please subscribe!!!!",
'just for test I have to say murdev.com',
'me shaking my sexy ass on my channel enjoy ^_^ \ufeff',
'watch?v=vtaRGgvGtWQ Check this out .\ufeff',
'Hey, check out my new website!! This site is about kids stuff. kidsmediausa . com',
'Subscribe to my channel \ufeff',
'i turned it on mute as soon is i came on i just wanted to check the views...\ufeff',
'You should check my channel for Funny VIDEOS!!\ufeff',
'and u should.d check my channel and tell me what I should do next!\ufeff',
'Hey subscribe to me\ufeff',
" Once you have started reading do not stop. If you do not subscribe to me within one day you and you're entire family will die so if you want to stay alive subscribe right now.\ufeff",
'https://twitter.com/GBphotographyGB\ufeff',
'subscribe like comment\ufeff',
'please like :D https://premium.easypromosapp.com/voteme/19924/616375350\ufeff',
"Hello! Do you like gaming, art videos, scientific experiments, tutorials, lyrics videos, and much, much more of that? If you do please check out our channel and subscribe to it, we've just started, but soon we hope we will be able to cover all of our expectations... You can also check out what we've got so far!\ufeff",
"I'm only checking the views\ufeff",
'http://www.ebay.com/itm/171183229277?ssPageName=STRK:MESELX:IT&_trksid=p3984.m1555.l2649 \ufeff',
'http://ubuntuone.com/40beUutVu2ZKxK4uTgPZ8K\ufeff',
'We are an EDM apparel company dedicated to bringing you music inspired designs. Our clothing is perfect for any rave or music festival. We have NEON crop tops, tank tops, t-shirts, v-necks and accessories! follow us on Facebook or on instagraml for free giveaways news and more!! visit our site at OnCueApparel\ufeff',
'i think about 100 millions of the views come from people who only wanted to check the views\ufeff',
'subscribe to my channel people :D\ufeff',
'Show your AUBURN PRIDE HERE: http://www.teespring.com/tigermeathoodie\ufeff',
'just checking the views\ufeff', 'CHECK OUT MY CHANNEL',
'marketglory . com/strategygame/andrijamatf earn real money from game',
'Hey guys! Im a 12 yr old music producer. I make chiptunes and 8bit music. It would be wonderful if you checked out some of my 8bit remixes! I even have a gangnamstyle 8bit remix if you would like to check that out ;) Thanks!!',
"Check me out! I'm kyle. I rap so yeah \ufeff",
'I dont even watch it anymore i just come here to check on 2 Billion or not\ufeff',
'Subscribe to me for free Android games, apps.. \ufeff',
'everyone please come check our newest song in memories of Martin Luther King Jr.\ufeff',
'Came here to check the views, goodbye.\ufeff',
'sub my channel for no reason -_-\ufeff',
'Check out my dubstep song "Fireball", made with Fruity Loops. I really took time in it. /watch?v=telOA6RIO8o\ufeff',
'2 billion....Coming soon\ufeff',
'Why dafuq is a Korean song so big in the USA. Does that mean we support Koreans? Last time I checked they wanted to bomb us. \ufeff',
'Check my channel please! And listen to the best music ever :P\ufeff',
'SUB 4 SUB PLEASE LIKE THIS COMMENT I WANT A SUCCESFULL YOUTUBE SO PPLEASE LIKE THIS COMMENT AND SUBSCRIBE IT ONLY TAKES 10 SECONDS PLEASE IF YOU SUBSCRIBE ILL SUBSCRIBE BACK THANKS\ufeff',
' Hey everyone!! I have just started my first YT channel i would be grateful if some of you peoples could check out my first clip in BF4! and give me some advice on how my video was and how i could improve it. ALSO be sure to go check out the about to see what Im all about. Thanks for your time :) . and to haters... You Hate, I WIN\ufeff',
'The projects After Effects, Music, Foto, Web sites and another you can find and buy here http://audiojungle.net/user/EugeneKalinin/portfolio?ref=EugeneKalinin\ufeff',
"YouTube/codytolleson for awesome videos I'll subscribe back \ufeff",
'if you like roblox minecraft world of warcraft gta5 mario suscribe to my channel\ufeff',
"SUBSCRIBE TO ME AND I'LL SUBSCRIBE TO YOU! (Must like - cZFcxsn0jnQ) \ufeff",
'http://www.twitch.tv/jaroadc come follow and watch my stream!\ufeff',
'if you like raw talent, raw lyrics, straight real hip hop Everyone check my newest sound Dizzy X - Got the Juice (Prod by. Drugs the Model Citizen) COMMENT TELL ME WHAT YOU THINK DONT BE LAZY!!!! - 1/7 Prophetz\ufeff',
'....subscribe...... ......to my........ .....channel.......\ufeff',
'now its 1,884,034,783 views! pls. comment the view count the next hour :P\ufeff',
'http://www.avaaz.org/po/petition/Youtube_Corporation_Fox_Broadcasting_Company_Anular_os_strikes_no_Canal_Nostalgia/?cXPZpgb \ufeff',
'go here to check the views :3\ufeff',
'thumbs up if u checked this video to see hw views it got\ufeff',
'Plz subscribe to my channel and I will subscribe back xx\ufeff',
'i check back often to help reach 2x10^9 views and I avoid watching Baby\ufeff',
'This video will get to 2 billion just because of people checking if it has hit 2 billion yet.\ufeff',
'https://www.facebook.com/pages/Brew-Crew-2014/134470083389909 Like this facebook-page! Chance to win an Iphone 5S!\ufeff',
'get GWAR to play 2015 superbowl http://www.change.org/petitions/the-national-football-league-allow-gwar-to-perform-the-2015-super-bowl-halftime-show#share \ufeff',
'Pls follow this channel!! http://www.twitch.tv/sevadus\ufeff',
'hi guys check my youtube channel\ufeff',
'Subscribe and like to me for more how to videos on minecraft!\ufeff',
'http://tankionline.com#friend=cd92db3f4 great game check it out!\ufeff',
'Subscribe ME!\ufeff',
'Im just to check how much views it has\ufeff',
'The first comment is chuck norrus ovbiously :D\ufeff',
'Behold the most viewed youtube video in the history of ever\ufeff',
'when is this gonna hit 2 billion?\ufeff',
'the most viewed youtube video of all time?\ufeff',
'969,210 dislikes like dislike themselves\ufeff',
'psy=korean\ufeff',
'OMG this oldspice spraytan party commercial omg....i\'m sitting here "NO this isn\'t a real thing is it? OMG" \ufeff',
'This is the only video on youtube that get so much views just because we want to see how much views it has. 1.000.000 every day, I mean, Most people think a video is popular when it actually gets 1.000.000 views.\ufeff',
"It's been back for quite a while now.", '2 Billions in 2014',
'plz check out fablife / welcome to fablife for diys and challenges so plz subscribe thx!\ufeff',
'Sub my channel!\ufeff',
'http://www.ebay.com/itm/131338190916?ssPageName=STRK:MESELX:IT&_trksid=p3984.m1555.l2649 \ufeff',
'http://www.guardalo.org/best-of-funny-cats-gatti-pazzi-e-divertenti-2013-5287/100000415527985/ \ufeff',
'if your like drones, plz subscribe to Kamal Tayara. He takes videos with his drone that are absolutely beautiful.\ufeff',
'http://hackfbaccountlive.com/?ref=4604617\ufeff',
'WHATS UP EVERYONE!? :-) I Trying To Showcase My Talent To The World! I Have Over 3000 SUBSCRIBERS! I PROMISE! I Dont Suck! Please Spread My Covers Around, SUBSCRIBE & Share! Thanks so much for all your support! Lucas Trigo -Stay Awesome! \ufeff',
'----->>>> https://www.facebook.com/video.php?v=10200253113705769&set=vb.201470069872822&type=3&permPage=1 <--------\ufeff',
"Hi there~I'm group leader of Angel, a rookie Korean pop group. We have four members, Chanicka, Julie, Stephanie, and myself, Leah. Please feel free to check out our channel and leave some feedback on our cover videos (: criticism is welcome as we know we're not top notch singers so please come leave some constructive feedback on our videos; we appreciate any chance to improve before auditioning for a Korean management company. We plan on auditioning for JYP, BigHit, Jellyfish, YG or SM. Thank you for taking time out of your day to read this !\ufeff",
'http://woobox.com/33gxrf/brt0u5 FREE CS GO!!!!\ufeff',
'Admit it you just came here to check the number of viewers \ufeff',
'Just coming to check if people are still viewing this video. And apparently, they still do.\ufeff',
'Check my first video out\ufeff', 'Check my channel\ufeff',
'PSY - GANGNAM STYLE (강남스타일) M/V: http://youtu.be/9bZkp7q19f0\ufeff',
'Suscribe My Channel Please XD lol\ufeff',
'Wow. Comments section on this still active. Not bad. Also 5277478 comments. (Now 79)\ufeff',
'http://binbox.io/1FIRo#123\ufeff',
'Ching Ching ling long ding ring yaaaaaa Ganga sty FUCK YOU.\ufeff',
'https://www.indiegogo.com/projects/cleaning-the-pan--2 please halp me with my project\ufeff',
'There is one video on my channel about my brother...\ufeff',
'Check my channel, please!\ufeff',
"Does anyone here use gift cards like Amazon, itunes, psn, google play, itunes, or any other gift cards? Then you'll be happy to know you can get free gift card codes for free from an amazing site. Here is a $50 itunes gift card code XXBB5TCZHM39HVZD\ufeff",
'Why does this video have so many views? Because asian things are awesome and non-asian countries are jelly so they try to learn from asia by looking at this video d:\ufeff',
'Plizz withing my channel \ufeff',
'I made a gaming channel (Unique right?) :L Angry Minecraft!\ufeff',
'Please help me go here http://www.gofundme.com/littlebrother\ufeff',
'Anybody who subscribes to me will get 10 subscribers\ufeff',
'http://thepiratebay.se/torrent/6381501/Timothy_Sykes_Collection\ufeff',
'My videos are half way decent, check them out if you want.\ufeff',
'they said this video are not deserve 2billion views , while they keep visiting it to watch the viewer . \ufeff',
'subscribe to itz recaps and above diddle\ufeff',
"Screw this Chinese crap i dont even understand what he is saying. Why isn't he speaking English like everyone should?\ufeff",
'need money?Enjoy https://www.tsu.co/emerson_zanol\ufeff',
'Sub to my channel visuelgamingzNL I sub back\ufeff',
'please subscribe i am a new youtuber and need help please subscribe and i will subscribe back :D hoppa HOPPA GaNgAm StYlE\ufeff',
'sub me if you dont like the song\ufeff',
'This is a weird video.\ufeff',
'8 million likes xD even the subscribers not 8 million xD\ufeff',
'EHI GUYS CAN YOU SUBSCRIBE IN MY CHANNEL? I AM A NEW YOUTUBER AND I PLAY MINECRAFT THANKS GUYS!... SUBSCRIBE!\ufeff',
"Hi everyone! Do you like music? Then why not check out my music channel. The LEXIS band will be uploading their own songs and covers soon so don't miss out. Please SUBSCRIBE too as it does help us out a lot. Just takes one click. ->\ufeff",
'This song never gets old love it.\ufeff',
'gofundme.com/grwmps\ufeff',
'Hey guys please check out my new Google+ page it has many funny pictures, FunnyTortsPics https://plus.google.com/112720997191206369631/post\ufeff',
'#2012bitches\ufeff', 'Made in china....\ufeff',
'5 milions comentars and 2 bilion views\ufeff',
'It is 0 zero\ufeff',
'Mix - PSY - GANGNAM STYLE (강남스타일) M/V: PSY - GANGNAM STYLE (강남스타일) M/V\ufeff',
'This has had over 2 billion views. Holy shit.\ufeff',
'how can there be 2.124.821.694 views, when im the only person alive after the zombie apocalypse - greetings, spoderman :)\ufeff',
'Suscribe my channel please\ufeff',
'2,124923004 wiews... wow\ufeff',
'guys please subscribe me to help my channel grow please guys\ufeff',
'Great music anyway\ufeff',
'PSY - GANGNAM STYLE (강남스타일) M/V: http://youtu.be/9bZkp7q19f0\ufeff',
'so crazy, over 2 billion views, not US, not Uk, its Korea republic, its asia\ufeff',
'Discover a beautiful song of A young Moroccan http://www.linkbucks.com/AcN2g\ufeff',
'Like getting Gift cards..but hate spending the cash.... Try Juno Wallet !!! At Juno Wallet you can earn money for gift cards such as ; Nike, Gamestop, Amazon , Ebay Etc & its easy Earn money by doing simple task like watching videos..downloading apps & you can even earn money by inviting your friends to join...its free for signup Sign up today & use promo code BD3721315\ufeff',
'Can somebody wake me up when we get to 3 billion views.\ufeff',
'PSY GOT LOTS OF MONEY FROM YOUTUBE THAT HE GOT FROM 2 BILLION VIEWS THIS IS THE MOST VIEWS IN THE WORLD :D\ufeff',
'Justin bieber = gay \ufeff',
"You gotta say its funny. well not 2 billion worth funny but still. It clicked and everything went uphill. At least you don't have JB's shit on #1.\ufeff",
'❤️ ❤️ ❤️ ❤️ ❤️❤️❤️❤️\ufeff', 'Ahhh, 2 years ago....\ufeff',
'Dance dance,,,,,Psy http://www.reverbnation.com/msmarilynmiles\ufeff',
'check out "starlitnightsky" channel to see epic videos\ufeff',
'https://www.tsu.co/KodysMan plz ^^\ufeff',
'Stupid people... this video doesnt have 2 billion visits. Have 2 thousands millions\ufeff',
'http://www.gcmforex.com/partners/aw.aspx?Task=JoinT2&AffiliateID=9107\ufeff',
'check men out i put allot of effort into my music but unfortunatly not many watch it\ufeff',
'pls http://www10.vakinha.com.br/VaquinhaE.aspx?e=313327 help me get vip gun cross fire al\ufeff',
'Add me here...https://www.facebook.com/TLouXmusic\ufeff',
'CHECK MY CHANNEL OUT PLEASE. I DO SINGING COVERS\ufeff',
'I think this is now a place to promote channels in the comment section lol.\ufeff',
'Get free gift cards and pay pal money!\ufeff',
'Check out pivot animations in my channel\ufeff',
'Follow me on twitter & IG : __killuminati94\ufeff',
"Check me out I'm all about gaming \ufeff",
'Oppa! Yeah! Best Song!\ufeff',
'More... http://www.sunfrogshirts.com/Sunglass-World.html?24398\ufeff',
'https://www.facebook.com/teeLaLaLa\ufeff',
'http://www.twitch.tv/zxlightsoutxz\ufeff',
'reminds me of this song https://soundcloud.com/popaegis/wrenn-almond-eyes\ufeff',
'What free gift cards? Go here http://www.swagbucks.com/p/register?rb=13017194\ufeff',
'Search "Chubbz Dinero - Ready Or Not " Thanks \ufeff',
'Follow me on Twitter @mscalifornia95\ufeff',
'😫😓😏😪😔😖😌😭😎😚😘😙😗😋😝😜😛😍😒😞😷😶😵😳😲😱😟😰😩😨😧😦😥😤😣😮😴😢😡😠😬😕😑😐😯😉😈😇😆😅😄😃😂😁😀😊☺ every single types of face on earth\ufeff',
'▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ DAMN THIS COMMENT IS FANCY ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬\ufeff',
"CHECK MY CHANNEL FOR MY NEW SONG 'STATIC'!! YOU'LL LOVE IT!!\ufeff",
'Incmedia.org where the truth meets you.\ufeff',
'look at my channel i make minecraft pe lets play \ufeff',
'I found out this song now\ufeff', '2 BILLION!!!\ufeff',
'Song name??\ufeff',
'please like : http://www.bubblews.com/news/9277547-peace-and-brotherhood\ufeff',
'hey again if you guys wouldnt mind chacking out my rap give it like and il giver 3 of your vids a like\ufeff',
'http://www.amazon.co.uk/gp/offer-listing/B00ECVF93G/sr=8-2/qid=1415297812/ref=olp_tab_refurbished?ie=UTF8&condition=refurbished&qid=1415297812&sr=8-2 \ufeff',
'The most watched video on YouTube is Psy’s “Gangnam Style”, with 2.1 billion views. PSY - GANGNAM STYLE (강남스타일) M/V\ufeff',
"Subscribe to me and I'll subscribe back!!!\ufeff",
'http://flipagram.com/f/LUkA1QMrhF\ufeff',
'For Christmas Song visit my channel! ;)\ufeff',
'http://www.gofundme.com/gvr7xg\ufeff',
'Subscribe to me i subscribe back!!!! Plus i have a nice ass lol\ufeff',
'https://www.change.org/p/facebook-twitter-youtube-do-not-censor-julien-blanc \ufeff',
'https://soundcloud.com/jackal-and-james/wrap-up-the-night\ufeff',
'https://www.surveymonkey.com/s/CVHMKLT\ufeff',
"Please give us a chance and check out the new music video on our channel! You won't be disappointed.\ufeff",
'Please subscribe to me\ufeff',
'This is the best, funny and viral video of history (youtube) THE TRUE\ufeff',
'Please check out my vidios\ufeff', 'OPPA GANGNAM STYLE!!!\ufeff',
"The funny thing is, 1,700,000,000 of the views are spam bots. I mean c'mon 2 BILLION views? BS!\ufeff",
'OPPA <3\ufeff',
"It's so funny it's awesomeness lol aaaaaaa sexy lada😂\ufeff",
'most viewed video in the world\ufeff',
"I'm here to check the views.. holy shit\ufeff",
'Dear person reading this, You are beautiful and loving Have a great day\ufeff',
'http://www.ermail.pl/dolacz/V3VeYGIN CLICK http://www.ermail.pl/dolacz/V3VeYGIN http://www.ermail.pl/dolacz/V3VeYGIN http://www.ermail.pl/dolacz/V3VeYGIN http://www.ermail.pl/dolacz/V3VeYGIN http://www.ermail.pl/dolacz/V3VeYGIN http://www.ermail.pl/dolacz/V3VeYGIN\ufeff',
"Have you tried a new social network TSU? This new social network has a special thing.You can share the posts as well as on fb and twitter and even to'll get paid You can registr here: https://www.tsu.co/WORLDWIDE_LIFE\ufeff",
'The Guy in the yellow suit kinda looks like Jae-suk \ufeff',
"People, here is a new network like FB...you register also free, the difference is only that you get paid for sharing, commenting and liking posts and so one...don't waste your time on fb for sharing and not being paid!! Register here to make also money with your everyday posts!! https://www.tsu.co/slema13 Wellcome to everyone! ;)\ufeff",
'How are there 2 billion views and theres only 2 million people in the world!?!?!?!! MULTIPLE ACCOUNTS!!!1111\ufeff',
'WAT DA FUCK THIS THE MOST VIEWED VIDEO IN YOUTUBE!\ufeff',
'OMG 2/7 People watched this video because there are 7 billion people in the world and 2 billion watched this\ufeff',
'What is he saying?!?!?!?!?!?!?!?$? \ufeff',
'this has so many views\ufeff', 'OMG over 2 billion views!\ufeff',
'Subscribe to me plz plz plz plz plz plZ \ufeff',
"http://www.twitch.tv/tareko100 Follow him on twitch and enter the keyword !5800 and you'll have a chance of winning a really nice and expensive gun for csgo that you can sell on the steam market\ufeff",
'i am 2,126,492,636 viewer :D\ufeff',
'https://www.tsu.co/Aseris get money here !\ufeff',
'Fantastic!\ufeff',
'The population of world is more than 7 billion\ufeff',
'2.126.521.750 views!!!!!!!!!!!!!!!!!\ufeff',
'Wow 23 min ago\ufeff',
'SUPER!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\ufeff',
'P E A C E & L O V E ! !\ufeff',
'How can this music video get 2 billion views while im the only one watching here on earth?????? lol\ufeff',
'Please friend read my book and repass: http://www.4shared.com/web/preview/pdf/CjFofTxeba?\ufeff',
'subscribe to me :) \ufeff', 'Still the best. :D\ufeff',
'The most liked video on YouTube...\ufeff',
'Still watching this 2 years later? \ufeff',
"Hello! I'm kind of new to Youtube, And soon i'm soon going to be making Launchpad Video's! :D I would really appreciate if i got some subs before i started so that people can spot me easily! I dont really care about hate comments so dont bother -_-\ufeff",
'Lol...I dunno how this joke gets a lot of likes, but whatever. xD\ufeff',
'2 Billion Views For This Piece Of Shit... ~ A R E ~ Y O U ~ K I D D I N G ~ M E ~\ufeff',
'GANGMAN STY- *D-D-D-D-D-D--DROP THE BASS!!*\ufeff',
'Will this song ever reach 7 Billion Views?\ufeff',
'Im a RAPPER/SONGWRITER, check my video PLEASE..also subscribe for more thanks :) tell me what you think.\ufeff',
'Hello all 29.24% earth population of the world, hope your having a great day :)\ufeff',
'Is this the video that started the whole "got my dick stuck in an elevator" excuse thing? \ufeff',
'Can anyone sub to my channel? :D\ufeff',
'prehistoric song..has been\ufeff',
"You think you're smart? Headbutt your face.\ufeff",
'DISLIKE.. Now one knows REAL music - ex. Enimen \ufeff',
'Loool nice song funny how no one understands (me) and we love it\ufeff',
'Like if you came here too see how many views this song has.\ufeff',
'We pray for you Little Psy ♡\ufeff',
"''Little Psy, only 5 months left.. Tumor in the head :( WE WILL MISS U <3\ufeff",
' Follow me on Instagram. _chris_cz \ufeff',
'how is this shit still relevant \ufeff',
'LOL this shit never gets old\ufeff',
'What Can i say....This Song He Just Change The World Completely... So good job PSY... (and your girls are awesome :))) )\ufeff',
'On 0:02 u can see the camera man on his glasses....\ufeff',
'this comment is wrong\ufeff',
'i hate this music. fucking singer and every koean chainise ana US sucks me dick.\ufeff',
'2:05. Hahahahah \ufeff',
'Can we reach 3 billion views by December 2014? \ufeff',
'Dumb Guy: Why is there 2 billion views when there are 7 million people on earth??? Also, I know what 1+1 equals! 1+1=1! I am a smartie pants\ufeff',
'People Who Say That "This Song Is Too Old Now, There\'s No Point Of Listening To It" Suck. Just Stfu And Enjoy The Music. So, Your Mom Is Old Too But You Still Listen To Her Right?....\ufeff',
'The Funny Thing Is That this song was made in 2009 but it took 2 years to get to america.\ufeff',
'why I dont see any comments but mine?:/\ufeff',
'this jap is such a piece of shit. he is such a worthless fish head. i dont know how any one likes this dumb untanlted gook. this isnt even fucken music. this is so fucking sad that this is even such thing. people are so fucked up.\ufeff',
'I remember when everyone was obsessed with Gangnam Style 😗\ufeff',
'Remove This video its wank\ufeff',
"It's so hard, sad :( iThat little child Actor HWANG MINOO dancing very active child is suffering from brain tumor, only 6 month left for him .Hard to believe .. Keep praying everyone for our future superstar. #StrongLittlePsY #Fighting SHARE EVERYONE PRAYING FOR HIM http://ygunited.com/2014/11/08/little-psy-from-the-has-brain-tumor-6-months-left-to-live/ \ufeff",
'Why the fuck this keeps updated? Comments :"5 minutes ago" Song: "2 years and 4 months ago"\ufeff',
'MANY MEMORIES...........\ufeff',
'why are they 5million comments when there is only 279.898 youtube Users. 5million fake account or PSY hacked youtube\ufeff',
'2,000,000,000 out of 7,000,000,000 people in the would saw this video just in 2 years and yeat i only get 2 words out of the hole song\ufeff',
'This video is so cool, again and again!\ufeff',
'I am now going to voyage to the first comment... Tell my family I loved them. 😢\ufeff',
"How did THIS Video in all of YouTube get this many views and likes? Why Gangnam style? I don't have a problem with it, i just don't understand the phenomena behind it, it's just like any other random music video out there. \ufeff",
"With the korean girl more slut and bitch : Hyuna :'33\ufeff",
"Hey guys! Check this out: Kollektivet - Don't be slappin' my penis! I think that they deserve much more credit than they receive.\ufeff",
'Still a very fun music video to watch! \ufeff',
"C'mon 3 billion views!!!!!!!!\ufeff",
'Hey everyone, I am a new channel and will post videos of book reviews and music on the flute. Please subscribe if you would enjoy that. Thanks!\ufeff',
"Hey I think I know what where dealing with here!!!! I have some theories of how this could've gotten 2billion hits!! 1. This was mabey made in korea and its realy popular there so they were stuck watching this over and over again. 2. Over 2billion people have access to the Internet, including youtube, and the numbers are rising, by 2017 half of the populatoin will be connected. 3. Hackers In Korea may have loved it so much they rised it to 2billion hits to make it more popular. 4. The song was featured in a just dance game, on multiple mp3s, and been seen on concerts and even on new years eve event in 2012, so just by seeing those you mabey adding more hits to this video. 5. You are complaining to much on how the heck this has 2b hits.\ufeff",
'subscribe my chanel\ufeff',
'THIS HAS MORE VIEWS THAN QUEEN AND MICHAEL JACKSON, 2 BILLION views omg\ufeff',
'LoL\ufeff',
'If you pause at 1:39 at the last millisecond you can see that that chick is about to laugh. Takes a few tries.\ufeff',
"9 year olds be like, 'How does this have 2 billion views when there are only 3 people in the world'\ufeff",
'PSY is a good guy\ufeff',
'WHY DOES THIS HAVE 2 BILLION VIEWS THIS SONG IS SO ANNOYING\ufeff',
'https://www.facebook.com/pages/Mathster-WP/1495323920744243?ref=hl\ufeff',
'1 millioon dislikesssssssssssssssssssssssssssssssss.............\ufeff',
'The little PSY is suffering Brain Tumor and only has 6 more months to live. Please pray to him and the best lucks.\ufeff',
'For all of the little kidz out there there is Like 7 to 8 Billon people on earth NOT 7 to 8 MILLON.Get you facts straight before posting comments.\ufeff',
'How stupid humanity is\ufeff',
'Come and watch my video it is called the odowd crowd zombie movie part 1 \ufeff',
'You know a song sucks dick when you need to use google translate to know what the fuck its saying!\ufeff',
'We get it, you came here for the views... \ufeff',
'Wow this video is the most viewed youtube video.. second that comes Justin bieber- baby SMH WHAT HAS THE WORLD COME TO\ufeff',
'Hey, join me on tsū, a publishing platform where I share my content now: http://tsu.co/MarkusMairhofer\ufeff',
'This song is great there are 2,127,315,950 views wow\ufeff',
"I'm watching this in 2014\ufeff",
'Most viewed video on youtube...daaaaaaaaaaannng those views can almost dominate the entire...china...\ufeff',
'how does this video have 2,127,322,484 views if there are only 7 million people on earth?\ufeff',
'What my gangnam style\ufeff',
'Lol this youtuber (officialpsy) is getting so much money lol\ufeff',
'1 million dislikes!EPIC FAIL(ready for you fanboys)\ufeff',
'If I knew Korean, this would be even funnier. At least a bit at the end was in English, but was spoken quite rapidly.\ufeff',
'Enough with the whole "how does this have two billion views if there\'s only 7 million on the planet" we get it. You\'re joking. It\'s not funny anymore.\ufeff',
"If I get 100 subscribers, I will summon Freddy Mercury's ghost to whipe from the face of earth One Direction and Miley Cirus.\ufeff",
"if i reach 100 subscribers i will go round in public pouring a bucket of ice water over people and then running away acting like it wasn't me! like so people can see!!\ufeff",
'YOUTUBE MONEY !!!!!!!!!!!!!!!!!!!!!!!\ufeff',
'2 billion for this shit?\ufeff',
'2 billion views, only 2 million shares\ufeff',
'Hi guys my name is Dylan and I do IRL football videos I have 1030 subscribers and I think you guys would like my content so come check it out and if you do subscribe!\ufeff',
"If I get 300 subscribers by tomorrow I'll do a epic Hunger Games Video! \ufeff",
'follower please https://www.facebook.com/lists/161620527267482\ufeff',
"2 billion views wow not even baby by justin beibs has that much he doesn't deserve a capitalized name\ufeff",
'If i reach 100 subscribers i will tazz my self and my friend\ufeff',
'Please help me go to college guys! Thanks from the bottom of my heart. https://www.indiegogo.com/projects/i-want-to-go-to-college--19/x/9082175\ufeff',
'https://www.facebook.com/SchoolGeniusNITS/photos/ms.c.eJw9kVkOxDAMQm808h5z~;4sNjqP~_tHqBEuM69AQUp1Ih~_fPHgk5zLLsVdQv0ZUf0MB~;LnUJ~;ufTH4YoKfRxYts2zvrrp6qGtw67y~;L551h~;f7~_vlcZzRG8vGCTlPSD9ONGeWhj8~_GIbu~;S3lzMvY~;IQ2~;TwSfzz9WHn7JUSvHufpglQRZczl05fNPhaGeVb3x8yDmC6X~_~;jTcjnMho~;vfXWCjZyvWObihrnGx2ocjnG2PG1EvHXzyjD~_o3h~_RY6f57sPrnD2xV~;~_BzszZ~;8~-.bps.a.390875584405933/391725794320912/?type=1&theater \ufeff',
'I am so awesome and smart!!! Sucscribe to me!\ufeff',
'Follow 4 Follow @ VaahidMustafic Like 4 Like \ufeff',
'http://hackfbaccountlive.com/?ref=4436607 psy news offıcal \ufeff',
'https://www.facebook.com/nicushorbboy add mee <3 <3\ufeff',
"im sorry for the spam but My name is Jenny. I go to high school where everyone dresses fashionable but for me I don't because i need money to buy cute clothes. I have low self esteem . I live with my dad. my mom passed away when i was 6 so i don't really have a mother figure. I have 2 brothers who is older than me. Since they are boys they get the attention while i just be alone. I really want to wear pretty clothes like the girls in my school and get a boyfriend. i just can't be my self. im very quite and shy at school because i don't have the confidence in myself to talk to someone. i did have one friend name Caroline but she moved away so now im alone. if you could donate some money to me it would be great. i don't care about expensive brand ill just shop at walmart because they have pretty clothes. also i wanna get my nails done at a salon . i see alot of girls have these french tips. i never had my nail did at a salon before i will really appreciate if i can and get my hair curled too. http://www.gofundme.com/dressprettyonce thanks omg please.\ufeff",
' I hate this song! \ufeff',
'please throw a sub on my channel\ufeff',
"NEW GOAL! 3,000,000! Let's go for it!\ufeff",
'Go to my channel if u want to see a fly getting burned alive\ufeff',
'just came here to check the views :P\ufeff',
'COME AND CHECK OUT MY NEW YOUTUBE CHHANEL, GOING TO BE POSTING DAILY!\ufeff',
"I hav absolutely no idea what he's saying. Is it even a language?\ufeff",
'Please check out my vidios guys\ufeff',
'I still to this day wonder why this video is so popular ?? illuminati confirmed ??\ufeff',
"Hey guys can you check my channel out plz. I do mine craft videos. Let's shoot for 20 subs\ufeff",
'This is getting old.........\ufeff',
'PLEASE SUBSCRIBE ME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\ufeff',
'just came to check the view count\ufeff',
'Check out my Music Videos! Fuego - U LA LA Remix hyperurl.co/k6a5xt\ufeff',
'Check out my Music Videos! and PLEASE SUBSCRIBE!!!! Fuego - U LA LA Remix hyperurl.co/k6a5xt\ufeff',
'www.marketglory.com/strategygame/lordviperas\ufeff',
"If the shitty Chinese Government didn't block YouTube over there, there'd be close to 3 billion views right now. \ufeff",
'WORLD RECORD YOUTUBE VIDEO VIEWS !!!!!! XD\ufeff',
'I think he was drunk during this :) x)\ufeff',
'Limit sun exposure while driving. Eliminate the hassle of having to swing the car visor between the windshield and window. https://www.kickstarter.com/projects/733634264/visortwin\ufeff',
'Hahah, juyk! I allways laugh at the part 1:57.. LOL!\ufeff',
'http://hackfbaccountlive.com/?ref=5242575\ufeff',
'I wanted to know the name of the guy that dances at 00:58, anybody knows ?\ufeff',
'https://www.facebook.com/FUDAIRYQUEEN?pnref=story\ufeff',
'Haha its so funny to see the salt of westerners that top views of youtube goes to video they dont even understand, keep the salt up!\ufeff',
'FOLLOW MY COMPANY ON TWITTER thanks. https://twitter.com/TheWaxedHatCo\ufeff',
'imagine if this guy put adsense on with all these views... u could pay ur morgage\ufeff',
"Hey come check us out were new on youtube let us know what you think and don't forget to subscribe thanks.\ufeff",
'The girl in the train who was dancing, her outfit was so fucking sexy, but the huge turn-off was she lacked eyebrows D:\ufeff',
'Look at the pictures, if not difficult http://image2you.ru/48051/1340524/ http://image2you.ru/48051/1340523/ http://image2you.ru/48051/1340522/ http://image2you.ru/48051/1340521/ http://image2you.ru/48051/1340520/ http://image2you.ru/48051/1340519/ http://image2you.ru/48051/1340518/ http://image2you.ru/48051/1340517/ http://image2you.ru/48051/1340504/ http://image2you.ru/48051/1340503/ http://image2you.ru/48051/1340502/ http://image2you.ru/48051/1340500/ http://image2you.ru/48051/1340499/ http://image2you.ru/48051/1340494/ http://image2you.ru/48051/1340493/ http://image2you.ru/48051/1340492/ http://image2you.ru/48051/1340491/ http://image2you.ru/48051/1340490/ http://image2you.ru/48051/1340489/ http://image2you.ru/48051/1340488/\ufeff',
"Don't mind me, I'm just checking what the views are up to : )\ufeff",
'Hey guys can you check my YouTube channel I know you hate comments like this one but I promise if you check my videos it will be entertaining I do Shotgun Montages,Ninja Defuse Montages and Trolling please guys can you check them out and thanks have a good day!!!!!!!\ufeff',
"To everyone joking about how he hacked to get 2 billion views because there's a certain amount of people or whatever, He actually did buy views.\ufeff",
'https://www.facebook.com/tofikmiedzynB/photos/a.1496273723978022.1073741828.1496241863981208/1498561870415874/?type=1&theater \ufeff',
'https://www.facebook.com/eeccon/posts/733949243353321?comment_id=734237113324534&offset=0&total_comments=74 please like frigea marius gabriel comment :D\ufeff',
'http://www.bing.com/explore/rewards?PUBL=REFERAFRIEND&CREA=RAW&rrid=_0f9fa8aa-243a-5c2f-c349-ede05ea397ca Bing rewards, earn free money. AND NO U CANT GET UR VIRUS IN BLUE!\ufeff',
"Please do buy these new Christmas shirts! You can buy at any time before December 4th and they are sold worldwide! Don't miss out: http://teespring.com/treechristmas\ufeff",
'Free my apps get 1m crdits ! Just click on the link and download a app and done!! · Link: https://m.freemyapps.com/share/url/5af506e1\ufeff',
'Why does a song like this have more views than Michael Jackson SMH\ufeff',
' Something to dance to, even if your sad JUST dance!! PSY - GANGNAM STYLE (강남스타일) M/V: http://youtu.be/9bZkp7q19f0\ufeff',
'everyones back lool this is almost 3 years old and people are still hear! xD\ufeff',
"How can this have 2 billion views when there's only me on the planet? LOL\ufeff",
"I don't now why I'm watching this in 2014\ufeff",
'subscribe to me for call of duty vids and give aways Goal-100 subs\ufeff',
'hi guys please my android photo editor download. thanks https://play.google.com/store/apps/details?id=com.butalabs.photo.editor\ufeff',
'The first billion viewed this because they thought it was really cool, the other billion and a half came to see how stupid the first billion were...\ufeff'],
dtype=object)yarray(['Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Not Spam',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Not Spam', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Not Spam', 'Spam Comment', 'Spam Comment', 'Not Spam',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Not Spam', 'Spam Comment', 'Spam Comment', 'Not Spam',
'Spam Comment', 'Spam Comment', 'Not Spam', 'Not Spam',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Not Spam', 'Spam Comment',
'Not Spam', 'Not Spam', 'Spam Comment', 'Not Spam', 'Not Spam',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Not Spam',
'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam',
'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Not Spam', 'Not Spam',
'Spam Comment', 'Spam Comment', 'Not Spam', 'Spam Comment',
'Not Spam', 'Spam Comment', 'Not Spam', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Not Spam',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Not Spam', 'Spam Comment',
'Not Spam', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Not Spam', 'Not Spam', 'Spam Comment',
'Spam Comment', 'Not Spam', 'Spam Comment', 'Spam Comment',
'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam',
'Not Spam', 'Not Spam', 'Spam Comment', 'Not Spam', 'Spam Comment',
'Not Spam', 'Not Spam', 'Not Spam', 'Spam Comment', 'Spam Comment',
'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam',
'Not Spam', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Not Spam', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Not Spam', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Not Spam',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Not Spam',
'Not Spam', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Not Spam', 'Not Spam', 'Not Spam', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Not Spam', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Not Spam', 'Spam Comment', 'Not Spam', 'Not Spam', 'Not Spam',
'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam', 'Spam Comment',
'Spam Comment', 'Not Spam', 'Spam Comment', 'Not Spam', 'Not Spam',
'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam', 'Spam Comment',
'Spam Comment', 'Not Spam', 'Spam Comment', 'Not Spam', 'Not Spam',
'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam',
'Spam Comment', 'Spam Comment', 'Not Spam', 'Not Spam', 'Not Spam',
'Spam Comment', 'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam',
'Spam Comment', 'Not Spam', 'Not Spam', 'Spam Comment', 'Not Spam',
'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam',
'Not Spam', 'Spam Comment', 'Not Spam', 'Not Spam', 'Not Spam',
'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam',
'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam',
'Not Spam', 'Not Spam', 'Spam Comment', 'Not Spam', 'Not Spam',
'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam',
'Not Spam', 'Spam Comment', 'Not Spam', 'Not Spam', 'Spam Comment',
'Not Spam', 'Spam Comment', 'Not Spam', 'Not Spam', 'Not Spam',
'Not Spam', 'Not Spam', 'Not Spam', 'Spam Comment', 'Not Spam',
'Not Spam', 'Not Spam', 'Not Spam', 'Spam Comment', 'Not Spam',
'Not Spam', 'Not Spam', 'Spam Comment', 'Not Spam', 'Not Spam',
'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam',
'Not Spam', 'Not Spam', 'Spam Comment', 'Spam Comment', 'Not Spam',
'Not Spam', 'Not Spam', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Not Spam', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Spam Comment', 'Not Spam', 'Spam Comment',
'Not Spam', 'Spam Comment', 'Not Spam', 'Spam Comment', 'Not Spam',
'Spam Comment', 'Not Spam', 'Spam Comment', 'Not Spam',
'Spam Comment', 'Not Spam', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Not Spam', 'Not Spam', 'Not Spam', 'Spam Comment',
'Not Spam', 'Spam Comment', 'Not Spam', 'Spam Comment', 'Not Spam',
'Spam Comment', 'Not Spam', 'Spam Comment', 'Not Spam',
'Spam Comment', 'Not Spam', 'Spam Comment', 'Not Spam',
'Spam Comment', 'Spam Comment', 'Spam Comment', 'Spam Comment',
'Spam Comment', 'Not Spam', 'Not Spam', 'Not Spam', 'Not Spam',
'Not Spam', 'Spam Comment', 'Spam Comment', 'Not Spam'],
dtype=object)# Check the shape of X and y variable
X.shape, y.shape((350,), (350,))
Machines cannot understand characters and words. So when dealing with text data we need to represent it in numbers to be understood by the machine. Countvectorizer is a method to convert text to numerical data. To show you how it works let’s take an example:
text = [‘Hello my name is james, this is my python notebook’]
The text is transformed to a sparse matrix as shown below.
- Hello is james my name notebook python this
- 1 2 1 2 1 1 1 1
from sklearn.feature_extraction.text import CountVectorizer
count_vec = CountVectorizer()
X = count_vec.fit_transform(X)
With CountVectorizer we are converting raw text to a numerical vector representation of words and n-grams. This makes it easy to directly use this representation as features (signals) in Machine Learning tasks such as for text classification and clustering.
2. Spliting the dataset in training and testing data.
Here we are spliting our dataset into 80/20 percentage where 80% dataset goes into the training part and 20% goes into testing part.
# Split the X and y into X_train, X_test, y_train, y_test variables with 80-20% split.
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)# Check shape of the splitted variables
X_train.shape, X_test.shape, y_train.shape, y_test.shape((280, 1418), (70, 1418), (280,), (70,))
Insights: -
Train test split technique is used to estimate the performance of machine learning algorithms which are used to make predictions on data not used to train the model.It is a fast and easy procedure to perform, the results of which allow you to compare the performance of machine learning algorithms for your predictive modeling problem. Although simple to use and interpret, there are times when the procedure should not be used, such as when you have a small dataset and situations where additional configuration is required, such as when it is used for classification and the dataset is not balanced.
In the next step we will train our model on the basis of our training and testing data.
Step 3: Model Training
Goal:
In this step we are going to train our dataset on different classification algorithms. As we know that our target variable is in discrete format so we have to apply classification algorithm. Target variable is a category like filtering.In our dataset we have the outcome variable or Dependent variable i.e Y having only two set of values, either 1 (Spam) or 0(Not Spam). So we will use Classification algorithm**
Algorithms we are going to use in this step
- Bernoulli Naive Bayes
- Linear SVC
- Random Forest Classification
K-fold cross validation is a procedure used to estimate the skill of the model on new data. There are common tactics that you can use to select the value of k for your dataset. There are commonly used variations on cross-validation, such as stratified and repeated, that are available in scikit-learn
# Define kfold with 10 split
cv1 = KFold(n_splits=10, shuffle=True, random_state=42)
The goal of cross-validation is to test the model’s ability to predict new data that was not used in estimating it, in order to flag problems like overfitting or selection bias and to give an insight on how the model will generalize to an independent dataset (i.e., an unknown dataset, for instance from a real problem).
1. Bernoulli Naive Bayes
Naive Bayes is a supervised machine learning algorithm to predict the probability of different classes based on numerous attributes. It indicates the likelihood of occurrence of an event. Naive Bayes is also known as conditional probability.
Bernoulli Naive Bayes is a part of the Naive Bayes family. It is based on the Bernoulli Distribution and accepts only binary values, i.e., 0 or 1. If the features of the dataset are binary, then we can assume that Bernoulli Naive Bayes is the algorithm to be used.
Train set cross-validation
#Using Bernoulli Naive Bayes algorithm to the Training Set
from sklearn.naive_bayes import BernoulliNB
model = BernoulliNB()
model.fit(X_train, y_train)BernoulliNB()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
BernoulliNB
BernoulliNB()#Accuracy check of trainig data
#Get R2 score
model.score(X_train, y_train)0.9785714285714285#Accuracy of test data
model.score(X_test, y_test)0.9857142857142858
Prediction
Now we will perform prediction on the dataset using Logistic Regression.
# Predict the values on X_test_scaled dataset
y_predicted = model.predict(X_test)
Various parameters are calculated for analysing the predictions.
- Confusion Matrix 2)Classification Report 3)Accuracy Score 4)Precision Score 5)Recall Score 6)F1 Score
Confusion Matrix
A confusion matrix presents a table layout of the different outcomes of the prediction and results of a classification problem and helps visualize its outcomes. It plots a table of all the predicted and actual values of a classifier.
This diagram helps in understanding the concept of confusion matrix.
# Constructing the confusion matrix.
from sklearn.metrics import confusion_matrix#confusion matrix btw y_test and y_predicted
cm = confusion_matrix(y_test,y_predicted)#We are creating Confusion Matrix on heatmap to have better understanding
# sns.heatmap(cm,cmap = 'Red') ~ to check for available colors
sns.set(rc = {'figure.figsize':(5,5)})
sns.heatmap(cm,cmap = 'icefire_r', annot = True, cbar=False, linecolor='Black', linewidth = 2)
plt.title("Confusion matrix")
plt.xlabel('Predicted CLass')
plt.ylabel('True Class')Text(29.75, 0.5, 'True Class')
sns.heatmap(cm/np.sum(cm), annot=True,
fmt='.2%', cmap='Blues', cbar = False)<AxesSubplot: >
Evaluating all kinds of evaluating parameters.
Classification Report :
A classification report is a performance evaluation metric in machine learning. It is used to show the precision, recall, F1 Score, and support of your trained classification model.
F1_score :
The F1 score is a machine learning metric that can be used in classification models.
Precision_score :
The precision is the ratio tp / (tp + fp) where tp is the number of true positives and fp the number of false positives. The precision is intuitively the ability of the classifier not to label as positive a sample that is negative. The best value is 1 and the worst value is 0.
Recall_score :
Recall score is used to measure the model performance in terms of measuring the count of true positives in a correct manner out of all the actual positive values. Precision-Recall score is a useful measure of success of prediction when the classes are very imbalanced.
# Evaluating the classifier
# printing every score of the classifier
# scoring in anything
from sklearn.metrics import classification_report
from sklearn.metrics import f1_score, accuracy_score, precision_score,recall_score
from sklearn.metrics import confusion_matrix
print("The model used is Bernoulli Naive Bayes")
l_acc = accuracy_score(y_test, y_predicted)
print("\nThe accuracy is: {}".format(l_acc))
prec = precision_score(y_test, y_predicted,average="binary", pos_label="Spam Comment")
print("The precision is: {}".format(prec))
rec = recall_score(y_test, y_predicted,average="binary", pos_label="Spam Comment")
print("The recall is: {}".format(rec))
f1 = f1_score(y_test, y_predicted,average="binary", pos_label="Spam Comment")
print("The F1-Score is: {}".format(f1))
c1 = classification_report(y_test, y_predicted)
print("Classification Report is:")
print()
print(c1)The model used is Bernoulli Naive Bayes
The accuracy is: 0.9857142857142858
The precision is: 1.0
The recall is: 0.9767441860465116
The F1-Score is: 0.988235294117647
Classification Report is:
precision recall f1-score support
Not Spam 0.96 1.00 0.98 27
Spam Comment 1.00 0.98 0.99 43
accuracy 0.99 70
macro avg 0.98 0.99 0.99 70
weighted avg 0.99 0.99 0.99 70
2. Linear SVC
The objective of a Linear SVC (Support Vector Classifier) is to fit to the data you provide, returning a “best fit” hyperplane that divides, or categorizes, your data. From there, after getting the hyperplane, you can then feed some features to your classifier to see what the “predicted” class is. This makes this specific algorithm rather suitable for our uses, though you can use this for many situations.
#Using KNeighborsClassifier Method of neighbors class to use Nearest Neighbor algorithm
from sklearn.svm import LinearSVC
classifier = LinearSVC()
classifier.fit(X_train, y_train)LinearSVC()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
LinearSVC
LinearSVC()#Accuracy check of trainig data
#Get R2 score
classifier.score(X_train, y_train)1.0#Accuracy of test data
classifier.score(X_test, y_test)0.9714285714285714
Prediction
# Predict the values on X_test_scaled dataset
y_predicted = classifier.predict(X_test)# Constructing the confusion matrix.
from sklearn.metrics import confusion_matrix#Confusion matrix btw y_test and y_predicted
cm = confusion_matrix(y_test,y_predicted)#We are drawing cm on heatmap to have better understanding
# sns.heatmap(cm,cmap = 'Red') ~ to check for available colors
sns.heatmap(cm,cmap = 'icefire_r', annot = True, fmt= 'd', cbar=False, linecolor='Black', linewidth = 2)
plt.title("Confusion matrix")
plt.xlabel('Predicted CLass')
plt.ylabel('True Class')Text(29.75, 0.5, 'True Class')
sns.heatmap(cm/np.sum(cm), annot=True,
fmt='.2%', cmap='Blues', cbar = False)<AxesSubplot: >
Evaluating all kinds of evaluating parameters.
# Evaluating the classifier
# printing every score of the classifier
# scoring in anything
from sklearn.metrics import classification_report
from sklearn.metrics import f1_score, accuracy_score, precision_score,recall_score
from sklearn.metrics import confusion_matrix
print("The model used is LinearSVC")
k_acc = accuracy_score(y_test, y_predicted)
print("\nThe accuracy is: {}".format(k_acc))
prec = precision_score(y_test, y_predicted,average="binary", pos_label="Spam Comment")
print("The precision is: {}".format(prec))
rec = recall_score(y_test, y_predicted,average="binary", pos_label="Spam Comment")
print("The recall is: {}".format(rec))
f1 = f1_score(y_test, y_predicted,average="binary", pos_label="Spam Comment")
print("The F1-Score is: {}".format(f1))
c1 = classification_report(y_test, y_predicted)
print("Classification Report is:")
print()
print(c1)The model used is LinearSVC
The accuracy is: 0.9714285714285714
The precision is: 0.9767441860465116
The recall is: 0.9767441860465116
The F1-Score is: 0.9767441860465116
Classification Report is:
precision recall f1-score support
Not Spam 0.96 0.96 0.96 27
Spam Comment 0.98 0.98 0.98 43
accuracy 0.97 70
macro avg 0.97 0.97 0.97 70
weighted avg 0.97 0.97 0.97 70
3. Random Forest Classifier
Random Forest is a powerful and versatile supervised machine learning algorithm that grows and combines multiple decision trees to create a “forest.” It can be used for both classification and regression problems in R and Python.
Random Forest and Decision Tree Algorithm are considered best for the data that has outliers.
#Using RandomForestClassifier method of ensemble class to use Random Forest Classification algorithm
from sklearn.ensemble import RandomForestClassifier
#clas = RandomForestClassifier(n_estimators = 10, criterion = 'entropy', random_state = 0)
clas = RandomForestClassifier()
clas.fit(X_train, y_train)RandomForestClassifier()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
RandomForestClassifier
RandomForestClassifier()#Accuracy check of trainig data
#Get R2 score
clas.score(X_train, y_train)1.0#Accuracy of test data
clas.score(X_test, y_test)0.9714285714285714
Prediction
# predict the values on X_test_scaled dataset
y_predicted = clas.predict(X_test)# Constructing the confusion matrix.
from sklearn.metrics import confusion_matrix#confusion matrix btw y_test and y_predicted
cm = confusion_matrix(y_test,y_predicted)#We are drawing cm on heatmap to have better understanding
# sns.heatmap(cm,cmap = 'Red') ~ to check for available colors
sns.heatmap(cm,cmap = 'icefire_r', annot = True, fmt= 'd', cbar=False, linecolor='Black', linewidth = 2)
plt.title("Confusion matrix")
plt.xlabel('Predicted CLass')
plt.ylabel('True Class')Text(29.75, 0.5, 'True Class')
sns.heatmap(cm/np.sum(cm), annot=True,
fmt='.2%', cmap='Blues', cbar = False)<AxesSubplot: >
Evaluating all kinds of evaluating parameters.
# Evaluating the classifier
# printing every score of the classifier
# scoring in anything
from sklearn.metrics import classification_report
from sklearn.metrics import f1_score, accuracy_score, precision_score,recall_score
from sklearn.metrics import confusion_matrix
print("The model used is Random Forest Classifier")
r_acc = accuracy_score(y_test, y_predicted)
print("\nThe accuracy is {}".format(r_acc))
prec = precision_score(y_test, y_predicted,average="binary", pos_label="Spam Comment")
print("The precision is {}".format(prec))
rec = recall_score(y_test, y_predicted,average="binary", pos_label="Spam Comment")
print("The recall is {}".format(rec))
f1 = f1_score(y_test, y_predicted,average="binary", pos_label="Spam Comment")
print("The F1-Score is {}".format(f1))
c1 = classification_report(y_test, y_predicted)
print("Classification Report is:")
print()
print(c1)The model used is Random Forest Classifier
The accuracy is 0.9714285714285714
The precision is 0.9767441860465116
The recall is 0.9767441860465116
The F1-Score is 0.9767441860465116
Classification Report is:
precision recall f1-score support
Not Spam 0.96 0.96 0.96 27
Spam Comment 0.98 0.98 0.98 43
accuracy 0.97 70
macro avg 0.97 0.97 0.97 70
weighted avg 0.97 0.97 0.97 70
Insight: -
cal_metric=pd.DataFrame([l_acc,k_acc,r_acc],columns=["Score in percentage"])
cal_metric.index=['Bernoulli Naive Bayes',
'LinearSVC',
'Random Forest']
cal_metric
- As you can see with our Bernoulli Naive Bayes Model(98.57%) we are getting a better result even for the recall (0.97 or 97%) which is the most tricky part.
- So we gonna save our model with Bernoulli Naive Bayes Model
Step 4: Save Model
Goal:- In this step we are going to save our model in pickel format file.
import pickle
pickle.dump(model , open('Spam_Comment_Detection_BernoulliNB.pkl', 'wb'))
pickle.dump(classifier , open('Spam_Comment_Detection_LinearSVC.pkl', 'wb'))
pickle.dump(clas , open('Spam_Comment_Detection_Logistic.pkl', 'wb'))import pickle
def model_prediction(features):
features = count_vec.transform([features]).toarray()
pickled_model = pickle.load(open('C:/My Sample Notebook/Notebook Template/Spam Comments Detection/model/Spam_Comment_Detection_BernoulliNB.pkl', 'rb'))
Comment = str(list(pickled_model.predict(features)))
return str(f'The Comment is {Comment}')
We can test our model by giving our own parameters or features to predict.
comment = "Lack of information!"model_prediction(comment)"The Comment is ['Not Spam']"
Conclusion
After observing the problem statement we have build an efficient model to overcome it. The above model helps in classifying the whether the comment is Spam or not. The accuracy for the prediction is 98.57% and it signifies the accurate classification of the comment.
Checkout whole project code here (github repo).
🚀 Unlock Your Dream Job with HiDevs Community!
🔍 Seeking the perfect job? HiDevs Community is your gateway to career success in the tech industry. Explore free expert courses, job-seeking support, and career transformation tips.
💼 We offer an upskill program in Gen AI, Data Science, Machine Learning, and assist startups in adopting Gen AI at minimal development costs.
🆓 Best of all, everything we offer is completely free! We are dedicated to helping society.
Book free of cost 1:1 mentorship on any topic of your choice — topmate
✨ We dedicate over 30 minutes to each applicant’s resume, LinkedIn profile, mock interview, and upskill program. If you’d like our guidance, check out our services here
💡 Join us now, and turbocharge your career!
Deepak Chawla LinkedIn
Vijendra Singh LinkedIn
Yajendra Prajapati LinkedIn
YouTube Channel
Instagram Page
HiDevs LinkedIn
Project Youtube Link