<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bjørn-Jostein Singstad on Medium]]></title>
        <description><![CDATA[Stories by Bjørn-Jostein Singstad on Medium]]></description>
        <link>https://medium.com/@bjorn_sing?source=rss-f656cf6e123b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fnOPU_5kw-KRwVrT2OXplA.jpeg</url>
            <title>Stories by Bjørn-Jostein Singstad on Medium</title>
            <link>https://medium.com/@bjorn_sing?source=rss-f656cf6e123b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 23:27:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bjorn_sing/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Understanding the Bias-Variance Tradeoff in Machine Learning]]></title>
            <link>https://medium.com/@bjorn_sing/understanding-the-bias-variance-tradeoff-in-machine-learning-7dcba2ce28a8?source=rss-f656cf6e123b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dcba2ce28a8</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[training]]></category>
            <category><![CDATA[bias-in-ai]]></category>
            <category><![CDATA[variance]]></category>
            <category><![CDATA[bias-variance-tradeoff]]></category>
            <dc:creator><![CDATA[Bjørn-Jostein Singstad]]></dc:creator>
            <pubDate>Thu, 29 May 2025 18:12:54 GMT</pubDate>
            <atom:updated>2025-05-29T18:12:54.332Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Why your model isn’t performing well — and how to fix it</em></h4><p>One of the most fundamental concepts in machine learning is the <strong>bias-variance tradeoff</strong>. It’s a powerful lens through which we can understand model performance and the reasons behind prediction errors. Whether you’re building your first linear regression model or fine-tuning a neural network, grappling with this tradeoff is key to success.</p><p>In this post, we’ll explore what bias and variance mean, how they contribute to a model’s total error, and how to balance them to build better models.</p><h3>📉 What is the Bias-Variance Tradeoff?</h3><p>At its core, the <strong>bias-variance tradeoff</strong> describes the balance between two sources of error that affect a model’s ability to generalize to unseen data:</p><ul><li><strong>Bias</strong>: Error from incorrect assumptions in the learning algorithm.</li><li><strong>Variance</strong>: Error from sensitivity to small fluctuations in the training set.</li></ul><p>A model with <strong>high bias</strong> pays too little attention to the training data and oversimplifies the model — this is known as <strong>underfitting</strong>.<br>A model with <strong>high variance</strong> pays too much attention to the training data and captures noise — this is known as <strong>overfitting</strong>.</p><p>The goal is to find a sweet spot where <strong>both bias and variance are low</strong>, allowing the model to perform well on both training and unseen data.</p><h3>📊 Decomposing Prediction Error</h3><p>Let’s break down the total prediction error into its three components:</p><p>Total Error=Bias²+Variance+Irreducible Error</p><ul><li><strong>Bias²</strong>: Error introduced by approximating a real-world problem with a simplified model.</li><li><strong>Variance</strong>: Error introduced by the model’s sensitivity to the training data.</li><li><strong>Irreducible Error</strong>: Noise in the data/problem that no model can learn.</li></ul><p>The <strong>irreducible error</strong> is out of our hands. What we can control is the tradeoff between <strong>bias</strong> and <strong>variance</strong>.</p><h3>🤹‍♂️ Real-World Analogy</h3><p>Imagine trying to hit a bullseye on a dartboard.</p><ul><li>A <strong>high-bias</strong> player always throws darts far from the bullseye in a consistent pattern — maybe always off to the right.</li><li>A <strong>high-variance</strong> player hits all over the place — some darts land close to the target, others far off, but there’s no consistency.</li></ul><p>We want a player (our model) who throws darts that land both <strong>close to each other</strong> (low variance) and <strong>close to the bullseye</strong> (low bias).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WUnlH3kko1PBeKm_0JEfQQ.png" /><figcaption>Bias-variance analogy using a dartboard</figcaption></figure><h3>🏗️ Bias vs. Variance in Model Complexity</h3><p>Typically:</p><ul><li><strong>Simple models</strong> (e.g., linear regression) tend to have <strong>high bias and low variance</strong>.</li><li><strong>Complex models</strong> (e.g., deep neural networks) tend to have <strong>low bias and high variance</strong>.</li></ul><p>Increasing model complexity reduces bias but increases variance, and vice versa.</p><p>Here’s a visual intuition:</p><pre>Model Complexity ----------------&gt;<br>Bias             ↑               ↓<br>Variance         ↓               ↑</pre><p>The trick is to stop increasing complexity <em>just before</em> the model starts to overfit.</p><h3>🔧 Diagnosing with Learning Curves</h3><p>One practical way to understand whether your model suffers from high bias or high variance is by plotting <strong>learning curves</strong> — graphs of training and validation error over increasing training set sizes.</p><ul><li><strong>High bias (underfitting)</strong>: Both training and validation errors are high and close together.</li><li><strong>High variance (overfitting)</strong>: Training error is low, but validation error is high.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cROQOnOS2yk9wrrt_Ni9wA.png" /><figcaption>A training curve showing a model going from underfitted to overfitted</figcaption></figure><p>By analyzing these curves, you can decide whether to:</p><ul><li>Increase model complexity (if high bias),</li><li>Add more training data or apply regularization (if high variance).</li></ul><h3>🧠 Techniques to Manage the Tradeoff</h3><p>Here are common strategies to manage the bias-variance tradeoff:</p><ul><li><strong>Regularization</strong> (like L1/L2) to reduce variance</li><li><strong>Cross-validation</strong> to detect overfitting</li><li><strong>Ensembles</strong> (e.g., random forests, bagging) to lower variance</li><li><strong>Data augmentation</strong> to increase effective dataset size</li></ul><h3>🧪 Practical Example</h3><p>Let’s say you’re using polynomial regression to model a relationship:</p><ul><li>A <strong>degree-1 polynomial (a straight line)</strong> underfits the data (high bias).</li><li>A <strong>degree-10 polynomial</strong> fits every data point (high variance).</li><li>A <strong>degree-3 polynomial</strong> might strike the right balance (sweet spot)</li></ul><p>Try training models of increasing complexity and monitor validation performance. This experimentation is how the tradeoff is usually addressed in practice.</p><h3>🧭 Final Thoughts</h3><p>The bias-variance tradeoff is not something you “solve” once. It’s an ongoing balancing act throughout a machine learning project.</p><p>When your model isn’t performing well, don’t just throw more data at it or try another algorithm. First, ask: <em>Is this a bias problem or a variance problem?</em><br> Then adjust accordingly.</p><p>Understanding this tradeoff isn’t just theory — it’s a practical compass that will guide you to better models.</p><h3>🧠 TL;DR</h3><ul><li>Bias = Error from simplifying assumptions (underfitting).</li><li>Variance = Error from sensitivity to training data (overfitting).</li><li>Good models balance both to minimize total error.</li><li>Use learning curves and model validation to detect and adjust.</li></ul><p><em>If you found this helpful, follow me for more explainers on machine learning, AI, and data science!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dcba2ce28a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Paying for QR Code Subscriptions — Use Canva for Free Instead]]></title>
            <link>https://medium.com/@bjorn_sing/stop-paying-for-qr-code-subscriptions-use-canva-for-free-instead-2049d07ddee5?source=rss-f656cf6e123b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2049d07ddee5</guid>
            <category><![CDATA[qr-code]]></category>
            <category><![CDATA[qrcodegenerator]]></category>
            <category><![CDATA[save-money]]></category>
            <category><![CDATA[hacks]]></category>
            <category><![CDATA[effectiveness]]></category>
            <dc:creator><![CDATA[Bjørn-Jostein Singstad]]></dc:creator>
            <pubDate>Thu, 29 May 2025 16:20:34 GMT</pubDate>
            <atom:updated>2025-05-29T16:20:34.587Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Stop Paying for QR Code Subscriptions — Use Canva for Free Instead</strong></h3><h4>Why You Shouldn’t Be Paying Monthly Fees for Something as Simple as a QR Code</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YwShJ-w-K7vo3EnIM6NPMQ.png" /><figcaption>Canva’s free QR code generator</figcaption></figure><p>In a world where nearly every online service is monetized through subscriptions, it’s easy to get caught in a web of recurring charges — especially when it comes to tools that <em>shouldn’t</em> cost you a dime. One prime example? QR code generators.</p><p>For something as simple as turning a link into a scannable square, it can cost up to 40 $ in monthly fees. Although certain advanced features might be useful for large companies, the average user or small business rarely needs all those extras. If you’re still paying for a QR code subscription, it’s time to rethink your strategy — and consider a tool you might already be using: <strong>Canva</strong>.</p><h3>The Hidden Costs of “Free” QR Code Generators</h3><p>Let’s start with the problem.</p><p>If you’ve ever googled “free QR code generator,” you’ve likely ended up on a site that looks helpful at first. You enter your link, generate a code, and boom — it works. But then you:</p><ul><li>Want to <strong>customize</strong> the color or shape? That’ll cost extra.</li><li>Need <strong>high-resolution exports</strong>? Upgrade to Pro.</li><li>Want to <strong>edit</strong> your QR code later or track scans? Time to pay up.</li><li>And the most annoying part — after 3 to 7 days the QR code stops working and you need a Pro subscription to get up and running again</li></ul><p>These platforms rely on locking you into subscriptions for ongoing access, even if your needs are minimal. The whole experience becomes an exhausting and unnecessary trap.</p><h3>Enter Canva: The Free Alternative You Probably Overlooked</h3><p>Canva has quietly become one of the most versatile tools in the online creative space. It’s known for everything from social media graphics to presentations — but few people realize it also includes a <strong>free QR code generator</strong> as part of its design platform.</p><p>Here’s why Canva is a better (and smarter) option:</p><h4>✅ 100% Free to Use</h4><p>You can generate as many QR codes as you like with your free Canva subscription without ever entering your credit card. No “7-day free trials.” No hidden downgrades.</p><h4>✅ Easy Customization</h4><p>You can design your QR code directly inside any project. Add your brand colors, logos, or even embed it into a flyer or business card — all with drag-and-drop ease.</p><h4>✅ No Gimmicks</h4><p>Once you generate a QR code in Canva, it’s yours. You can download it in high resolution, use it commercially, and never worry about it expiring or being “deactivated” if you don’t pay.</p><h4>✅ Everything in One Place</h4><p>Why bounce between a QR code tool? Canva lets you create, style, and export everything in one workflow — whether it’s for a poster, menu, product packaging, or presentation.</p><h3>How to Create a QR Code in Canva (In Less Than 2 Minutes)</h3><ol><li>Go to <a href="https://canva.me/qr-codes">https://canva.me/qr-codes</a></li><li>Select if you want to implement the QR code in an existing project or if you want to start a new design</li><li>Paste the URL you would like to associate with the QR code</li><li>Click “Generate QR Code.”</li><li>Drag and drop it anywhere into your design.</li><li>Download or print your project as needed.</li></ol><p>That’s it. No watermarks. No restrictions. No monthly fees.</p><figure><img alt="Making a QR code with Canva" src="https://cdn-images-1.medium.com/max/1024/1*5IIEM_3Ga2783xkdWI6IKA.png" /><figcaption>Making a QR code with Canva in a blank project</figcaption></figure><h3>The Bottom Line</h3><p>If you’re a small business owner, marketer, educator, or creator, there’s no reason you should be spending $10–$30 a month just to make QR codes. Especially when Canva gives you a powerful, customizable, and <em>free</em> alternative that integrates seamlessly into your design workflow.</p><p>So before you hit “renew” on that QR code subscription, ask yourself: do I really need to be paying for this?</p><p>Chances are, you don’t.</p><p>Canva is doing more than most dedicated QR services — for free. And once you switch, you’ll wonder why you didn’t ditch the subscription sooner.</p><p><strong>Stop the subscription cycle</strong> — u<strong>se Canva instead.</strong></p><p><em>Have thoughts or experiences with QR code tools? Drop them in the comments — let’s help each other save more and create better.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2049d07ddee5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LIME 1D Convolutional Neural Network Explainer]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@bjorn_sing/lime-1d-convolutional-neural-network-explainer-b036c6f44f53?source=rss-f656cf6e123b------2"><img src="https://cdn-images-1.medium.com/max/2600/0*LQZTMI3fGldIvNy6" width="3450"></a></p><p class="medium-feed-snippet">How to squeeze a CNN explanation out of a LIME Recurrent Tabular Explainer</p><p class="medium-feed-link"><a href="https://medium.com/@bjorn_sing/lime-1d-convolutional-neural-network-explainer-b036c6f44f53?source=rss-f656cf6e123b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@bjorn_sing/lime-1d-convolutional-neural-network-explainer-b036c6f44f53?source=rss-f656cf6e123b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b036c6f44f53</guid>
            <category><![CDATA[explainable-ai]]></category>
            <category><![CDATA[xai]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[ecg]]></category>
            <category><![CDATA[1dcnn]]></category>
            <dc:creator><![CDATA[Bjørn-Jostein Singstad]]></dc:creator>
            <pubDate>Thu, 29 Aug 2024 14:20:31 GMT</pubDate>
            <atom:updated>2025-05-30T17:04:21.952Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[The False-Positive paradox explained in an easy way]]></title>
            <link>https://medium.com/intuition/the-false-positive-paradox-explained-in-an-easy-way-d1a50cbeac2b?source=rss-f656cf6e123b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1a50cbeac2b</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[science]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Bjørn-Jostein Singstad]]></dc:creator>
            <pubDate>Thu, 20 Apr 2023 03:18:06 GMT</pubDate>
            <atom:updated>2023-04-20T03:18:06.692Z</atom:updated>
            <content:encoded><![CDATA[<h4>Statistics</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3tRc6dAuD0IgHT6D" /><figcaption>Photo by <a href="https://unsplash.com/ko/@rodlong?utm_source=medium&amp;utm_medium=referral">Rod Long</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The concept of false-positive paradox highlights the misleading nature of a diagnostic test that exhibits high sensitivity and specificity, particularly for low prevalence conditions. For instance, if we were to conduct genetic screening for hypertrophic cardiomyopathy (HCM) among all individuals in the United States — approximately 330 million people — with a prevalence rate of about 1:500, an algorithm analyzing their ECGs could demonstrate a sensitivity and specificity score of 98% and 99%, respectively. However, despite the impressively high predictive value of this screening test, a positive result for any individual does not confirm the likelihood that they are affected by HCM. In fact, due to the large population size and low prevalence rate of HCM, a false-positive result is more likely than a true positive.</p><p>Out of the 330 million electrocardiograms (ECGs) analyzed, it can be found through statistical analysis that approximately 660,000 individuals would be affected by hypertrophic cardiomyopathy (HCM). The test utilized in this fictive study would manage to detect HCM in about 646,800 cases. However, a small percentage comprising 13,200 people remained undetected. Though this is an unfortunate reality for those few who remain unrecognized and untreated; when considering that such a large population has been screened across United States territories- the numbers are relatively low.</p><p>Upon further examination in this fictive study, it was discovered that among the 329.34 million ECGs analyzed in the non-HCM affected group, approximately 1% or roughly 3,293,400 individuals have received false positive results suggesting an ailment. Such erroneous outcomes can cause unwarranted distress and apprehension among those concerned without proper medical validation. This occurrence highlights a perplexing issue of misleading outcomes, even when high-precision diagnostic tests are utilized on a large population with minimal instances of the ailment in question. It is crucial to recognize this problem and take necessary precautions to prevent misdiagnosis or unnecessary treatment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1a50cbeac2b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/intuition/the-false-positive-paradox-explained-in-an-easy-way-d1a50cbeac2b">The False-Positive paradox explained in an easy way</a> was originally published in <a href="https://medium.com/intuition">Intuition</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to train a CNN using tf.GradientTape]]></title>
            <link>https://medium.com/@bjorn_sing/tensorflow-gradient-tape-mnist-536c47fb8d85?source=rss-f656cf6e123b------2</link>
            <guid isPermaLink="false">https://medium.com/p/536c47fb8d85</guid>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[mnist-dataset]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[research]]></category>
            <dc:creator><![CDATA[Bjørn-Jostein Singstad]]></dc:creator>
            <pubDate>Mon, 06 Feb 2023 20:40:48 GMT</pubDate>
            <atom:updated>2023-02-06T20:40:48.700Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Train a CNN Using tf.GradientTape</h3><h4>A simple practical example of how to use TensorFlow&#39;s GradientTape to train a convolutional neural network.</h4><figure><img alt="Main image showing tensorflow logo, MNIST digits and the text; GradientTape" src="https://cdn-images-1.medium.com/max/1024/1*jjJRX5uQ_OXxa_aWuFfFtg.png" /><figcaption>Figure 1. A practical example of using tf.GradientTape with MNIST</figcaption></figure><p>Training TensorFlow models using model.fit()works perfectly fine for most applications, so why should you care about using tf.GradientTape() ?</p><p>For those of you who don&#39;t know what tf.GradientTape()is and what it does, here comes a short explanation:</p><p>tf.GradientTape() lets you compute the gradient while training all sorts of neural networks. The computed gradients are essential in order to do backpropagation to correct the errors of the neural network to make it gradualy improve.</p><h4>Using model.fit()</h4><p>The easiest way to train a model using TensorFlow is to use the model.fit()method. Assuming that you have defined some dataset X_trainwith some corresponding labels y_train and defined a model architecture create_my_model(), then a TensorFlow model can be trained using model.fit() like shown in the example below.</p><pre>num_epochs = 30<br>batchsize = 64<br><br>model = create_my_model()<br>model.compile(optimizer = &quot;adam&quot; , loss = &quot;categorical_crossentropy&quot;, metrics=[&quot;accuracy&quot;])<br>model.fit(x=X_train, y=y_train, epochs=num_epochs, batch_size=batchsize)</pre><p>This will train your model in a supervised way over 30 epochs. However, if you want to do some more crazy stuff, like training a generative adversarial network (GAN), or simply just want to understand what happens behind the curtains in model.fit(), you can use tf.GradientTape().</p><h4>Using tf.GradientTape()</h4><p>As a minimum working example, this would do exactly the same as model.fit() .</p><pre>num_epochs = 30<br>batchsize = 64<br><br>model = create_my_model()<br>opt = tf.keras.optimizers.Adam(learning_rate=0.001)<br>for epoch in range(num_epochs):<br>  for step in range(X_train.shape[0]//batchsize):<br>    start_idx = batchsize*step<br>    end_idx = batchsize*(step+1)<br>    X_batch = X_train[start_idx:end_idx]<br>    y_batch = y_train[start_idx:end_idx]<br>    with tf.GradientTape() as tape:<br>      pred = model(X_batch)<br>      loss = tf.keras.losses.categorical_crossentropy(y_batch, pred)<br>    grads = tape.gradient(loss, model.trainable_variables)<br>    opt.apply_gradients(zip(grads, model.trainable_variables))</pre><p>But you might say; “can I be 100% sure that using tf.GradientTape gives me the same good results as when I use model.fit() ?”</p><p>The answer is … almost<strong>, </strong>and I will show you this in an experiment on the well-known MNIST dataset (Figure 2 shows examples from the MNIST dataset).</p><figure><img alt="Ten examples of handwritten digits from the MNIST dataset" src="https://cdn-images-1.medium.com/max/1024/1*h8PPePAhRbKdqFaUFceY3g.png" /><figcaption>Figure 2. MNIST examples</figcaption></figure><h4>Experiment on MNIST</h4><p>Figure 3 shows the 2D CNN architecture that was trained and validated using 10-fold cross-validation on the MNIST dataset. First using the model.fit() method then the tf.GradientTape() method.</p><figure><img alt="A block diagram showing the model architecture" src="https://cdn-images-1.medium.com/max/347/1*FAJAnPUFDN3W5BOOrFViYA.png" /><figcaption>Figure 3. 2D CNN model architecture used in this experiment</figcaption></figure><p>The training curves in Figure 4 shows that there are some differences in performance using model.fit()compared to tf.GradientTape() and model.fit() seems to be significantly better. From the loss curve, it seems like the model that was trained using tf.GradientTape() starts to overfit after just a few epochs. The model that was trained using model.fit() does also overfit, but the increase in loss is less than the tf.GradientTape() model. A possible explanation for this might be that more things happen behind the curtains in model.fit() than what we have implemented in the tf.GradientTape() method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*d93jvhr3C4YA6rFgFkW-Sw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Nrq0R-6rjin2MkZ-XQ4CWQ.png" /><figcaption>Figure 4. Training curves showing the mean ± standard deviation for the loss and accuracy during training of the 2D CNN model on the MNIST dataset. The orange color represents the model trained using the tf.GradientTape() method, while the blue color represents the training using model.fit() method.</figcaption></figure><h4>Conclusion</h4><p>We have shown that tf.GradientTape() is relatively easy to implement. However, model.fit() seems to have some extra built-in calculations that make it slightly better than our proposed tf.GradientTape() method, at least for simple tasks such as supervised categorical classification on the MNIST dataset. Nevertheless, learning to use tf.GradientTape() will enable you to build advanced deep learning applications as well as give you a better intuition of how neural networks work.</p><h4>Code availability</h4><p>The full source code for this experiment is available on <a href="https://www.kaggle.com/code/bjoernjostein/train-keras-model-using-gradient-tape">Kaggle</a>.</p><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=536c47fb8d85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What's your cardiovascular age?]]></title>
            <link>https://medium.com/@bjorn_sing/whats-your-cardiovascular-age-23355d9598d7?source=rss-f656cf6e123b------2</link>
            <guid isPermaLink="false">https://medium.com/p/23355d9598d7</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[cardiology]]></category>
            <dc:creator><![CDATA[Bjørn-Jostein Singstad]]></dc:creator>
            <pubDate>Mon, 23 Jan 2023 18:05:45 GMT</pubDate>
            <atom:updated>2023-02-02T08:40:55.750Z</atom:updated>
            <content:encoded><![CDATA[<h4>In this article, I show how a Convolutional Neural Network can be used to predict a person&#39;s age based on the person&#39;s ECG</h4><p><a href="https://www.ahajournals.org/doi/full/10.1161/CIRCEP.119.007284">Attia et al 2019</a>[1], showed that a person&#39;s age could be predicted from an ECG using convolutional neural networks (CNN). They also showed that the predicted age relates to the cardiovascular age, which means that the model generally will overestimate the age of people with severe cardiovascular diseases and underestimate the age of healthy people. In Attia et al 2019 they describe a very interesting case, highlighting this phenomenon:</p><blockquote>Before age 54, he had numerous myocardial infarctions, and CNN predicted age significantly surpassed his actual age (predicted age ~70 years). At age 54, he underwent a heart transplant from a donor who died at the age of 16, with a subsequent decrease in CNN-predicted age to 50 years. He remained well for several years with subsequent loss of weight to normal weight and cessation of blood pressure and diabetes mellitus medications at the age of 60, with a further drop in CNN-predicted age to below chronologic age.</blockquote><p>Could this be useful in a clinical setting? The answer is we don&#39;t know, but it shows that a CNN can detect some patterns from the ECG that correlates well with our age. This is something even skilled cardiologists cannot do, but it is even more interesting to see that the presence of cardiovascular disease or cardiac injury patterns makes the model overestimate the age. This could for instance be used for patient risk stratification or maybe we could use eXplainable AI (XAI) to better understand these patterns and teach the doctors how to look for them.</p><p>The development of these models (including Attia et al 2019) have mainly been done on patient data owned by the hospitals and not on open data. Even not any trained models have been publically available up to now. This is very unfortunate because these models would have benefited from being tested, tweaked and benchmarked by the large data science community outside of the hospitals. We wanted to do something with this and therefore conducted a study where we used several open ECG datasets from China, USA and Germany.</p><p>In addition to Attia’s model architecture we used another promising CNN architecture called Inception Time, proposed by <a href="https://arxiv.org/abs/1909.04939">Fawas H.I et al 2019</a>[2]. The models were first trained on the datasets from China and USA, containing 59355 ECGs, and then tested on the separate cohort from Germany (PTB-XL dataset), containing 21748 ECGs. Figure 1 shows the normalized age distribution in both the training and test set. The distributions are skewed towards the right and this could possibly be due to the fact that the ECGs are gathered in a hospital setting, where one could assume an overweight of elderly people.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HDUeb29Mjt3A-FLKnK8vfA.png" /><figcaption>Figure 1. Normalized age distribution in training and test set [3]</figcaption></figure><p>The model was implemented in Python and stored in a public <a href="https://github.com/Bsingstad/ECG-age">GitHub repository</a> (containing source code and the trained models). The use of Jupyter Notebooks was done in order to make it possible to train and validate the models on <a href="https://colab.research.google.com/">Google Colab</a> in order to get access to free GPUs.</p><p>The final model (Inception Time) achieved a mean absolute error of 7.90±0.04 doing cross-validation on the training set and a mean absolute error of 8.3 years on the test set. This shows that the model generalizes fairly well and could be applied to data outside of the hospitals it was trained and still perform ok. Figure 2 show the true age (x-axis) versus the predicted age (y-axis). The red line show the optimal relation between true and predicted age, while the green line shows the optimal linear fit given the current prediction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*pbL6XAavZx5rG-3Tr3wOSw.jpeg" /><figcaption>Figure 2. True versus predicted age achieved by the Inception Time model on the test set [3]</figcaption></figure><p>Finally, we wanted to see whether there are any relationship between the annotated conditions, in the German ECG dataset, and the predicted age. In Figure 3 we show the predicted versus true age for 20 different cardiovascular conditions. The subfigures are sorted from the lowest to the highest mean absolute error starting at the upper left.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*56lB6h95lwTE4Ha0-TpRAQ.png" /><figcaption>Figure 3. Relationship between predicted and true age for 20 different cardiovascular conditions</figcaption></figure><h3>References</h3><ol><li>Attia et al., Z. I. Age and Sex Estimation Using Artificial Intelligence From Standard 12-Lead ECGs. <em>Circulation: Arrhythmia and Electrophysiology</em> <strong>12</strong>, e007284 (2019).</li><li>Ismail Fawaz et al., H. InceptionTime: Finding AlexNet for Time Series Classification. <em>Data Min Knowl Disc</em> <strong>34</strong>, 1936–1962 (2020).</li><li>Singstad, B.-J. &amp; Tavashi, B. Using deep convolutional neural networks to predict patients age based on ECGs from an independent test cohort. <em>Proceedings of the Northern Lights Deep Learning Workshop</em> <strong>4</strong>, (2023).</li></ol><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23355d9598d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ECHO2022]]></title>
            <link>https://medium.com/@bjorn_sing/echo2022-ml-challenge-b9a26537db0d?source=rss-f656cf6e123b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9a26537db0d</guid>
            <category><![CDATA[competition]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[echocardiogram]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <dc:creator><![CDATA[Bjørn-Jostein Singstad]]></dc:creator>
            <pubDate>Tue, 15 Mar 2022 21:05:31 GMT</pubDate>
            <atom:updated>2022-03-15T21:05:31.696Z</atom:updated>
            <content:encoded><![CDATA[<h4>Predict cardiac ejection fraction from echocardiogram loops</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_GtW-2JQgDLQeAuzUj7Gw.png" /><figcaption>ECHO 2022 — Machine Learning Challenge</figcaption></figure><p>Cardiac ejection fraction (EF) is a measurement, expressed as a percentage, of how much blood the left ventricle pumps out with each contraction [1]. Low cardiac EF might be a sign of heart failure, and therefore have clinical relevance. Cardiac EF is usually measured in the left ventricle, which is the heart’s main pumping chamber. The left chamber pumps oxygen-rich blood up into your body’s main artery (aorta) to the rest of the body [2].</p><p>Today cardiovascular MRI (CMR) is the gold standard for the calculation of left ventricular ejection fraction (LVEF)[3]. However, each cardiac MRI scan can cost between $1000–5000 or on average 5.5-times the price of echocardiography [4]. It would therefore have great health economical benefits if echocardiograms could be used instead of CMR to determine the left ventricular ejection fraction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*-84O2F1CtQECDqe1tnsiVA.gif" /><figcaption>A 4 channel echo loop</figcaption></figure><h3>The challenge</h3><p>Artificial intelligence has shown great potential in medical image classification and its reason to believe that it can be beneficial in terms of interpreting echocardiograms. In <a href="https://www.kaggle.com/c/echo2022">this dataset</a>, we present echo loops or sequences of echocardiograms. In the training set, there are images from 400 patients and in the test set, there are 50 patients. The objective is to predict the cardiac EF of the 50 patients in the test set.</p><h3>Data</h3><p>The data set contains both 2 channel (2CH) echo images and 4 channel (4CH) echo images. 2CH images show only the left ventricle and the left atrium, while 4CH shows both the left and right atrium and ventricle. The competitors are free to choose whether they want to use only 4CH, only 2CH, or both in their training and prediction.</p><p>The image data are stored in .npy files. These files can be loaded into Python using numpy.load</p><pre>import numpy as np</pre><pre>np.load(&quot;./my_path/my_echofile.npy&quot;)</pre><p>Each .npy-file contains an entire echo loop. All images inside an echo loop have the same resolution and image size, but the image size varies from patient to patient.</p><p>The ejection fraction (ground truth) for the training data is given inside the file called train_data.csv. This file can be uploaded to Python using pandas.read_csv</p><pre>import pandas as pd</pre><pre>pd.read_csv(&quot;./my_path/train_data.csv&quot;)</pre><p>And finally, after you have trained your model and done the predictions on the test set you can populate the lv EF column in the sample_submission.csv-file with your own predictions and submit it to <a href="https://www.kaggle.com/c/echo2022">this competition</a>.</p><h3>Baseline code</h3><p>Need a place to start? Check out <a href="https://www.kaggle.com/bjoernjostein/echo2022-eda-baseline-model">this baseline code</a> which gives a brief introduction to the dataset, some exploratory data analysis, and a baseline model as a benchmark for further development.</p><h3>Reference</h3><p>[1] <a href="https://www.heart.org/en/health-topics/heart-failure/diagnosing-heart-failure/ejection-fraction-heart-failure-measurement">https://www.heart.org/en/health-topics/heart-failure/diagnosing-heart-failure/ejection-fraction-heart-failure-measurement</a><br>[2] <a href="https://www.mayoclinic.org/tests-procedures/ekg/expert-answers/ejection-fraction/faq-20058286">https://www.mayoclinic.org/tests-procedures/ekg/expert-answers/ejection-fraction/faq-20058286</a><br>[3] Simpson R, Bromage D, Dancy L, et al6 Comparing echocardiography and cardiac magnetic resonance measures of ejection fraction: implications for HFMRF researchHeart 2018;104:A3.<br>[4] <a href="https://www.acc.org/latest-in-cardiology/articles/2019/01/07/12/42/for-the-fits-the-future-of-cardiovascular-imaging-considerations-for-fits">https://www.acc.org/latest-in-cardiology/articles/2019/01/07/12/42/for-the-fits-the-future-of-cardiovascular-imaging-considerations-for-fits</a><br>[5] S. Leclerc, E. Smistad, J. Pedrosa, A. Ostvik, et al.<br>“Deep Learning for Segmentation using an Open Large-Scale Dataset in 2D Echocardiography” in IEEE Transactions on Medical Imaging,<br>early acces, 2019</p><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9a26537db0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NumPy reshape can break your heart]]></title>
            <link>https://medium.com/data-science/numpy-reshape-can-break-your-heart-96fcc47c6894?source=rss-f656cf6e123b------2</link>
            <guid isPermaLink="false">https://medium.com/p/96fcc47c6894</guid>
            <category><![CDATA[reshape]]></category>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[resample]]></category>
            <category><![CDATA[time-series-data]]></category>
            <dc:creator><![CDATA[Bjørn-Jostein Singstad]]></dc:creator>
            <pubDate>Fri, 14 Jan 2022 13:16:18 GMT</pubDate>
            <atom:updated>2022-01-14T13:16:18.289Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h4>NumPy reshape may not literally break your heart, but it can make unintentional changes to time-series like e.g electrocardiograms (ECG), and cause dramatic changes in terms of the physiological properties</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sTvQ6EnJYmAFJFMl" /><figcaption>Figure 1: Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This story, which I am about to tell, originates from an experience gained while participating in Physionet Challenge <a href="https://physionetchallenges.org/2020/">2020</a> and <a href="https://physionetchallenges.org/2021/">2021</a>. The task in this machine learning challenge was to classify heart-related diseases from electrocardiograms (ECG). Our team decided to use 1D Convolutional Neural Networks to classify 30 different cardiac diseases from 12-lead ECGs (you can read more about this approach in our <a href="https://www.researchgate.net/publication/355855233_Multi-label_ECG_classification_using_Convolutional_Neural_Networks_in_a_Classifier_Chain">preprint paper</a>).</p><p>The problem occurred after we had imported the dataset into a NumPy array and then had to reshape the array from:</p><blockquote>(n_patients x n_channels x n_signal_length)</blockquote><p>to</p><blockquote>(n_patients x n_signal_length x n_channels)</blockquote><p>This was necessary to make the array fit the input shape of the 1D Convolutional Neural Network. In previous projects, working with image data, I have done this using NumPy’s reshape method and this works perfectly fine. The code below shows how the three examples of MNIST digits, shown in Figure 2, were plotted before reshaping the array.</p><pre>Image_data = pd.read_csv(&quot;/kaggle/input/digit-recognizer/train.csv&quot;)<br>Image_data = Image_data.iloc[:,1:]<br># Image_data shape = (42000, 28, 28, 1)</pre><pre>for i <strong>in</strong> range(3):<br>    plt.imshow(Image_data[i][:,:,0])<br>    plt.axis(&quot;off&quot;)<br>    plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*ATMhyuKNNgAY7ZlIAzTU6Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*U5HYljuamKVS8JbsxwASyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*5_ypabdoTFmQbBENS1LWPQ.png" /><figcaption>Figure 2: MNIST digits without any preprocessing | Image by author</figcaption></figure><p>Then, let&#39;s try to apply the reshape method to the same three numbers and then plot it again.</p><pre>Image_data_reshaped= Image_data.reshape(42000,28,1,28)</pre><pre>for i <strong>in</strong> range(3):<br>    plt.imshow(Image_data_reshaped[i][:,0,:])<br>    plt.axis(&quot;off&quot;)<br>    plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*ATMhyuKNNgAY7ZlIAzTU6Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*U5HYljuamKVS8JbsxwASyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*5_ypabdoTFmQbBENS1LWPQ.png" /><figcaption>Figure 3: MNIST digits after reshaping | Image by author</figcaption></figure><p>Figure 3 shows the 3 same figures plotted in Figure 2 after using NumPy reshape method. And…. tada:</p><h3>No difference! 🎉</h3><p>Now let’s, switch back to the ECG case and try the same method on the ECG array. First, let’s take a look at what an ECG is:</p><blockquote>The ECG reflects the electrical activity of the heart, and the interpretation of this recording can reveal numerous pathologies of the heart.</blockquote><p>A 12-lead ECG is measured by placing 10 electrodes at different positions on the upper body of the patients. This lets us measure the electrical activity of the heart from different angles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s20p4mr7XL2WeIP4" /><figcaption>Figure 4: A 12-lead ECG interpreted manually. Photo by <a href="https://unsplash.com/@towfiqu999999?utm_source=medium&amp;utm_medium=referral">Towfiqu barbhuiya</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Now, let&#39;s look at the 12 ECG leads from the first patient in the dataset. The code below shows how a 12-lead ECG from one patient was selected and plotted without any reshaping. The plotted results are shown in Figure 5and each sub-figure shows each of the 12 leads.</p><pre># ecg_array shape is equal to (21832,12,5000)</pre><pre>single_ecg = ecg_array[0]</pre><pre>for i <strong>in</strong> range(12):<br>    ecg_plot.plot_1(single_ecg[i,:])<br>    plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PQWYyJSkQaeC01viqlfuiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XnkUPUikja9YF-MOtIr_XQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R14KaOF7cK8ViSwHI1c-Hw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n5Lu6p4tOMzAQ357zlamAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sypfo7-dlzliPAkcAXG2RA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tcujDP1ud5qPooK-6mza-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wHYkVcL3zOJFxrmgFpUbDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wjm9WalOUHM9UOd-v2czCg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nbCEq0z1ujTaI78aKxmoew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FhQxvSOhtJqUncWfEL0_Pw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n6To24KY5jkpRkGDjcF-Jg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D60KnEdGJA-_wabs0QYgdQ.png" /><figcaption>Figure 5: ECGs before any preprocessing | Image by author</figcaption></figure><p>Now, let&#39;s use the reshape method on the ECG.</p><pre># single_ecg shape = (12,5000)<br>reshaped_ecg = single_ecg.reshape(single_ecg.shape[1],single_ecg.shape[0])<br># reshaped_ecg shape = (5000,12)</pre><pre>for i <strong>in</strong> range(12):<br>    ecg_plot.plot_1(reshaped_ecg[:,i])<br>    plt.show()</pre><p>Figure 6 shows the resulting 12 leads after plotting the reshaped ECG array</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kTBW3BxQQyFgTQCX9ECOBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tm3idpWP3tjd6B5J2chRIw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2gCcwsOxMrEoy-O5ItEpow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kff-8FYAox6X_-8V0N3KTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FqddqBrfvSZYzFOHHgrIHw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OmZPnKMCUe85PJUcnjeAkg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wQl53bRSmWb3xUU97QfAzg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvuNqCW9Qt5fozNK5vKdog.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k8wrwJYTeq8QUNYr9rjR5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WPes2SxUJOAe4ON6NcN5MQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*04LOyqwqA3LNkJHBiFNEfg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*enJvLWUDk1FxKncepX0dPg.png" /><figcaption>Figure 6: ECG after using the reshape method | Image by author</figcaption></figure><p>Hmm... something strange happened. Let’s zoom in on one of the ECGs. Figure 7 shows what&#39;s supposed to be lead I. It still looks like an ECG, but not as we expected. If we take a closer look at the 12 leads in Figure 4 again we see that all leads are exactly the same now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kTBW3BxQQyFgTQCX9ECOBA.png" /><figcaption>Figure 7: Zoom in on one ECG lead processed with the NumPy reshape method | Image by author</figcaption></figure><p>The best way to show what happened is to flatten the original ECG signal and resample it to 5000 samples, and then compare it with the reshaped signal as shown in Figure 8.</p><pre># single_ecg.ravel() shape = 60000 (12 x 5000)<br>from scipy import signal</pre><pre>#resample signal from 60000 to 5000<br>resamp_sig = signal.resample(single_ecg.ravel(), 5000) </pre><pre><br>plt.plot(reshaped_ecg[:,0], label=&quot;reshaped signal&quot;)<br>plt.plot(resamp_sig, label=&quot;resampled signal&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AmrdQUZd-DE_DnkU4u0Huw.png" /><figcaption>Figure 8: Reshaped signal VS resampled signal | Image by author</figcaption></figure><p>From Figure 8 we see that the reshape method actually not just reshapes the array but also resamples all original 12 leads and then makes it fit into a single lead and then makes 12 copies.</p><p>Ok, so NumPy reshape might not literally break your heart, but in this case, it made an unintentional change to the ECG which also made a dramatic change to the physiological properties. In this case it increased the measured heart rate by a factor of 12, but how do we overcome this problem?</p><h4>Use n<strong>umpy.moveaxis </strong>instead!</h4><pre># single_ecg shape = (12,5000)<br>ecg_moveaxis = np.moveaxis(single_ecg, 0, -1)<br># ecg_moveaxis.shape = (5000,12)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96fcc47c6894" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/numpy-reshape-can-break-your-heart-96fcc47c6894">NumPy reshape can break your heart</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From cats and dogs to polyps in the colon]]></title>
            <link>https://medium.com/@bjorn_sing/from-cats-and-dogs-to-polyps-in-the-colon-3e139aafe030?source=rss-f656cf6e123b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e139aafe030</guid>
            <category><![CDATA[medical-imaging]]></category>
            <category><![CDATA[segmentation]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[challenge]]></category>
            <dc:creator><![CDATA[Bjørn-Jostein Singstad]]></dc:creator>
            <pubDate>Mon, 10 Jan 2022 18:34:33 GMT</pubDate>
            <atom:updated>2022-01-10T19:03:50.927Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Colorectal cancer is one of the deadliest and most widespread types of cancer in the world and colonoscopy is the preferred procedure used to detect and diagnose these polyps in the colon. On the other hand, today’s detection rate shows a significant error rate that affects diagnosis and treatment. In 2021 <a href="https://www.simulamet.no/">Simula Metropolitan Center for Digital Engineering</a> and the new AI journal; <a href="https://journals.uio.no/NMI/">Nordic Machine Intelligence</a>, organized a machine learning challenge with 3 tasks. The two first tasks was to segment polyps and instruments from colonoscopy images. A <a href="https://datasets.simula.no/kvasir/">training set comprising of 1000 annotated images</a> was used in the polyp segmentation task and a<a href="https://datasets.simula.no/kvasir-instrument/"> training set of 590 annotated images</a> was used in the instrument segmentation task. The polyp and instrument segmentation models were finally scored on two separate test sets containing 300 images each.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hAYk6vversP5inSl2EqXXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g_p88RqDjKBahww_TeCsnQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B_R09HJmYDtO8Pqjrrsk-g.png" /><figcaption>Segmented polyps — the predicted masks are shown as a transparent white overlay over the colonoscopy images, highlighting the polyps shown in the images</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j1qZ53fGds-_cK_Qi0qrGQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gbldm4UIW0V-yNGRsEu9hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uuIZnOrQLOhHQpXtajjuyw.png" /><figcaption>Segmented instruments — the predicted masks are shown as a transparent white overlay over the colonoscopy images, highlighting the instruments shown in the images</figcaption></figure><p>The 3rd and final task was to make the model and the prediction more transparent. This task was open to interpretation by the participants as there were no specific requirements and a multi-disciplinary team evaluated the submissions based on how transparent and understandable the submissions were. Finally, 16 teams described their methodologies and results in <a href="https://journals.uio.no/NMI/issue/view/787">16 different scientific papers</a> published by <a href="https://journals.uio.no/NMI/">Nordic Machine Intelligence</a> and the team which had the best overall achievement on all of the 3 tasks got 5000 euros in prize money.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*QKHUxfqquBYa-_QLP8Wi2w.jpeg" /><figcaption>Nordic Machine intelligence logo</figcaption></figure><p>Our team; Team Polypixel, ended up in 6th place in this machine learning challenge (you can read our full paper <a href="https://journals.uio.no/NMI/article/view/9132">here</a>). We found that pretraining the segmentation models on ImageNet, containing images like cats and dogs, had a significant increase in performance both on the polyp and instrument segmentation. From cross-validation, we found the polyp model to achieve a DICE score of 0.65±0.07 without pretraining and 0.87±0.01 with pretraining. The instrument model achieved a DICE score of 0.89±0.03 without pretraining and 0.94±0.02 with pretraining.</p><p>If you are curious about these datasets but don&#39;t know where to start you can have a look at these two notebooks: <a href="https://www.kaggle.com/bjoernjostein/hyperkvasir-starter-code">Polyp segmentation</a> and <a href="https://www.kaggle.com/bjoernjostein/kvasir-instrument-starter-code">Instrument segmentation</a> where you can find the data sets attached and a machine learning pipeline with augmentations and other preprocessing steps.</p><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e139aafe030" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kaggle Days Championship — Shanghai]]></title>
            <link>https://medium.com/@bjorn_sing/kaggle-days-championship-shanghai-f137a5e823bb?source=rss-f656cf6e123b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f137a5e823bb</guid>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[kaggle-days]]></category>
            <dc:creator><![CDATA[Bjørn-Jostein Singstad]]></dc:creator>
            <pubDate>Fri, 19 Nov 2021 09:01:05 GMT</pubDate>
            <atom:updated>2021-11-20T09:42:14.672Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kaggle Days Championship — Shanghai</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HorsQTaGUjCbbb5U" /><figcaption>Photo by <a href="https://unsplash.com/@kikekiks?utm_source=medium&amp;utm_medium=referral">kike vega</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Yesterday, 18th November history was made in Shanghai, at least virtually in Shanghai. This was the first-ever, of totally 12 Kaggle Days Championship meetups, which were held virtually in Shanghai. You might wonder what Kaggle Days Championship is, and who isbetter to explain this than the organizers themselves:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FT3nbDpwA95Q%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DT3nbDpwA95Q&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FT3nbDpwA95Q%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ba4ec2e1fe2f9e239daa9db9a32281b/href">https://medium.com/media/1ba4ec2e1fe2f9e239daa9db9a32281b/href</a></iframe><p>The meetups started off with a short introduction of the organizers followed by a great presentation by Kaggle Grandmaster, Shen Tao, better known as <a href="https://www.kaggle.com/shentao">SeuTao</a> on Kaggle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L7DFsa25tuwdaw6w4pelcA.jpeg" /></figure><p>He did a 30 minutes presentation on:</p><h3><em>How to win Kaggle Competitions using Transformer models</em></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yB-zeXXjq5Hj6_8_" /><figcaption>Photo by <a href="https://unsplash.com/@tetrakiss?utm_source=medium&amp;utm_medium=referral">Arseny Togulev</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>He started bygoing through some key aspects of the transformer models like the attention modules, the Query-Key-Value principle and the multi-headed self-attention [1]. Furthermore, he told about some of the most obvious use cases for transformers such as NLP, but also innovative and forward-looking use-cases like</p><ul><li>Transformers for Computer Vision — Masked Autoencoders [2] and Swin Transformers [3]</li><li>Transformers for Graph structured data — Graphormer [4]</li></ul><p>In his conclusion, he also had some helpful bits of advice from his experiences of training and using Transformers</p><ul><li>Be patient with the hyperparameter tuning</li><li>Use pre-layer normalization</li><li>Use warmup</li><li>Use identity-mapping initialization</li></ul><p>But he also emphasized that Transformers is not all you need to win Kaggle competitions</p><blockquote>Transformers is not all you need</blockquote><h3>Don’t stop until you drop!</h3><p>You have might asked yourself why the first image in this post was a yoga pose and the answer to this is because the first Kaggle Days Meetup challenge was to identify yoga poses from images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*zzg79OMEVtm2sjydOUxHfg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*laDvqS3XzYfIgoEt8pSFSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*7yXPHtpcpAhsPen27Kc1IA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*jFp3_7ztlEkEJimRjuzFRw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*YFyV7s7SjYrrumRHycUEcw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*mMUBVUtRsfgM70C5APM28g.png" /><figcaption>Example of all six different poses in the data set [5]</figcaption></figure><p>The given data set, used for model development, contained 2360 images, and a test set containing 756 images, of people doing six different yoga poses[5]. This was organized as a classical Kaggle competition, but with a 4 hours deadline. Each team had 10 attempts to submit their best classification results on the test set. A total of 70 teams submitted their prediction, including our team, <em>Team</em> <em>Overfitted</em> (<a href="https://www.kaggle.com/bjoernjostein/kaggle-days-shanghai-2021-accuracy-88-07/notebook">here is our solution</a>).</p><p>Your question now might be; <em>is it too late for me to participate? </em>And the answer is no. You can still participate in the remaining 11 meetups. At each of these meetups, the three best-performing teams will be invited to the big final in Barcelona in September/October 2022. <em>Team!? I don&#39;t have a team, </em>you might think. Don’t worry just register here <a href="https://kaggledays.com/championship/meetups/">https://kaggledays.com/championship/meetups/</a> and you will be invited to the Slack channel where you will meet friendly fellow Kagglers who are more than happy to form a team with you.</p><p>#kaggledays #kaggledayschampionship</p><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><p>[1] A. Vaswani <em>et al.</em>, ‘Attention Is All You Need’, <em>arXiv:1706.03762 [cs]</em>, Dec. 2017, Available: <a href="http://arxiv.org/abs/1706.03762">http://arxiv.org/abs/1706.03762</a></p><p>[2] K. He, X. Chen, S. Xie, Y. Li, P. Dollár, and R. Girshick, <em>Masked Autoencoders Are Scalable Vision Learners</em>. 2021.</p><p>[3] K. He, X. Chen, S. Xie, Y. Li, P. Dollár, and R. Girshick, <em>Masked Autoencoders Are Scalable Vision Learners</em>. 2021.</p><p>[4] C. Ying <em>et al.</em>, ‘Do Transformers Really Perform Bad for Graph Representation?’, <em>arXiv:2106.05234 [cs]</em>, Jun. 2021, Available: <a href="http://arxiv.org/abs/2106.05234">http://arxiv.org/abs/2106.05234</a></p><p>[5] M. Verma, S. Kumawat, Y. Nakashima, and S. Raman, ‘Yoga-82: A New Dataset for Fine-grained Classification of Human Poses’, in <em>IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW)</em>, 2020, pp. 4472–4479.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f137a5e823bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>