summaryrefslogtreecommitdiff
path: root/docs/posts/2019-12-22-Fake-News-Detector.html
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2024-04-03 09:36:58 -0600
committerGitHub <noreply@github.com>2024-04-03 09:36:58 -0600
commit84ad5d8360fb0683f12f9bae8f29d6b36964dde3 (patch)
tree64bb1d9675ac3d6a3604d512311a754b08c53be2 /docs/posts/2019-12-22-Fake-News-Detector.html
parent0e4b5fcc164cd8432678bdffd58b8c123acee186 (diff)
parentd00b2da99ef2d498074a6e4eb8d80995cdfc4476 (diff)
Merge branch 'vanilla-ssg' into dependabot/pip/jinja2-3.1.3
Diffstat (limited to 'docs/posts/2019-12-22-Fake-News-Detector.html')
-rw-r--r--docs/posts/2019-12-22-Fake-News-Detector.html93
1 files changed, 63 insertions, 30 deletions
diff --git a/docs/posts/2019-12-22-Fake-News-Detector.html b/docs/posts/2019-12-22-Fake-News-Detector.html
index 6979c19..3a7a843 100644
--- a/docs/posts/2019-12-22-Fake-News-Detector.html
+++ b/docs/posts/2019-12-22-Fake-News-Detector.html
@@ -2,14 +2,27 @@
<html lang="en">
<head>
- <link rel="stylesheet" href="https://unpkg.com/latex.css/style.min.css" />
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
+ <meta name="theme-color" content="#6a9fb5">
+
+ <title>Building a Fake News Detector with Turicreate</title>
+
+ <!--
+ <link rel="stylesheet" href="https://unpkg.com/latex.css/style.min.css" />
+ -->
+
+ <link rel="stylesheet" href="/assets/c-hyde.css" />
+
+ <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface">
+
<link rel="stylesheet" href="/assets/main.css" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Building a Fake News Detector with Turicreate</title>
<meta name="og:site_name" content="Navan Chauhan" />
<link rel="canonical" href="https://web.navan.dev/posts/2019-12-22-Fake-News-Detector.html" />
- <meta name="twitter:url" content="https://web.navan.dev/posts/2019-12-22-Fake-News-Detector.html />
+ <meta name="twitter:url" content="https://web.navan.dev/posts/2019-12-22-Fake-News-Detector.html" />
<meta name="og:url" content="https://web.navan.dev/posts/2019-12-22-Fake-News-Detector.html" />
<meta name="twitter:title" content="Building a Fake News Detector with Turicreate" />
<meta name="og:title" content="Building a Fake News Detector with Turicreate" />
@@ -26,37 +39,56 @@
<script data-goatcounter="https://navanchauhan.goatcounter.com/count"
async src="//gc.zgo.at/count.js"></script>
<script defer data-domain="web.navan.dev" src="https://plausible.io/js/plausible.js"></script>
- <link rel="manifest" href="manifest.json" />
+ <link rel="manifest" href="/manifest.json" />
</head>
-<body>
- <center><nav style="display: block;">
-|
-<a href="/">home</a> |
-<a href="/about/">about/links</a> |
-<a href="/posts/">posts</a> |
-<!--<a href="/publications/">publications</a> |-->
-<!--<a href="/repo/">iOS repo</a> |-->
-<a href="/feed.rss">RSS Feed</a> |
-</nav>
-</center>
-
-<main>
+<body class="theme-base-0d">
+ <div class="sidebar">
+ <div class="container sidebar-sticky">
+ <div class="sidebar-about">
+ <h1><a href="/">Navan</a></h1>
+ <p class="lead" id="random-lead">Alea iacta est.</p>
+ </div>
+
+ <ul class="sidebar-nav">
+ <li><a class="sidebar-nav-item" href="/about/">about/links</a></li>
+ <li><a class="sidebar-nav-item" href="/posts/">posts</a></li>
+ <li><a class="sidebar-nav-item" href="/3D-Designs/">3D designs</a></li>
+ <li><a class="sidebar-nav-item" href="/feed.rss">RSS Feed</a></li>
+ <li><a class="sidebar-nav-item" href="/colophon/">colophon</a></li>
+ </ul>
+ <div class="copyright"><p>&copy; 2019-2024. Navan Chauhan <br> <a href="/feed.rss">RSS</a></p></div>
+ </div>
+</div>
- <h1>Building a Fake News Detector with Turicreate</h1>
+<script>
+let phrases = [
+ "Something Funny", "Veni, vidi, vici", "Alea iacta est", "In vino veritas", "Acta, non verba", "Castigat ridendo mores",
+ "Cui bono?", "Memento vivere", "अहम् ब्रह्मास्मि", "अनुगच्छतु प्रवाहं", "चरन्मार्गान्विजानाति", "coq de cheval", "我愛啤酒"
+ ];
+
+let new_phrase = phrases[Math.floor(Math.random()*phrases.length)];
+
+let lead = document.getElementById("random-lead");
+lead.innerText = new_phrase;
+</script>
+ <div class="content container">
+
+ <div class="post">
+ <h1 id="building-a-fake-news-detector-with-turicreate">Building a Fake News Detector with Turicreate</h1>
<p><strong>In this tutorial we will build a fake news detecting app from scratch, using Turicreate for the machine learning model and SwiftUI for building the app</strong></p>
<p>Note: These commands are written as if you are running a jupyter notebook.</p>
-<h2>Building the Machine Learning Model</h2>
+<h2 id="building-the-machine-learning-model">Building the Machine Learning Model</h2>
-<h3>Data Gathering</h3>
+<h3 id="data-gathering">Data Gathering</h3>
<p>To build a classifier, you need a lot of data. George McIntire (GH: @joolsa) has created a wonderful dataset containing the headline, body and whether it is fake or real.
Whenever you are looking for a dataset, always try searching on Kaggle and GitHub before you start building your own</p>
-<h3>Dependencies</h3>
+<h3 id="dependencies">Dependencies</h3>
<p>I used a Google Colab instance for training my model. If you also plan on using Google Colab then I recommend choosing a GPU Instance (It is Free)
This allows you to train the model on the GPU. Turicreate is built on top of Apache's MXNet Framework, for us to use GPU we need to install
@@ -71,7 +103,7 @@ a CUDA compatible MXNet package.</p>
<p>If you do not wish to train on GPU or are running it on your computer, you can ignore the last two lines</p>
-<h3>Downloading the Dataset</h3>
+<h3 id="downloading-the-dataset">Downloading the Dataset</h3>
<div class="codehilite">
<pre><span></span><code><span class="nt">!wget</span><span class="na"> -q &quot;https</span><span class="p">:</span><span class="nc">//github.com/joolsa/fake_real_news_dataset/raw/master/fake_or_real_news.csv.zip&quot;</span>
@@ -79,7 +111,7 @@ a CUDA compatible MXNet package.</p>
</code></pre>
</div>
-<h3>Model Creation</h3>
+<h3 id="model-creation">Model Creation</h3>
<div class="codehilite">
<pre><span></span><code><span class="kn">import</span> <span class="nn">turicreate</span> <span class="k">as</span> <span class="nn">tc</span>
@@ -99,14 +131,14 @@ a CUDA compatible MXNet package.</p>
</code></pre>
</div>
-<h4>Splitting Dataset</h4>
+<h4 id="splitting-dataset">Splitting Dataset</h4>
<div class="codehilite">
<pre><span></span><code><span class="n">train</span><span class="p">,</span> <span class="n">test</span> <span class="o">=</span> <span class="n">dataSFrame</span><span class="o">.</span><span class="n">random_split</span><span class="p">(</span><span class="mf">.9</span><span class="p">)</span>
</code></pre>
</div>
-<h4>Training</h4>
+<h4 id="training">Training</h4>
<div class="codehilite">
<pre><span></span><code><span class="n">model</span> <span class="o">=</span> <span class="n">tc</span><span class="o">.</span><span class="n">text_classifier</span><span class="o">.</span><span class="n">create</span><span class="p">(</span>
@@ -131,7 +163,7 @@ a CUDA compatible MXNet package.</p>
</code></pre>
</div>
-<h3>Testing the Model</h3>
+<h3 id="testing-the-model">Testing the Model</h3>
<div class="codehilite">
<pre><span></span><code><span class="n">est_predictions</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">predict</span><span class="p">(</span><span class="n">test</span><span class="p">)</span>
@@ -164,7 +196,7 @@ a CUDA compatible MXNet package.</p>
</code></pre>
</div>
-<h3>Exporting the Model</h3>
+<h3 id="exporting-the-model">Exporting the Model</h3>
<div class="codehilite">
<pre><span></span><code><span class="n">model_name</span> <span class="o">=</span> <span class="s1">&#39;FakeNews&#39;</span>
@@ -177,9 +209,9 @@ a CUDA compatible MXNet package.</p>
<p><a rel="noopener" target="_blank" href="https://colab.research.google.com/drive/1onMXGkhA__X2aOFdsoVL-6HQBsWQhOP4">Link to Colab Notebook</a></p>
-<h2>Building the App using SwiftUI</h2>
+<h2 id="building-the-app-using-swiftui">Building the App using SwiftUI</h2>
-<h3>Initial Setup</h3>
+<h3 id="initial-setup">Initial Setup</h3>
<p>First we create a single view app (make sure you check the use SwiftUI button)</p>
@@ -307,14 +339,15 @@ DescriptionThe bag-of-words model is a simplifying representation used in NLP, i
</code></pre>
</div>
+ </div>
<blockquote>If you have scrolled this far, consider subscribing to my mailing list <a href="https://listmonk.navan.dev/subscription/form">here.</a> You can subscribe to either a specific type of post you are interested in, or subscribe to everything with the "Everything" list.</blockquote>
<script data-isso="https://comments.navan.dev/"
src="https://comments.navan.dev/js/embed.min.js"></script>
<section id="isso-thread">
<noscript>Javascript needs to be activated to view comments.</noscript>
</section>
-</main>
+ </div>
<script src="assets/manup.min.js"></script>
<script src="/pwabuilder-sw-register.js"></script>
</body>