<?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 Mykyta Solonko on Medium]]></title>
        <description><![CDATA[Stories by Mykyta Solonko on Medium]]></description>
        <link>https://medium.com/@msolonko?source=rss-fe4b70c28b97------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*yEucruIJqUV-u75XZlwTXQ.jpeg</url>
            <title>Stories by Mykyta Solonko on Medium</title>
            <link>https://medium.com/@msolonko?source=rss-fe4b70c28b97------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 23:06:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@msolonko/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[Manta Biofuel Analysis]]></title>
            <link>https://msolonko.medium.com/manta-biofuel-analysis-d576bb532900?source=rss-fe4b70c28b97------2</link>
            <guid isPermaLink="false">https://medium.com/p/d576bb532900</guid>
            <category><![CDATA[equity-crowdfunding]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[venture-capital]]></category>
            <category><![CDATA[manta-biofuel]]></category>
            <dc:creator><![CDATA[Mykyta Solonko]]></dc:creator>
            <pubDate>Wed, 06 Jan 2021 23:43:50 GMT</pubDate>
            <atom:updated>2021-01-10T04:07:13.687Z</atom:updated>
            <content:encoded><![CDATA[<p>Deeper look at the promising startup</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QwY8E9-NWXkt1h42AmEH8A.jpeg" /></figure><p><em>Disclaimer: Nothing that appears in this post is investment advice. I created this document as I was conducting my own due diligence on a potential investment opportunity for myself. I am an angel investor and Venture Fellow at Republic. I am not employed by Republic, and this is not an endorsement of Manta Biofuel.</em></p><p>After scouring Republic for my next investment, I noticed that Manta Biofuel’s raise was picking up some steam. While I usually document my due diligence privately, I decided to write a post in case it is useful to other angel investors doing their due diligence.</p><p>I will be looking at the market, founding team, traction, and competitive landscape.</p><h4>Introduction</h4><p>With the world becoming increasingly concerned about global warming, nations are making an effort to transition from using fossil fuels to renewable sources for power. In 2019, 80% of American energy came from fossil fuels.¹</p><p>Knowing that it is difficult to quickly transition everything to solar energy and that many industries will require fossil fuels for decades to come, <a href="https://mantabiofuel.com/">Manta Biofuel</a> uses fast-growing algae to create a renewable (carbon neutral) replacement for crude oil (petroleum). Essentially, algae grow in ponds, gets harvested using special machinery, and then gets converted into oil. At scale, this system is expected to be automated and allow independent farmers to grow algae naturally and convert it into oil.</p><h4>Market</h4><p>Manta Biofuel is starting with heating oil. In 2018, 3.6 billion gallons of heating oil were used by American households.² With a price per gallon of about $3 in 2018, this is roughly a $10 billion market.³ Outside of heating oil, the size of the petroleum industry as a whole (globally) is about $1.7 trillion.⁴</p><p>While there is no debate that the market that Manta Biofuel addresses is huge, a potential concern is falling oil prices, as we have seen in the spring of 2020. Given that Manta Biofuel will have to compete with other companies selling non-renewable oil, the price per barrel at which Manta Biofuel is profitable will determine its short-term viability. Andrew Wills, Director of Finance at Manta Biofuel, mentioned that many US oil producers have “breakeven production costs around $50/barrel,” while the goal of Manta Biofuel is to reach $25/barrel with time, which would indeed be very competitive. This number of $50/barrel is supported by other sources.⁵ Thus, the main risk I see here is Manta Biofuel’s ability to actually scale and reach that $25/barrel price (based on Andrew’s response on Republic, their current production cost is $65, but they have a clear path on how to get down to $25). If it succeeds, they would be very well-positioned.</p><p>Also, it is worth noting that oil prices have been recovering since the sharp drop in the spring.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*r8bdsYmwrEiRI0-C2MjVRQ.png" /><figcaption>Oil Prices Recovering (<a href="https://www.macrotrends.net/1369/crude-oil-price-history-chart">source</a>)</figcaption></figure><p><strong>Founding Team</strong></p><p>The startup is led by CEO Dr. Ryan Powell, who has a Ph.D. in algal biofuels and invented the harvesting system that Manta Biofuel is using in its process. In addition to his experience on his family’s farm, Dr. Powell seems like the perfect person to lead such a venture.</p><p>Brian Ratigan, Senior Chemical Engineer and Ex-Exxon Project Engineer is an author of 8 patents and an expert on chemical and biotech processes with 43 years of experience. The team also features engineers and Director of Finance Andrew Wills who has venture capital experience.</p><p>Overall, I do not have any concerns about the team being qualified. The only small concern is co-founder Onur Unal’s departure from the company in 2019 and what impact that will have on Manta Biofuel going forward. Of course, I am not sufficiently with their team dynamic to evaluate the possible impacts of this.</p><p><strong>Traction</strong></p><p>Some of the things that Manta Biofuel mentioned on Republic blew me away. They have secured $2.2M from the U.S. Department of Energy, got accepted into two clean-tech accelerators, and proven that their oil is safe to be used as a replacement of standard oil. An early relationship with the U.S. Government is certainly amazing, especially given that climate change will be addressed more and more seriously in the years to come.</p><p>It appears that Manta Biofuel plans to sell 240,000 gallons of oil to the University of Maryland where the CEO did his Ph.D. While they have already had their first sale to a customer in 2018, it is not very clear whether this has continued since. They plan to sell about 10,000 gallons this year (2021), which is about 240 barrels. With a market price of $125 (from their chart), this would bring roughly $30k in revenue. The traction / revenue is very small at the moment, but it is important to point out that Manta Biofuel is raising at a decently low $6M valuation cap, so the lack of revenue has been priced in to the deal.</p><p>Manta Biofuel’s projected sales reach a few million gallons in a few years, so we will have to wait and see if this happens. From the available information, it seems like they have the technology, expertise, and third-party support necessary for success, so the next obstacle is to begin producing and scaling, making use of their pipeline of over 50 qualified leads.</p><p><strong>Competition</strong></p><p>The Republic page features the following graphic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t7VlDpJPwotHKY79.png" /></figure><p>At scale, we have established that Manta Biofuel should be competitive with Fossil Fuel Companies. Biodiesel is definitely more expensive than Manta’s eventual price target.⁶ Ethanol requires a different engine, while Manta’s product is chemically compatible with what already exists. While I definitely agree with the last two columns of the chart, it would be useful if the Manta Biofuel team quantified the first three, especially why their product is more renewable than ethanol and biodiesel and how they can be sure that their startup cost is that much lower.</p><p>Regarding intellectual property, Manta Biofuel holds two patents to protect its magnetic harvesting methods.</p><p>I wish that they mentioned the names of some of their competitors. For instance, <a href="https://corporate.exxonmobil.com/en/Research-and-innovation/Advanced-biofuels/Advanced-biofuels-and-algae-research?utm_source=google&amp;utm_medium=cpc&amp;utm_campaign=XOM+%7C+Corp+%7C+ELH+%7C+Traffic+%7C+Brand+%7C+Innovation+%7C+Algae+%7C+Phrase&amp;utm_content=Brand+%7C+Algae+%7C+Core+%7C+Exxon+%7C+NEW&amp;utm_term=exxon+algae&amp;&amp;gclid=Cj0KCQiA88X_BRDUARIsACVMYD9fNNMPC5EIG2QGZmk4-t0a3bal1H2fM-hDQJUm7JkTitQryK9DlFQaAhoMEALw_wcB&amp;gclsrc=aw.ds#Algaeforbiofuelsproduction">this article</a> talks about Exxon’s goals of producing huge quantities of algal crude oil by 2025. How does Manta differentiate from Exxon? Why can they outcompete this giant? Who are the other major players? More details on this would be appreciated beyond the broad categories in the graphic above.</p><p>Overall, this space is very competitive, with many big players involved. Given the size of the market and the early support that Manta has gotten, I do not think that this is a deal-breaker and that they can fill a specific niche with their unique algae growing and harvesting method.</p><h4>Final Thoughts</h4><p>My main concerns with Manta is the limited traction and the uncertainty regarding the competition. On the bright side, they have been noticed by the Department of Energy and the founding team is phenomenal.</p><p>Personally, I will be investing a small amount into this startup (being a non-accredited investor). Please do your own research (some sources below), and keep in mind that this is not financial advice.</p><p>[1]: U.S. Energy Information Administration. (September 14, 2020). <a href="https://www.eia.gov/todayinenergy/detail.php?id=45096">Link</a></p><p>[2]: U.S. Energy Information Administration. (February 26, 2020). <a href="https://www.eia.gov/energyexplained/heating-oil/use-of-heating-oil.php">Link</a></p><p>[3]: U.S. Energy Information Administration. (December 30, 2020). <a href="https://www.eia.gov/dnav/pet/hist/LeafHandler.ashx?n=PET&amp;s=M_EPD2F_PRS_NUS_DPG&amp;f=M">Link</a></p><p>[4]: Oil Price. (October 3, 2016). <a href="https://oilprice.com/Energy/Crude-Oil/The-17-Trillion-Oil-Industry-Isnt-Going-Anywhere.html">Link</a></p><p>[5]: Financial Times. (May 1, 2020). <a href="https://www.ft.com/content/bc398fca-c66d-4d0f-8e29-a1b0a6fee6bd">Link</a></p><p>[6]: U.S. Department of Energy. (October, 2020). <a href="https://afdc.energy.gov/fuels/prices.html">Link</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d576bb532900" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[R Tutorial: Analyzing COVID-19 Data]]></title>
            <link>https://medium.com/data-science/r-tutorial-analyzing-covid-19-data-12670cd664d6?source=rss-fe4b70c28b97------2</link>
            <guid isPermaLink="false">https://medium.com/p/12670cd664d6</guid>
            <category><![CDATA[r-programming]]></category>
            <category><![CDATA[coronavirus]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[statistical-analysis]]></category>
            <category><![CDATA[r]]></category>
            <dc:creator><![CDATA[Mykyta Solonko]]></dc:creator>
            <pubDate>Tue, 24 Mar 2020 23:33:22 GMT</pubDate>
            <atom:updated>2021-05-08T05:34:56.427Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction to using R in the real world</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UofAibMtS22EEgyyCYZGbw.jpeg" /><figcaption><a href="https://pixabay.com/photos/entrepreneur-idea-competence-vision-1340649/">Source</a></figcaption></figure><p>This semester at Yale I am taking an Introduction to Econometrics class where we utilize R and statistics in order to analyze various datasets. So, while I am socially distancing myself at home, I thought it would be interesting to apply some of the techniques that I have learned on a COVID-19 dataset.</p><p>I used <a href="https://www.kaggle.com/sudalairajkumar/novel-corona-virus-2019-dataset/version/25#COVID19_line_list_data.csv">this page on Kaggle </a>and found a CSV dataset that you can get <a href="https://www.kaggle.com/sudalairajkumar/novel-corona-virus-2019-dataset/download/uMF6QnlPB7ScS6BxTw1I%2Fversions%2Fe03zBLHwzT7b8fR01UTk%2Ffiles%2FCOVID19_line_list_data.csv?datasetVersionNumber=25">here</a>.</p><p>Let us take a look at the data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gl19hf2afTJyCHOe5HkQ0g.png" /></figure><p>We have data for about 1,000 cases of COVID-19. We can see the age of each infected person, the fender, whether they recovered or died, among many other things. For this tutorial, we will just look at a few of these columns. Let us make a folder with this CSV file in it and start RStudio.</p><p>In RStudio, to import the dataset, we will go to File-&gt;Import Dataset-&gt;From Text(base). Find your CSV file and click “Import.” You will see a line like this in the console of RStudio:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6285ba272018079f1797a942d4809cfa/href">https://medium.com/media/6285ba272018079f1797a942d4809cfa/href</a></iframe><p>We will copy this line into our main R script, which I will save as script.R in the same folder as our CSV file.</p><p>For convenience, I will rename the data frame variable to “data.” I will also clear all existing variables, import a library called Hmisc, and use its describe function to better understand our data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/613b658d7062c642eba390cc9d7b6ee9/href">https://medium.com/media/613b658d7062c642eba390cc9d7b6ee9/href</a></iframe><p>If you run this code, you will see a lot of information in the console. For instance, we have 1085 rows. If we look at the death section, we see that there are 14 distinct values. This may seem a little bit weird, but the death column either has a 0 (no death), 1 (no death), or simply the date of the patient’s death. This is difficult to work with because we want all 0s and 1s.</p><p>Let us fix this by adding a death_dummy column to our dataset, which only contains the values 0 and 1.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22b0c4350685b9240f298b351db04fc0/href">https://medium.com/media/22b0c4350685b9240f298b351db04fc0/href</a></iframe><p>We also calculated the death rate of our dataset, which after running turns out to be 5.8%. For the first part of this tutorial, we will analyze the age of the people who have died and of those who did not.</p><h3>AGE</h3><p>The media claims that older people are more likely to die than younger people from COVID-19. Is this true? Let us check with our dataset. First, we will subset our dataset into patients who are alive and patients who have died and compare the mean ages. This code will do it for us:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/803d829405cf9c2283ba3b17b2724f96/href">https://medium.com/media/803d829405cf9c2283ba3b17b2724f96/href</a></iframe><p>Notice, the na.rm=TRUE means to skip rows that have NA (or no value) for a specific column (age in this case). After running this, we get that the mean of those who survived is 48 years, while the mean for those who have died is about 68.6 years old.</p><p>Okay, so the data does indeed show that those who die are older in our sample. But is this true universally for the population? How confident are we that this is true?</p><p>We can use the t.test command to gauge our confidence and to see if we can trust our means. In this case, we will use a 95% confidence interval.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/32a84f822a918c37553574da128b5b75/href">https://medium.com/media/32a84f822a918c37553574da128b5b75/href</a></iframe><p>This simple command is quite powerful. Notice, we gave it both the ages of the alive patients as well as the age of the patients who have died. Let’s analyze the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_VaJkIMIIMWtKDsOYDZmgg.png" /></figure><p>Looking at the confidence interval, we can say with 95% certainty, that the age difference between patients who have died and those who haven’t is from 16.7 to 24.3 years. Now, look at the p-value. It is almost 0. This means that there is ~0% chance that we obtained such extreme result randomly from this sample under the null hypothesis (which is that the ages of the two groups are equal). For this reason, we can reasonably reject the null hypothesis (under the conventional significance level of 0.05) and say that people who have died from COVID-19 are indeed older than those who did not. Now, let’s look at gender!</p><h3>GENDER</h3><p>This will be very similar. We want to see if the death rate is similar for men and women. Let us again split our data and perform the t-test:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a1993a732c9b767ab523b0df4616a57/href">https://medium.com/media/9a1993a732c9b767ab523b0df4616a57/href</a></iframe><p>We subset our original data into two sets. After calculating the means, we see that men in this dataset have a death rate of 8.5% as opposed to 3.7% in women. Well, this is unexpected. Again, can we trust this data? Here is the t.test output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*HP1h515aC08okQu91oefkg.png" /></figure><p>Our confidence interval of 95% shows that mean will have from 1.7% to 7.8% higher death rate than women. A p-value of 0.002 signifies that we can reject the null hypothesis that men and women have the same death rate, since 0.002 &lt; 0.05.</p><p>There have been articles written that men indeed do have a higher coronavirus death rate. <a href="https://www.cnn.com/2020/03/24/health/coronavirus-gender-mortality-intl/index.html">Here </a>is one of them if you are interested.</p><h3>Conclusion</h3><p>As you can see, R helps us perform statistical analysis on important datasets quite easily. Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12670cd664d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/r-tutorial-analyzing-covid-19-data-12670cd664d6">R Tutorial: Analyzing COVID-19 Data</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[Reading Color Blindness Charts: Deep Learning and Computer Vision]]></title>
            <link>https://medium.com/data-science/reading-color-blindness-charts-deep-learning-and-computer-vision-a8c824dd71cd?source=rss-fe4b70c28b97------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8c824dd71cd</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[colorblind]]></category>
            <category><![CDATA[opencv]]></category>
            <dc:creator><![CDATA[Mykyta Solonko]]></dc:creator>
            <pubDate>Sun, 26 Jan 2020 04:11:49 GMT</pubDate>
            <atom:updated>2022-10-30T18:50:36.907Z</atom:updated>
            <content:encoded><![CDATA[<h4>Transforming data to make it compatible with a similar dataset</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hoILlr6J8MWPURMqgg1mSw.jpeg" /></figure><p>There are plenty of online tutorials where you can learn to train a neural network to classify handwritten digits using the <a href="https://en.wikipedia.org/wiki/MNIST_database">MNIST</a> dataset, or to tell the difference between cats and dogs. We, humans, are always very good at these tasks and can easily match or beat the performance of a trained model.</p><p>This is not always the case. In this project, I want to explore a task that I personally struggle with a lot. I have mild red-green color blindness. So, charts such as these have usually been difficult if not impossible for me to see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*TK103FjwMdEYJknXrGMhdA.png" /><figcaption>This is a 6 (I think?)</figcaption></figure><p>Is it possible for me to train a model to do this task for me, without me having to squint and inevitably get the question wrong either way?</p><p>At first glance, this task seems simple. We can take some images, split them into training and test sets, and then train a convolutional neural network. Except… there is no dataset. Online, I was able to find only 54 different images, which is insufficient for a training set, given that there are 9 classes (digits 1–9).</p><p>How can this be resolved? We still have the MNIST dataset that contains images of a single hand-written digit. We can use this dataset to train a neural network that excels at classifying individual digits. With some OpenCV transformations, we can get the color-blindness charts to look similar to the MNIST images, which look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*PLnZQ_75FH0xhIfY0qa7_A.png" /><figcaption>Handwritten 5</figcaption></figure><p>Let’s do it!</p><h3>Training Convolutional Neural Network on MNIST Dataset</h3><p>There are many <a href="https://machinelearningmastery.com/how-to-develop-a-convolutional-neural-network-from-scratch-for-mnist-handwritten-digit-classification/">tutorials</a> on this, but I will nonetheless give a high-level overview on how this is done.</p><p>First, we will need Tensorflow installed, which is available through pip. If you do not have it installed, run the following command in the terminal.</p><pre>pip install tensorflow</pre><p>Or if you have a GPU:</p><pre>pip install tensorflow-gpu</pre><p>Now we will create a mnist.py file and get our training data, which is built-in to tensorflow due to the MNIST dataset’s popularity:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0a0c8fa19395a3dc4ef858f4d2a4cae/href">https://medium.com/media/c0a0c8fa19395a3dc4ef858f4d2a4cae/href</a></iframe><p>Next, we will set up our Convolutional Neural Network. I will not go into detail about how these work internally, but there are many resources online to read more, such as <a href="https://www.datacamp.com/tutorial/convolutional-neural-networks-python">this one</a>. We will be using one Conv2D layer, followed by MaxPooling, and Dropout. Then, our 2D output is flattened and put through a Dense layer with 128 units, followed by our classification layer with 10 classes (number 0–9). The output will be a vector of a length 10 to indicate the prediction. For instance, a 2 will be predicted like this:</p><pre>[0, 0, 1, 0, 0, 0, 0, 0, 0, 0]</pre><p>since the 1 is in the 2nd index. Here is the model code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23cc9aa01a09df5e14fde2e111685444/href">https://medium.com/media/23cc9aa01a09df5e14fde2e111685444/href</a></iframe><p>Now, we compile the model, run it on the training data, evaluate it on the test data, and save the model as an .h5 file in our directory:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47edf40f2f51ce51121114401d03e89b/href">https://medium.com/media/47edf40f2f51ce51121114401d03e89b/href</a></iframe><p>When we run this code, we get a training accuracy of about 99% and test set accuracy of 98%:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*piKr4to53YfylvgMVAG5iw.png" /></figure><p>Not bad! Now, you should see a mnist.h5 file in your directory. Now, let’s move to the next step.</p><h3>OpenCV Chart Processing</h3><p>The next goal is to take the existing charts and transform them in such a way that they look as similar as possible to the MNIST data, which the model we saved is great at classifying. For this part, we will need a few more libraries:</p><pre>pip install opencv-python<br>pip install imutils<br>pip install numpy<br>pip install sklearn<br>pip install scikit-image</pre><p>Our goal a transformation like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*CljY_UXKbNFMYYRrjFMPsA.png" /></figure><p>After some experimentation, here is what processing we will need to do:</p><ol><li>Increase the contrast in order to make the color of the digit be more visible.</li><li>Apply median and Gaussian blurring to smooth out the small circles that we see in the original images.</li><li>Apply K-means color clustering to get consistent blobs of color.</li><li>Convert to grayscale</li><li>Apply thresholding (this one will be tricky) in order to get an image that only uses black and white.</li><li>More blurring and thresholding</li><li>Morphology open, close, erosion</li><li>Skeletonizing</li><li>Dilation</li></ol><p>Wow, that is a lot. Let’s get started with contrast. I copied a function from the internet that takes in an image and applies customized brightness and contrast transformations. I put this in a file ContrastBrightness.py and made it a class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3575177bfa3d0b671c4af57e8b8c46fa/href">https://medium.com/media/3575177bfa3d0b671c4af57e8b8c46fa/href</a></iframe><p>At a high level, increasing brightness adds values to the RGB channels of an image while increasing contrast multiplies the values by some constant. We will only use the contrast feature.</p><p>Another complex part of our algorithm is clustering. Again, I made a file Clusterer.py and put the necessary code into it that I got online:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fafc3b553f396fc6b3dfafb98562c55a/href">https://medium.com/media/fafc3b553f396fc6b3dfafb98562c55a/href</a></iframe><p>This code will take an image and a number as an input. That number K will determine how many color clusters we will use. You can read more about K-means clustering <a href="https://en.wikipedia.org/wiki/K-means_clustering">here</a>. Now, let’s make our last file main.py. We will start with imports:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20e91ee1fdf1d807e67fc270ab7c0870/href">https://medium.com/media/20e91ee1fdf1d807e67fc270ab7c0870/href</a></iframe><p>Notice that we are importing the two classes that we just created. Now, please download the images in the charts directory from <a href="https://github.com/msolonko/colorblindness_classification">my Github</a>.</p><p>These have all been sorted (with the help of individuals without color blindness) into appropriate folders.</p><p>Now, we will loop through all the images in our path and apply transformations 1–4. I commented my code pretty extensively.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ef9f29298977acec1e18c556fa946b8/href">https://medium.com/media/6ef9f29298977acec1e18c556fa946b8/href</a></iframe><p>Here is what some of those transformed images look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*FVwevlixYRE26XLIAfxwGw.png" /></figure><p>That is an obvious improvement. The digits are all clear, even to me. Two problems remain:</p><ol><li>They do not look hand-written and are too thick</li><li>They are not fully white on a black background</li></ol><p>So, we will threshold. However, due to the various coloring of the images, each needs a different threshold to work. We will automate the search for the perfect threshold. I noticed that a digit typically takes up 10–28% of the total image based on the number of pixels.</p><p>Thus, we will try different threshold values until we get percent white to be in the 10–28% range. First, we will define a function that tells us what percent of an input image is white. There are shorter ways to do this, but I want to show explicitly what this is doing. We are counting all pixels that have a value of 255 (with 255 meaning white and 0 meaning black).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/496d807975ec7bd573d6bab116c39d27/href">https://medium.com/media/496d807975ec7bd573d6bab116c39d27/href</a></iframe><p>Now, we will start at a threshold of 0 and works up to 255 in increments of 10 until we are in the 0.1–0.28 zone (this code goes in the for loop):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9b05d65695b80857cdda0b7708798a4/href">https://medium.com/media/a9b05d65695b80857cdda0b7708798a4/href</a></iframe><p>Awesome! The end is in sight. Now we get images like this (if we use the threshold we found):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*naVWEdw0YKQMEUpze-rZvg.png" /></figure><p>Most images look pretty good! However, some are problematic. It turns out that some digits are <em>darker </em>than the background, as you see with the 9 on the top right. Thus, thresholding makes them black, not white! The 0.1–0.28 zone is never reached.</p><p>We can check if our threshold was successful by the value of the variable. If the value of the threshold variable is 260, it means that the while loop ended without finding a perfect threshold. For those images, we will have a separate procedure.</p><p>Essentially, we will</p><ol><li>Invert the images to make the inside bright compared to the background</li><li>Convert to black and white</li><li>Create a circular mask to mask out the background (that went from black to white when we inverted).</li></ol><p>Here is the visual process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*-8upcDAz02YZOmQiB0CcWA.png" /></figure><p>The last step is the most difficult, so I commented it in my code. Here is our whole function for this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11615b4ba267f4817c7f83b9c743b938/href">https://medium.com/media/11615b4ba267f4817c7f83b9c743b938/href</a></iframe><p>We will adjust our code to use the new function and also do steps 6–7. These are all built-in OpenCV transformations, so nothing surprising here:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1200ebccbb56d02cc85f37ff18b39a7d/href">https://medium.com/media/1200ebccbb56d02cc85f37ff18b39a7d/href</a></iframe><p>Let’s see what the images look like!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*A5WPTRs9UsTSiSCxfW1IQQ.png" /></figure><p>Awesome! Clearly recognizable. Originally, we would expect the accuracy to be about 10% because the model output is of size 10 and its output would be essentially random since the original images looked nothing like the MNIST dataset that the model was trained on. With these transformed images, the model can certainly do better than random. If we stopped here, our accuracy would be about 63%, about 6X better than random! However, we can do a little bit more.</p><p>We will skeletonize and dilate our images. This will give us a consistent width and look more uniform overall. Let’s do it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c88d011062b8246dcaa5ca776944c079/href">https://medium.com/media/c88d011062b8246dcaa5ca776944c079/href</a></iframe><p>This code is the last snippet we put inside the big for loop. Here is what the results look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*hcvd6rAEfoj7bVvbX1rYcg.png" /></figure><p>They are a little uneven, but so is handwriting. These inputs should be no problem for the neural network. Now, we just reshape our list, load the model, and evaluate:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9db7a5c383d8bd496f37cd276653d5f/href">https://medium.com/media/c9db7a5c383d8bd496f37cd276653d5f/href</a></iframe><p>Put this code below your for loop. As a recap, we load our model, reshape the data, and print the accuracy after evaluating.</p><h3>Results</h3><p>After running the code, here is what gets printed for me:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*Jr_S92URjyqPtX1ltzSMyw.png" /></figure><p>Let’s take a look! We got an overall accuracy of…. 78%! That is 7–8 times better than random and a lot better than a person with medium to severe color blindness can do. This is outstanding!</p><p>If we look at our recall (ratio of correctly predicted positive observations to all observations in the actual class) for our digits, we see that we had great performance for 1–5 and 9. We had an okay performance for 8, and our neural network really struggled with 6s and 7s.</p><p>This approach clearly has limitations and the transformations I listed do not work for all possible color blindness images (there is actually one image in the dataset that it does not work with after the thresholding step). Try printing all the processed 9s and you will see that the thresholding step results in a ratio between 0.1 and .28 but that is because the background becomes partly white. I did not try to find a solution for this because this only affected one image.</p><h3>Conclusion</h3><p>I hope this tutorial has been informative on how a similar dataset can be used to make predictions on a different one. Also, I hope that this tutorial helps beginners become more comfortable with OpenCV, Tensorflow, and Python in general.</p><p>To view the complete code and download the images and model, check out <a href="https://github.com/msolonko/colorblindness_classification">my Github</a>.</p><h4>References</h4><p>[1] Data Science Stack Exchange (2020), <a href="https://datascience.stackexchange.com/questions/66377/how-to-use-mnist-dataset-to-make-predictions-on-similar-images-colorblindness-c">Link</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8c824dd71cd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/reading-color-blindness-charts-deep-learning-and-computer-vision-a8c824dd71cd">Reading Color Blindness Charts: Deep Learning and Computer Vision</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>
    </channel>
</rss>