From 40e852df97e1a956196d085a63fddea91c6d9b7a Mon Sep 17 00:00:00 2001
From: Mariam Zakaria <123750992+mariam851@users.noreply.github.com>
Date: Fri, 2 Jan 2026 10:55:01 +0200
Subject: [PATCH] Fix: resolve turicreate dependency for Windows 10 (Issue #1)
---
.../Coding_naive_Bayes.ipynb | 149 +++++++++++++-----
1 file changed, 109 insertions(+), 40 deletions(-)
diff --git a/Chapter_08_Naive_Bayes/Coding_naive_Bayes.ipynb b/Chapter_08_Naive_Bayes/Coding_naive_Bayes.ipynb
index 763b2c5..71725c0 100644
--- a/Chapter_08_Naive_Bayes/Coding_naive_Bayes.ipynb
+++ b/Chapter_08_Naive_Bayes/Coding_naive_Bayes.ipynb
@@ -146,9 +146,78 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " text | \n",
+ " spam | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " Subject: naturally irresistible your corporate... | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " Subject: the stock trading gunslinger fanny i... | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " Subject: unbelievable new homes made easy im ... | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " Subject: 4 color printing special request add... | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " Subject: do not have money , get software cds ... | \n",
+ " 1 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " text spam\n",
+ "0 Subject: naturally irresistible your corporate... 1\n",
+ "1 Subject: the stock trading gunslinger fanny i... 1\n",
+ "2 Subject: unbelievable new homes made easy im ... 1\n",
+ "3 Subject: 4 color printing special request add... 1\n",
+ "4 Subject: do not have money , get software cds ... 1"
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# IMPORTANT: ONLY RUN THIS CELL IF YOU ARE WORKING ON A COLAB \n",
"\n",
@@ -159,7 +228,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@@ -172,7 +241,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 5,
"metadata": {},
"outputs": [
{
@@ -206,61 +275,61 @@
" 0 | \n",
" Subject: naturally irresistible your corporate... | \n",
" 1 | \n",
- " [., clear, original, our, :, distinctive, busi... | \n",
+ " [more, information, clear, -, shouldn, _, iead... | \n",
" \n",
" \n",
" | 1 | \n",
" Subject: the stock trading gunslinger fanny i... | \n",
" 1 | \n",
- " [perspicuous, huzzah, inflexible, continuant, ... | \n",
+ " [edt, optima, continuant, kansas, tight, hawth... | \n",
"
\n",
" \n",
" | 2 | \n",
" Subject: unbelievable new homes made easy im ... | \n",
" 1 | \n",
- " [454, ., to, 3, wanting, we, you, loan, our, p... | \n",
+ " [loan, new, to, 454, your, you, extended, unco... | \n",
"
\n",
" \n",
" | 3 | \n",
" Subject: 4 color printing special request add... | \n",
" 1 | \n",
- " [., an, printing, goldengraphix, our, e, irwin... | \n",
+ " [special, canyon, goldengraphix, ca, e, inform... | \n",
"
\n",
" \n",
" | 4 | \n",
" Subject: do not have money , get software cds ... | \n",
" 1 | \n",
- " [., it, cds, ?, to, compatibility, along, ', d... | \n",
+ " [to, ?, are, death, marriage, here, old, !, .,... | \n",
"
\n",
" \n",
" | 5 | \n",
" Subject: great nnews hello , welcome to medzo... | \n",
" 1 | \n",
- " [introduce, ., 75, worldwide, total, op, v, to... | \n",
+ " [total, to, andmanyother, nice, miilion, are, ... | \n",
"
\n",
" \n",
" | 6 | \n",
" Subject: here ' s a hot play in motion homela... | \n",
" 1 | \n",
- " [transportation, innovative, *, adverse, excha... | \n",
+ " [terror, more, involve, press, constant, proje... | \n",
"
\n",
" \n",
" | 7 | \n",
" Subject: save your money buy getting this thin... | \n",
" 1 | \n",
- " [imagine, it, ., has, viagra, iasts, ?, buy, t... | \n",
+ " [errrectlon, save, to, ?, start, what, man, ca... | \n",
"
\n",
" \n",
" | 8 | \n",
" Subject: undeliverable : home based business f... | \n",
" 1 | \n",
- " [75, ., original, :, business, undeliverable, ... | \n",
+ " [2001, undeliverable, 2002, -, 8, recognized, ... | \n",
"
\n",
" \n",
" | 9 | \n",
" Subject: save your money buy getting this thin... | \n",
" 1 | \n",
- " [imagine, it, ., has, viagra, ?, buy, to, 10, ... | \n",
+ " [errrectlon, save, to, ?, start, what, man, ca... | \n",
"
\n",
" \n",
"\n",
@@ -280,19 +349,19 @@
"9 Subject: save your money buy getting this thin... 1 \n",
"\n",
" words \n",
- "0 [., clear, original, our, :, distinctive, busi... \n",
- "1 [perspicuous, huzzah, inflexible, continuant, ... \n",
- "2 [454, ., to, 3, wanting, we, you, loan, our, p... \n",
- "3 [., an, printing, goldengraphix, our, e, irwin... \n",
- "4 [., it, cds, ?, to, compatibility, along, ', d... \n",
- "5 [introduce, ., 75, worldwide, total, op, v, to... \n",
- "6 [transportation, innovative, *, adverse, excha... \n",
- "7 [imagine, it, ., has, viagra, iasts, ?, buy, t... \n",
- "8 [75, ., original, :, business, undeliverable, ... \n",
- "9 [imagine, it, ., has, viagra, ?, buy, to, 10, ... "
+ "0 [more, information, clear, -, shouldn, _, iead... \n",
+ "1 [edt, optima, continuant, kansas, tight, hawth... \n",
+ "2 [loan, new, to, 454, your, you, extended, unco... \n",
+ "3 [special, canyon, goldengraphix, ca, e, inform... \n",
+ "4 [to, ?, are, death, marriage, here, old, !, .,... \n",
+ "5 [total, to, andmanyother, nice, miilion, are, ... \n",
+ "6 [terror, more, involve, press, constant, proje... \n",
+ "7 [errrectlon, save, to, ?, start, what, man, ca... \n",
+ "8 [2001, undeliverable, 2002, -, 8, recognized, ... \n",
+ "9 [errrectlon, save, to, ?, start, what, man, ca... "
]
},
- "execution_count": 4,
+ "execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@@ -303,7 +372,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 6,
"metadata": {},
"outputs": [
{
@@ -340,7 +409,7 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@@ -360,7 +429,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 8,
"metadata": {},
"outputs": [
{
@@ -369,7 +438,7 @@
"{'spam': 9, 'ham': 1}"
]
},
- "execution_count": 7,
+ "execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@@ -380,7 +449,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 9,
"metadata": {},
"outputs": [
{
@@ -389,7 +458,7 @@
"{'spam': 39, 'ham': 42}"
]
},
- "execution_count": 8,
+ "execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
@@ -407,7 +476,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@@ -420,7 +489,7 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 11,
"metadata": {},
"outputs": [
{
@@ -429,7 +498,7 @@
"0.9"
]
},
- "execution_count": 10,
+ "execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
@@ -440,7 +509,7 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 12,
"metadata": {},
"outputs": [
{
@@ -449,7 +518,7 @@
"0.48148148148148145"
]
},
- "execution_count": 11,
+ "execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@@ -460,7 +529,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
@@ -476,8 +545,8 @@
" if word in model:\n",
" spams.append(model[word]['spam']/num_spam*total)\n",
" hams.append(model[word]['ham']/num_ham*total)\n",
- " prod_spams = np.compat.long(np.prod(spams)*num_spam)\n",
- " prod_hams = np.compat.long(np.prod(hams)*num_ham)\n",
+ " prod_spams = np.prod(spams, dtype=np.float64) * num_spam\n",
+ " prod_hams = np.prod(hams, dtype=np.float64) * num_ham\n",
" return prod_spams/(prod_spams + prod_hams)"
]
},
@@ -665,7 +734,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.6"
+ "version": "3.12.5"
}
},
"nbformat": 4,