Akshat Sanghvi commited on
Commit
0f0bf58
Β·
unverified Β·
1 Parent(s): 31c8de4
Files changed (5) hide show
  1. Classifier.joblib +0 -0
  2. app.py +14 -0
  3. notebook.ipynb +505 -0
  4. requirements.txt +4 -0
  5. spam.csv +0 -0
Classifier.joblib ADDED
Binary file (339 kB). View file
 
app.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from joblib import load
3
+
4
+ model = load("Classifier.joblib")
5
+
6
+ def pred(Email):
7
+ l = model.predict([Email])
8
+ if l[0]==1:
9
+ return "Spam ⚠️"
10
+ else:
11
+ return "πŸ‘"
12
+
13
+ iface = gr.Interface(fn=pred, inputs="text", outputs="text", allow_flagging="never", description="Enter Your Message Below :")
14
+ iface.launch()
notebook.ipynb ADDED
@@ -0,0 +1,505 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "# Importing Essential libraries : \n",
10
+ "import pandas as pd\n",
11
+ "# import matplotlib.pyplot as plt"
12
+ ]
13
+ },
14
+ {
15
+ "cell_type": "code",
16
+ "execution_count": 2,
17
+ "metadata": {},
18
+ "outputs": [
19
+ {
20
+ "data": {
21
+ "text/html": [
22
+ "<div>\n",
23
+ "<style scoped>\n",
24
+ " .dataframe tbody tr th:only-of-type {\n",
25
+ " vertical-align: middle;\n",
26
+ " }\n",
27
+ "\n",
28
+ " .dataframe tbody tr th {\n",
29
+ " vertical-align: top;\n",
30
+ " }\n",
31
+ "\n",
32
+ " .dataframe thead th {\n",
33
+ " text-align: right;\n",
34
+ " }\n",
35
+ "</style>\n",
36
+ "<table border=\"1\" class=\"dataframe\">\n",
37
+ " <thead>\n",
38
+ " <tr style=\"text-align: right;\">\n",
39
+ " <th></th>\n",
40
+ " <th>Category</th>\n",
41
+ " <th>Message</th>\n",
42
+ " </tr>\n",
43
+ " </thead>\n",
44
+ " <tbody>\n",
45
+ " <tr>\n",
46
+ " <th>0</th>\n",
47
+ " <td>ham</td>\n",
48
+ " <td>Go until jurong point, crazy.. Available only ...</td>\n",
49
+ " </tr>\n",
50
+ " <tr>\n",
51
+ " <th>1</th>\n",
52
+ " <td>ham</td>\n",
53
+ " <td>Ok lar... Joking wif u oni...</td>\n",
54
+ " </tr>\n",
55
+ " <tr>\n",
56
+ " <th>2</th>\n",
57
+ " <td>spam</td>\n",
58
+ " <td>Free entry in 2 a wkly comp to win FA Cup fina...</td>\n",
59
+ " </tr>\n",
60
+ " <tr>\n",
61
+ " <th>3</th>\n",
62
+ " <td>ham</td>\n",
63
+ " <td>U dun say so early hor... U c already then say...</td>\n",
64
+ " </tr>\n",
65
+ " <tr>\n",
66
+ " <th>4</th>\n",
67
+ " <td>ham</td>\n",
68
+ " <td>Nah I don't think he goes to usf, he lives aro...</td>\n",
69
+ " </tr>\n",
70
+ " </tbody>\n",
71
+ "</table>\n",
72
+ "</div>"
73
+ ],
74
+ "text/plain": [
75
+ " Category Message\n",
76
+ "0 ham Go until jurong point, crazy.. Available only ...\n",
77
+ "1 ham Ok lar... Joking wif u oni...\n",
78
+ "2 spam Free entry in 2 a wkly comp to win FA Cup fina...\n",
79
+ "3 ham U dun say so early hor... U c already then say...\n",
80
+ "4 ham Nah I don't think he goes to usf, he lives aro..."
81
+ ]
82
+ },
83
+ "execution_count": 2,
84
+ "metadata": {},
85
+ "output_type": "execute_result"
86
+ }
87
+ ],
88
+ "source": [
89
+ "# importing data to work on :\n",
90
+ "dataset = pd.read_csv(\"spam.csv\")\n",
91
+ "dataset.head()"
92
+ ]
93
+ },
94
+ {
95
+ "cell_type": "code",
96
+ "execution_count": 3,
97
+ "metadata": {},
98
+ "outputs": [
99
+ {
100
+ "data": {
101
+ "text/plain": [
102
+ "(5572, 2)"
103
+ ]
104
+ },
105
+ "execution_count": 3,
106
+ "metadata": {},
107
+ "output_type": "execute_result"
108
+ }
109
+ ],
110
+ "source": [
111
+ "dataset.shape"
112
+ ]
113
+ },
114
+ {
115
+ "cell_type": "code",
116
+ "execution_count": 4,
117
+ "metadata": {},
118
+ "outputs": [
119
+ {
120
+ "data": {
121
+ "text/plain": [
122
+ "Index(['Category', 'Message'], dtype='object')"
123
+ ]
124
+ },
125
+ "execution_count": 4,
126
+ "metadata": {},
127
+ "output_type": "execute_result"
128
+ }
129
+ ],
130
+ "source": [
131
+ "dataset.columns"
132
+ ]
133
+ },
134
+ {
135
+ "cell_type": "code",
136
+ "execution_count": 5,
137
+ "metadata": {},
138
+ "outputs": [
139
+ {
140
+ "name": "stdout",
141
+ "output_type": "stream",
142
+ "text": [
143
+ "<class 'pandas.core.frame.DataFrame'>\n",
144
+ "RangeIndex: 5572 entries, 0 to 5571\n",
145
+ "Data columns (total 2 columns):\n",
146
+ " # Column Non-Null Count Dtype \n",
147
+ "--- ------ -------------- ----- \n",
148
+ " 0 Category 5572 non-null object\n",
149
+ " 1 Message 5572 non-null object\n",
150
+ "dtypes: object(2)\n",
151
+ "memory usage: 87.2+ KB\n",
152
+ "None\n"
153
+ ]
154
+ },
155
+ {
156
+ "data": {
157
+ "text/plain": [
158
+ "Category 0\n",
159
+ "Message 0\n",
160
+ "dtype: int64"
161
+ ]
162
+ },
163
+ "execution_count": 5,
164
+ "metadata": {},
165
+ "output_type": "execute_result"
166
+ }
167
+ ],
168
+ "source": [
169
+ "# to check if there are NULL values in our dataset :\n",
170
+ "print(dataset.info())\n",
171
+ "dataset.isna().sum()"
172
+ ]
173
+ },
174
+ {
175
+ "cell_type": "code",
176
+ "execution_count": 6,
177
+ "metadata": {},
178
+ "outputs": [
179
+ {
180
+ "data": {
181
+ "text/plain": [
182
+ "Category 2\n",
183
+ "Message 5157\n",
184
+ "dtype: int64"
185
+ ]
186
+ },
187
+ "execution_count": 6,
188
+ "metadata": {},
189
+ "output_type": "execute_result"
190
+ }
191
+ ],
192
+ "source": [
193
+ "# to check if there are values other than spam and ham :\n",
194
+ "dataset.nunique()"
195
+ ]
196
+ },
197
+ {
198
+ "cell_type": "code",
199
+ "execution_count": 7,
200
+ "metadata": {},
201
+ "outputs": [
202
+ {
203
+ "data": {
204
+ "text/html": [
205
+ "<div>\n",
206
+ "<style scoped>\n",
207
+ " .dataframe tbody tr th:only-of-type {\n",
208
+ " vertical-align: middle;\n",
209
+ " }\n",
210
+ "\n",
211
+ " .dataframe tbody tr th {\n",
212
+ " vertical-align: top;\n",
213
+ " }\n",
214
+ "\n",
215
+ " .dataframe thead th {\n",
216
+ " text-align: right;\n",
217
+ " }\n",
218
+ "</style>\n",
219
+ "<table border=\"1\" class=\"dataframe\">\n",
220
+ " <thead>\n",
221
+ " <tr style=\"text-align: right;\">\n",
222
+ " <th></th>\n",
223
+ " <th>Category</th>\n",
224
+ " <th>Message</th>\n",
225
+ " <th>Spam</th>\n",
226
+ " </tr>\n",
227
+ " </thead>\n",
228
+ " <tbody>\n",
229
+ " <tr>\n",
230
+ " <th>0</th>\n",
231
+ " <td>ham</td>\n",
232
+ " <td>Go until jurong point, crazy.. Available only ...</td>\n",
233
+ " <td>0</td>\n",
234
+ " </tr>\n",
235
+ " <tr>\n",
236
+ " <th>1</th>\n",
237
+ " <td>ham</td>\n",
238
+ " <td>Ok lar... Joking wif u oni...</td>\n",
239
+ " <td>0</td>\n",
240
+ " </tr>\n",
241
+ " <tr>\n",
242
+ " <th>2</th>\n",
243
+ " <td>spam</td>\n",
244
+ " <td>Free entry in 2 a wkly comp to win FA Cup fina...</td>\n",
245
+ " <td>1</td>\n",
246
+ " </tr>\n",
247
+ " <tr>\n",
248
+ " <th>3</th>\n",
249
+ " <td>ham</td>\n",
250
+ " <td>U dun say so early hor... U c already then say...</td>\n",
251
+ " <td>0</td>\n",
252
+ " </tr>\n",
253
+ " <tr>\n",
254
+ " <th>4</th>\n",
255
+ " <td>ham</td>\n",
256
+ " <td>Nah I don't think he goes to usf, he lives aro...</td>\n",
257
+ " <td>0</td>\n",
258
+ " </tr>\n",
259
+ " </tbody>\n",
260
+ "</table>\n",
261
+ "</div>"
262
+ ],
263
+ "text/plain": [
264
+ " Category Message Spam\n",
265
+ "0 ham Go until jurong point, crazy.. Available only ... 0\n",
266
+ "1 ham Ok lar... Joking wif u oni... 0\n",
267
+ "2 spam Free entry in 2 a wkly comp to win FA Cup fina... 1\n",
268
+ "3 ham U dun say so early hor... U c already then say... 0\n",
269
+ "4 ham Nah I don't think he goes to usf, he lives aro... 0"
270
+ ]
271
+ },
272
+ "execution_count": 7,
273
+ "metadata": {},
274
+ "output_type": "execute_result"
275
+ }
276
+ ],
277
+ "source": [
278
+ "# Encoding Categories into 0 and 1 :\n",
279
+ "dataset[\"Spam\"] = [1 if i==\"spam\" else 0 for i in dataset[\"Category\"]]\n",
280
+ "dataset.head()"
281
+ ]
282
+ },
283
+ {
284
+ "cell_type": "code",
285
+ "execution_count": 8,
286
+ "metadata": {},
287
+ "outputs": [],
288
+ "source": [
289
+ "X = dataset[\"Message\"]\n",
290
+ "y = dataset.Spam"
291
+ ]
292
+ },
293
+ {
294
+ "attachments": {},
295
+ "cell_type": "markdown",
296
+ "metadata": {},
297
+ "source": [
298
+ "### Train-Test Split :"
299
+ ]
300
+ },
301
+ {
302
+ "cell_type": "code",
303
+ "execution_count": 9,
304
+ "metadata": {},
305
+ "outputs": [],
306
+ "source": [
307
+ "from sklearn.model_selection import train_test_split\n",
308
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=12)"
309
+ ]
310
+ },
311
+ {
312
+ "cell_type": "code",
313
+ "execution_count": 10,
314
+ "metadata": {},
315
+ "outputs": [
316
+ {
317
+ "data": {
318
+ "text/plain": [
319
+ "((4457,), (1115,), (4457,), (1115,))"
320
+ ]
321
+ },
322
+ "execution_count": 10,
323
+ "metadata": {},
324
+ "output_type": "execute_result"
325
+ }
326
+ ],
327
+ "source": [
328
+ "X_train.shape, X_test.shape, y_train.shape, y_test.shape"
329
+ ]
330
+ },
331
+ {
332
+ "cell_type": "code",
333
+ "execution_count": 11,
334
+ "metadata": {},
335
+ "outputs": [],
336
+ "source": [
337
+ "# Importing CountVectorizer which converta the text into matrics :\n",
338
+ "from sklearn.feature_extraction.text import CountVectorizer"
339
+ ]
340
+ },
341
+ {
342
+ "cell_type": "code",
343
+ "execution_count": 12,
344
+ "metadata": {},
345
+ "outputs": [],
346
+ "source": [
347
+ "# Importing Different classifiers to compare :\n",
348
+ "# from sklearn.linear_model import LogisticRegression\n",
349
+ "# from sklearn.ensemble import RandomForestClassifier\n",
350
+ "from sklearn.naive_bayes import MultinomialNB # βœ”οΈβœ”οΈ Works well with this type of problems, when data is discrete."
351
+ ]
352
+ },
353
+ {
354
+ "cell_type": "code",
355
+ "execution_count": 13,
356
+ "metadata": {},
357
+ "outputs": [],
358
+ "source": [
359
+ "# Creating a pipeline :\n",
360
+ "\n",
361
+ "from sklearn.pipeline import Pipeline\n",
362
+ "clf=Pipeline([\n",
363
+ " ('vectorizer',CountVectorizer()),\n",
364
+ " ('nb',MultinomialNB())\n",
365
+ "])"
366
+ ]
367
+ },
368
+ {
369
+ "cell_type": "code",
370
+ "execution_count": 14,
371
+ "metadata": {},
372
+ "outputs": [
373
+ {
374
+ "data": {
375
+ "text/html": [
376
+ "<style>#sk-container-id-1 {color: black;background-color: white;}#sk-container-id-1 pre{padding: 0;}#sk-container-id-1 div.sk-toggleable {background-color: white;}#sk-container-id-1 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-1 label.sk-toggleable__label-arrow:before {content: \"β–Έ\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-1 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-1 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-1 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"β–Ύ\";}#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-1 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-1 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-1 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-1 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-1 div.sk-item {position: relative;z-index: 1;}#sk-container-id-1 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-1 div.sk-item::before, #sk-container-id-1 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-1 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-1 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-1 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-1 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-1 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-1 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-1 div.sk-label-container {text-align: center;}#sk-container-id-1 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-1 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>Pipeline(steps=[(&#x27;vectorizer&#x27;, CountVectorizer()), (&#x27;nb&#x27;, MultinomialNB())])</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item sk-dashed-wrapped\"><div class=\"sk-label-container\"><div class=\"sk-label sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" ><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">Pipeline</label><div class=\"sk-toggleable__content\"><pre>Pipeline(steps=[(&#x27;vectorizer&#x27;, CountVectorizer()), (&#x27;nb&#x27;, MultinomialNB())])</pre></div></div></div><div class=\"sk-serial\"><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-2\" type=\"checkbox\" ><label for=\"sk-estimator-id-2\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">CountVectorizer</label><div class=\"sk-toggleable__content\"><pre>CountVectorizer()</pre></div></div></div><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-3\" type=\"checkbox\" ><label for=\"sk-estimator-id-3\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">MultinomialNB</label><div class=\"sk-toggleable__content\"><pre>MultinomialNB()</pre></div></div></div></div></div></div></div>"
377
+ ],
378
+ "text/plain": [
379
+ "Pipeline(steps=[('vectorizer', CountVectorizer()), ('nb', MultinomialNB())])"
380
+ ]
381
+ },
382
+ "execution_count": 14,
383
+ "metadata": {},
384
+ "output_type": "execute_result"
385
+ }
386
+ ],
387
+ "source": [
388
+ "# Fitting Data :\n",
389
+ "\n",
390
+ "clf.fit(X_train, y_train)"
391
+ ]
392
+ },
393
+ {
394
+ "cell_type": "code",
395
+ "execution_count": 15,
396
+ "metadata": {},
397
+ "outputs": [
398
+ {
399
+ "data": {
400
+ "text/plain": [
401
+ "0.97847533632287"
402
+ ]
403
+ },
404
+ "execution_count": 15,
405
+ "metadata": {},
406
+ "output_type": "execute_result"
407
+ }
408
+ ],
409
+ "source": [
410
+ "# Accuracy check :\n",
411
+ "clf.score(X_test,y_test)"
412
+ ]
413
+ },
414
+ {
415
+ "attachments": {},
416
+ "cell_type": "markdown",
417
+ "metadata": {},
418
+ "source": [
419
+ "### *TESTING :*"
420
+ ]
421
+ },
422
+ {
423
+ "cell_type": "code",
424
+ "execution_count": 19,
425
+ "metadata": {},
426
+ "outputs": [
427
+ {
428
+ "name": "stdout",
429
+ "output_type": "stream",
430
+ "text": [
431
+ "Spam!\n",
432
+ "Good to go πŸ‘\n",
433
+ "Good to go πŸ‘\n",
434
+ "Spam!\n",
435
+ "Spam!\n",
436
+ "Good to go πŸ‘\n"
437
+ ]
438
+ }
439
+ ],
440
+ "source": [
441
+ "msg = [\"Thanks for your subscription to Ringtone - 'Shila ki jawaani', your mobile will be charged RS.5/month Please confirm by replying YES or NO. If you reply NO you will not be charged\",\n",
442
+ "\"Oops, I'll let you know when my roommate's done\",\n",
443
+ "\"hello, i am akshat, are you free today?\",\n",
444
+ "\"free free free, get free coins, just download this xyz app (100 RS. Instant Cash)\",\n",
445
+ "\"subscribe to get unlimited benefits\",\n",
446
+ "\" i want some money, can you plz send me? \"]\n",
447
+ "\n",
448
+ "# True Values : 1 0 0 1 1 0\n",
449
+ "# i.e. - Spam, Ham, Ham, Spam, Spam, Ham\n",
450
+ "\n",
451
+ "y_pred = clf.predict(msg) \n",
452
+ "for i in y_pred:\n",
453
+ " if i==0:\n",
454
+ " print(\"Good to go πŸ‘\")\n",
455
+ " else:\n",
456
+ " print(\"Spam!\")"
457
+ ]
458
+ },
459
+ {
460
+ "attachments": {},
461
+ "cell_type": "markdown",
462
+ "metadata": {},
463
+ "source": [
464
+ "#### *Saving this as a model using Joblib :*"
465
+ ]
466
+ },
467
+ {
468
+ "cell_type": "code",
469
+ "execution_count": 17,
470
+ "metadata": {},
471
+ "outputs": [],
472
+ "source": [
473
+ "# from joblib import dump\n",
474
+ "# dump(clf, 'Classifier.joblib')"
475
+ ]
476
+ }
477
+ ],
478
+ "metadata": {
479
+ "kernelspec": {
480
+ "display_name": "Python 3",
481
+ "language": "python",
482
+ "name": "python3"
483
+ },
484
+ "language_info": {
485
+ "codemirror_mode": {
486
+ "name": "ipython",
487
+ "version": 3
488
+ },
489
+ "file_extension": ".py",
490
+ "mimetype": "text/x-python",
491
+ "name": "python",
492
+ "nbconvert_exporter": "python",
493
+ "pygments_lexer": "ipython3",
494
+ "version": "3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]"
495
+ },
496
+ "orig_nbformat": 4,
497
+ "vscode": {
498
+ "interpreter": {
499
+ "hash": "706654849fe4d07e215a38f448ee8e5d780794e2be3793e11d37ab3169b306ae"
500
+ }
501
+ }
502
+ },
503
+ "nbformat": 4,
504
+ "nbformat_minor": 2
505
+ }
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ joblib==1.2.0
2
+ gradio==3.17.0
3
+ scikit-learn==1.2.1
4
+ pandas==1.5.0
spam.csv ADDED
The diff for this file is too large to render. See raw diff