<?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 Wilhem Kornhauser on Medium]]></title>
        <description><![CDATA[Stories by Wilhem Kornhauser on Medium]]></description>
        <link>https://medium.com/@wkornhauser?source=rss-5400136c5bd9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UIYbrK5Y5hw332jEFeErbQ.jpeg</url>
            <title>Stories by Wilhem Kornhauser on Medium</title>
            <link>https://medium.com/@wkornhauser?source=rss-5400136c5bd9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 09:27:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wkornhauser/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[Algorithms, Data Structures, and Data Science]]></title>
            <link>https://medium.com/codex/algorithms-data-structures-and-data-science-6a240db7355e?source=rss-5400136c5bd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a240db7355e</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Wilhem Kornhauser]]></dc:creator>
            <pubDate>Tue, 05 Jan 2021 15:20:48 GMT</pubDate>
            <atom:updated>2021-01-05T15:20:48.972Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AV7JZzB47JN3KROQ" /><figcaption>Photo by <a href="https://unsplash.com/@christopher__burns?utm_source=medium&amp;utm_medium=referral">Christopher Burns</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>One of the biggest challenges I have had during my self-study of machine learning is trying to run before I could walk. Towards the end of 2019, I read the book <em>AI Superpowers: China, Silicon Valley, and the New World Order</em> by Kai-Fu Lee, which catapulted me into the field of data science. With much enthusiasm, I started a hands-on machine learning course from Udemy. After about one month’s time, I was equipped with knowledge of many modern machine learning models and eagerly wanted to start numerous personal side-projects with this exciting technology. Unbeknownst to me, there was still much to learn.</p><h3>Learn From my Mistakes</h3><p>Before diving into the relevance of algorithms and data structures in data science, it is vital to understand their importance in computer science. If I were to describe their significance with a single word, it would be <strong>efficient</strong>.</p><p>Computers are fast, high-speed. Much faster than humans in many tasks. So fast that many people wrongly assume that they are infinitely fast. I know I mistakenly reached that conclusion as a freshman in university. Thinking back to my first programming class, the subject of “inefficient code” came up. Still, I never fully grasped the concept until learning about algorithms and data structures. In that class, we used C++ to write simple programs. On occasion, a TA would inform me that a particular syntax was inefficient. Still, I would immediately question this statement, thinking, “but it runs in milliseconds, how is this inefficient?”. <strong>Here is the catch: if you are writing 10 lines of code to parse a 50 character string once, you will not appreciate algorithms and data structures.</strong> In contrast, if you are working with a text file with millions (or more!) lines, and you do not know how to use algorithms and data structures properly, then your program will either take significantly longer to complete.</p><p>This pitfall became very apparent when I attempted to preprocess a dataset I had taken from online. I had found a CSV file with over 20 years of FOREX data for USDCAD pairs. Each line represented a single minute window of exchange prices. Doing some quick maths, one can determine that 20 years of FOREX data with a data point at every minute roughly equals 10,512,000 data points. That is, by all measures, an appreciable number of data points. It is not even close to being considered big data. Still, it is enough data to quickly bog down a processor during preprocessing if inefficient algorithms and data structures are utilized.</p><p>When reviewing my data, I noticed that many data points were missing. I thought to myself, “this is normal, and I can handle this no problem!”. The first statement is authentic; when practicing data science, one of the most time-consuming tasks is performing data preprocessing. The second statement could not have been further from the truth.</p><p>In my novice ignorance, I opened up a Spyder IDE, imported pandas, and loaded my entire csv text file into a pandas data frame. Then, I wrote a few lines of code involving nested for loops, which would insert into the data frame the missing data points with the values immediately preceding the missing data points as the best approximation. I reviewed my code to ensure proper algorithmic logic. When satisfied that it would run without errors, I started the script. <strong>Seven hours later</strong>, I stopped the script, unsure why it had not been completed on its own. I reviewed the IDE environment and realized that I had not gotten through 10% of the data frame. There was no way that I could afford to take over 70 hours to clean just a single dataset, but I did not even know what I was doing wrong! There was something fundamental missing from my skill set to allow me to complete this crucial step of data preprocessing.</p><h3>Algorithms and Data Structures</h3><p>Sometime mid-summer 2020, I was browsing Reddit and came across the following meme.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*YRxkTBMbQbS-S7b7MZL6sA.jpeg" /><figcaption>Image by Author using <a href="https://imgflip.com/">imgflip.com</a>, inspired by source <a href="https://www.kaggle.com/getting-started/177451">Kaggle</a></figcaption></figure><p>Ironically, this was not the first time that this meme would haunt me. About a week later, my girlfriend sent me the<em> exact same meme</em>. She is a computer engineering graduate from The University of Toronto and working as a software developer for a major telecommunications company in Canada. Despite the apparent humor of the meme, I was starting to realize that algorithms and data structures were a piece of the puzzle in my data science journey.</p><p>In my quest to better my skill set with data science and machine learning, I reached out to Graham Taylor, an associate professor at The University of Guelph. Taylor had learned under the renowned Geoffery Hinton at The University of Toronto. I told Dr. Taylor my story and asked for guidance on my journey. Dr. Taylor said to me that he often is asked about machine learning skills and resources and that of course, I want to make sure that I have the necessary pre-requisites. Specifically, linear algebra, calculus, probability and statistics, and algorithms and data structures (wow, precisely like the meme).</p><p>At the first opportunity possible, I enrolled in an online course to conquer the study of algorithms and data structures. I registered in the Stanford Online Algorithms Specialization on Coursera, taught by Tim Roughgarden, an associate professor of computer science at Standford University. The specialization consisted of four individual courses, covering both a broad and detailed range of subjects in algorithms and data structures. Not to be a Coursera schill, but if you are in the same boat I was, I highly recommend this specialization. Be warned though, to succeed you need both a high-level mathematical and programming background, and you will be lost without one.</p><p>Dr. Roughgarden did an excellent job teaching. The unanimous theme of the specialization is the guiding question, “<strong>can we do better?</strong>”. This principle is applicable whenever one is writing code, and data science is no exception.</p><p>To best illustrate the importance of algorithms and data structures, I have included the below video. This video demonstrates 24 different sorting algorithms, all running at the same rate. Notice how dramatically the completion times vary.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FBeoCbJPuvSE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DBeoCbJPuvSE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FBeoCbJPuvSE%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/10e5ecba83de5240be82dadb1faac0ac/href">https://medium.com/media/10e5ecba83de5240be82dadb1faac0ac/href</a></iframe><h3>Big-O Notation</h3><p>To understand algorithms and data structures, it is essential to comprehend runtime notation. Frequently, Big-O notation is used to describe an algorithm’s efficiency. If you are already familiar with this notation, the video below is not for you. Otherwise, I recommend that you review the video.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F__vX2sjlpXU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D__vX2sjlpXU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F__vX2sjlpXU%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/1dc2148583ba755f31505c105160dbb9/href">https://medium.com/media/1dc2148583ba755f31505c105160dbb9/href</a></iframe><h3>Algorithms and Data Structures in Data Science</h3><p>So why are algorithms and data structures important in the field of data science? I will list three reasons:</p><ol><li>You will inevitably run into scenarios where you will be unable to implement a program without proper knowledge of algorithms and data structures. Do not make the same mistake I did when trying to use a pandas data frame to preprocess my data. Since that first attempt at preprocessing more than 20 years of data, I have learned about a beautiful data structure is known as a hash table supporting O(1) insert and search times. Furthermore, hash tables can be easily implemented in Python through dictionaries (<em>all</em> dictionaries in Python are hash tables). Now when I try to achieve the exact same result, I can preprocess the data set in under a minute. That is literally more than 4200 times faster than my naïve implementation. This fact alone reinforces just how important a proper understanding of algorithms and data structures are.</li><li>It is a fundamental topic that employers expect you to know during technical interviews. A critical step in technical interviews is <strong>always </strong>using hash tables for inserts and searches because of their O(1) runtimes. Every single individual I know that is a professional in the computer science field has learned about algorithms and data structures at one point. It is the bread and butter of efficient programming. If you are serious about data science and machine learning, you need to be serious about algorithms and data structures.</li><li>Your programming abilities will increase dramatically. As I mentioned before, learning algorithms and data structures require good programming abilities. I know that my skills with Python grew tremendously when I was learning algorithms and data structures. I can not guarantee that you will become a professional developer. Still, you will be forced to utilized programming paradigms that you are likely unaware of.</li></ol><h3>Closing Thoughts</h3><p>The field of data science is both exciting and promising. IT technologies like machine learning hold the potential to revolutionize the world in the same way electricity did in the 19th century. It is easy to be swept up in this technology’s hype and rapidly race to a point where you are over your head without even realizing it. As with any science, a solid understanding of fundamentals is required to achieve mastery. A thorough education in algorithms and data structures takes you a step ahead of the curve, opening doors and opportunities you may not have even realized existed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a240db7355e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/algorithms-data-structures-and-data-science-6a240db7355e">Algorithms, Data Structures, and Data Science</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Measuring Success of Machine Learning Products]]></title>
            <link>https://medium.com/codex/failure-is-part-of-the-learning-process-7f84cb26077b?source=rss-5400136c5bd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f84cb26077b</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[product-design]]></category>
            <category><![CDATA[business]]></category>
            <dc:creator><![CDATA[Wilhem Kornhauser]]></dc:creator>
            <pubDate>Tue, 05 Jan 2021 14:24:54 GMT</pubDate>
            <atom:updated>2021-01-05T14:27:09.264Z</atom:updated>
            <content:encoded><![CDATA[<p>Failure is part of the learning process. Unfortunately, it frequents being part of the machine learning development process far too often. ML projects can be doomed from conception due to a misalignment between product metrics and model metrics. Today, many skilled individuals can create highly accurate models, and low modeling capabilities are not a common pitfall. Instead, there is a tendency for accurate models to be developed that are not useful for a product, thus failing to meet business objectives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XvX5H2x_urnYKNS6_PCUnA.jpeg" /><figcaption>Image by <a href="https://unsplash.com/@isaacmsmith">Isaac Smith</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><h3>Defining and Quantifying Success</h3><p>In defining success, it is crucial to consider the differences between <em>business performance</em> and <em>model performance</em>. The most straightforward way to put this is that business performance is a function of many variables, not just model performance. With poor model performance, business performance will be inadequate, but good model performance does not guarantee good business performance!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OPcacieSvFRSpESDyjPgFQ.jpeg" /><figcaption>Image by <a href="https://unsplash.com/@freetousesoundscom">Free To Use Sounds</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><h3>Business Performance</h3><p>To evaluate business performance, one must start with a product or feature goal. For example, increasing the revenue of an e-commerce site. Once this is defined, a <em>product metric</em> should be assigned to evaluate success. This metric needs to be separate from any model metrics, only quantifying the product’s success. Product metrics can vary, with metrics such as the number of users a feature attracts or the click-through rate (CTR) of recommendations, both representing valid examples.</p><p>At the end of the day (and fiscal period), product metrics are what matter. They represent the goals of the product. Any other metrics are to be considered tools available to optimize product metrics. Typically projects only aim to improve a single product metric, but their impact is frequently quantified concerning numerous metrics. Some of these include <em>guardrail metrics</em>, which represent metrics that are not to fall below a certain point. For example, an ML project can increase a product metric like the number of users while maintaining the stability of other metrics like average user session.</p><h3>Model Performance</h3><p>Measuring the effectiveness of an ML approach requires the tracking of model performance. Before the deployment of a product utilizing ML, it is not possible to quantify product metrics. During the building of the ML product, <em>offline metrics</em> or <em>model metrics</em> are useful for defining success. To consider an offline metric to be of quality, evaluating the metrics without exposing the ML model to users is required. Furthermore, a positive correlation between model metrics, product metrics, and business goals should exist.</p><p>Suppose you were developing a feature to offer users suggestions while typing queries to an online retail store. The success of this feature can be measured using CTR (product metric). To create these suggestions, a model that predicts the words a user will type and displays these predictions can be built. By measuring the word-level accuracy (calculating how often the model predicts the correct next set of words), the model’s performance can be defined. In this scenario, the model would be required to have extreme accuracy to increase the product’s CTR, as a single error in word prediction would render a suggestion useless.</p><p>A (better) approach would involve training a model that can take user input and perform classification into categories of your catalog, suggesting the top most likely predicted categories. Here, the number of categories in a catalog is significantly less than all the words in the English language, making this a much easier model metric to optimize. Moreover, the model only needs to correctly predict one category to generate a click.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XIHHzFuJl1yX4Eo5_j8FUg.jpeg" /><figcaption>Image by <a href="https://unsplash.com/@glencarrie">Glen Carrie</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><h3>Closing Remarks</h3><p>Business performance seems to get often lost in the hype of ML model performance, but it is always important to realize what metrics need to be optimized.</p><p>Beyond just business performance and model performance, other metrics for success are required. Considerations include model freshness and speed. Model freshness is an essential consideration as models age and data distributions change. Speed is always an important consideration with any software. Autonomous vehicles could never be achieved if it took even several seconds to process data and generate predictions.</p><p>For more on this topic, I highly recommend <em>Building Machine Learning Powered Applications </em>by Emmanuel Ameisen. It covers the skills necessary to design, build, and deploy applications powered by machine learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f84cb26077b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/failure-is-part-of-the-learning-process-7f84cb26077b">Measuring Success of Machine Learning Products</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Measuring Success of Machine Learning Products]]></title>
            <link>https://medium.com/data-science/measuring-success-ef3aff9c28e4?source=rss-5400136c5bd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef3aff9c28e4</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[product-design]]></category>
            <dc:creator><![CDATA[Wilhem Kornhauser]]></dc:creator>
            <pubDate>Mon, 04 Jan 2021 21:42:10 GMT</pubDate>
            <atom:updated>2021-01-04T23:12:52.676Z</atom:updated>
            <content:encoded><![CDATA[<h4>Business Performance vs Model Performance</h4><p>Failure is part of the learning process. Unfortunately, it frequents being part of the machine learning development process far too often. ML projects can be doomed from conception due to a misalignment between product metrics and model metrics. Today, there are many skilled individuals who can create highly accurate models, and poor modelling capabilities is not a common pitfall. Rather, there is a tendency for accurate models to be developed that are not useful for a product, thus failing to meet business objectives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XvX5H2x_urnYKNS6_PCUnA.jpeg" /><figcaption>Image by <a href="https://unsplash.com/@isaacmsmith">Isaac Smith</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><h3>Defining and Quantifying Success</h3><p>In defining success, it is important to consider the differences between <em>business performance</em> and <em>model performance</em>. The most simple way to put this is that business performance is a function of many variables, not just model performance. With poor model performance, business performance will be inadequate, but good model performance does not guarantee good business performance!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OPcacieSvFRSpESDyjPgFQ.jpeg" /><figcaption>Image by <a href="https://unsplash.com/@freetousesoundscom">Free To Use Sounds</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><h3>Business Performance</h3><p>To evaluate business performance, it is necessary to start with a product or feature goal. For example, increasing revenue of an e-commerce site. Once this is defined, a <em>product metric</em> should be assigned to evaluate success. This metric needs to be separate from any model metrics, only quantifying the product’s success. Product metrics can vary, with metrics such as number of users a feature attracts or the click-through rate (CTR) of recommendations both representing valid examples.</p><p>At the end of the day (and fiscal period), product metrics are what matter. They represent the goals of the product. Any other metrics are simply to be considered tools available to optimize product metrics. Typically projects only aim to improve a single product metric, but their impact is frequently quantified with respect to numerous metrics. Some of these include <em>guardrail metrics</em>, which represent metrics that are not to fall below a certain point. For example, an ML project can have the objective of increasing a product metric like number of users while maintaining the stability of other metrics like average user session.</p><h3>Model Performance</h3><p>Measuring the effectiveness of an ML approach requires the tracking of model performance. Prior to deployment of a product utilizing ML, it is not possible to quantify product metrics. During the building of the ML product, <em>offline metrics</em> or <em>model metrics</em> are useful for defining success. To consider an offline metric to be of quality, it should be evaluated without exposing the ML model to users. Furthermore, it should be highly correlated with product metrics and business goals.</p><p>Suppose you were developing a feature to offer suggestions to users while typing queries to an online retail store. The success of this feature can be measured using CTR (product metric). To create these suggestions, a model which predicts the words a user will type and displays these predictions can be built. By measuring the word-level accuracy (calculating how often the model predicts the correct next set of words), the performance of the model can be defined. In this scenario, the model would be required to have extreme accuracy to increase the product’s CTR, as a single error in word prediction would render a suggestion useless.</p><p>A (better) approach would involve training a model that can take user input and perform classification into categories of your catalog, suggesting the top most likely predicted categories. Here, the number of categories in a catalog is significantly less than all the words in the English language, making this a much easier model metric to optimize. Moreover, the model only needs to correctly predict one category to generate a click.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XIHHzFuJl1yX4Eo5_j8FUg.jpeg" /><figcaption>Image by <a href="https://unsplash.com/@glencarrie">Glen Carrie</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><h3>Closing Remarks</h3><p>Business performance seems to often get lost in the hype of ML model performance, but it is always important to realize what metrics need to be optimized.</p><p>Beyond just business performance and model performance, other metrics for success are required. Considerations include model freshness and speed. Model freshness is an important consideration as models age and data distributions change. Speed is always an important consideration with any software. Autonomous vehicles could never be achieved if it took even several seconds to process data and generate predictions.</p><p>For more on this topic, I highly recommend <em>Building Machine Learning Powered Applications </em>by Emmanuel Ameisen. It covers the skills necessary to design, build, and deploy applications powered by machine learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef3aff9c28e4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/measuring-success-ef3aff9c28e4">Measuring Success of Machine Learning Products</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[Algorithms, Data Structures, and Data Science]]></title>
            <link>https://medium.com/data-science/algorithms-data-structures-and-data-science-8d7a4e62758e?source=rss-5400136c5bd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d7a4e62758e</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[Wilhem Kornhauser]]></dc:creator>
            <pubDate>Wed, 30 Dec 2020 17:06:47 GMT</pubDate>
            <atom:updated>2021-01-02T19:58:16.183Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why should you care about algorithms and data structures as a data scientist?</h4><p>One of the biggest challenges I have had during my self study of machine learning is trying to run before I could walk. Towards the end of 2019 I read the book <em>AI Superpowers: China, Silicon Valley, and the New World Order</em> by Kai-Fu Lee, which catapulted me into the field of data science. With much enthusiasm, I started a hands-on machine learning course from Udemy. After about one months time, I was equipped with knowledge of many modern machine learning models, and eagerly wanted to start numerous personal side-projects with this exciting technology. Unbeknownst to me, there was still much to learn.</p><h3>Learn From my Mistakes</h3><p>Before diving into the relevance of algorithms and data structures in data science, it is important to understand their importance in computer science. If I were to describe their importance with a single word, it would be <strong>efficiency</strong>.</p><p>Computers are fast, very fast. Much faster than humans in many tasks. So fast that many people wrongly assume that they are infinitely fast. I know I wrongly reached that conclusion as a freshman in university. Thinking back to my first programming class, the subject of “inefficient code” came up, but I never fully grasped the concept until learning about algorithms and data structures. In that class, we used C++ to write simple programs. On occasion, a TA would inform me that a certain syntax was inefficient, but I would immediately question this statement, thinking “but it runs in milliseconds, how is this inefficient?”. <strong>Here is the catch: if you are writing 10 lines of code to parse a 50 character string once, then you will not be able to appreciate algorithms and data structures.</strong> In contrast, if you are working with a text file with millions (or more!) lines, and you do not know how to use algorithms and data structures properly, then your program will either take significantly longer to complete, or perhaps not even complete in your lifetime.</p><p>This pitfall became very apparent to me when I was attempting to do preprocessing on a dataset I had taken from online. I had found a csv file with over 20 years of FOREX data for USDCAD pairs. Each line represented a single minute window of exchange prices. Doing some quick maths, one can determine that 20 years of FOREX data with a data point at every minute roughly equals 10,512,000 data points. That is, by all measures, an appreciable number of data points. It is not even close to being considered big data, but it is enough data to quickly bog down a processor during preprocessing if inefficient algorithms and data structures are utilized.</p><p>When reviewing my data, I noticed that many data points were missing. I thought to myself “this is normal, and I can handle this no problem!”. The first statement is very true, when practicing data science, one of the most time consuming tasks is performing data preprocessing. The second statement, could not have been further from the truth.</p><p>In my novice ignorance, I opened up a Spyder IDE, imported pandas, and loaded my entire csv text file into a pandas dataframe. Then, I wrote a few lines of code, involving nested for loops, which would insert into the dataframe the missing data points with the values immediately preceding the missing data points as a best approximation. I reviewed my code to ensure proper algorithmic logic, and when satisfied that it would run without errors, I started the script. <strong>Seven hours later</strong> I stopped the script, unsure why it had not completed on its own. I reviewed the IDE environment, and realized that I had not even gotten through 10% of the dataframe. There was no way that I could afford to take in excess of 70 hours to clean just a single dataset, but I did not even know what I was doing wrong! There was something fundamental missing from my skill set to allow me to be able to complete this crucial step of data preprocessing.</p><h3>Algorithms and Data Structures</h3><p>Sometime mid summer 2020, I was browsing Reddit and came across the following meme.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*muVp--D-eN5otucYCq08Ow.jpeg" /><figcaption>Image by Author using <a href="https://imgflip.com/">https://imgflip.com/</a>, inspired by source <a href="https://www.kaggle.com/getting-started/177451">https://www.kaggle.com/getting-started/177451</a></figcaption></figure><p>Ironically, this was not the first time that this meme would haunt me. About a week later, my girlfriend sent me the<em> exact same meme</em>. She is an computer engineering graduate from The University of Toronto and working as a software developer for a major telecommunications company in Canada. Despite the obvious humor of the meme, I was starting to realize that algorithms and data structures were a piece of the puzzle in my data science journey.</p><p>In my quest to better my skill set with data science and machine learning, I reached out to Graham Taylor, an associate professor at The University of Guelph who had learned under the renowned Geoffery Hinton at The University of Toronto. I told Dr. Taylor my story, and asked for guidance on my journey. Dr. Taylor told me that he often is asked about machine learning skills and resources, and that of course I want to make sure that I have the necessary pre-requisites. Specifically, linear algebra, calculus, probability and statistics, and algorithms and data structures (wow, exactly like the meme).</p><p>At the first opportunity possible I enrolled in a online course to conquer the study of algorithms and data structures. I registered in the Stanford Online Algorithms Specialization on Coursera, taught by Tim Roughgarden, an associate professor of computer science at Standford University. The specialization consisted of four individual courses, covering both a broad and detailed range of subjects in algorithms and data structures. Not to be a Coursera schill, but if you are in the same boat I was, I highly recommend this specialization. Be warned though, to succeed you need both a high level mathematical and programming background, and you will be lost without.</p><p>Dr. Roughgarden did an excellent job teaching, and the unanimous theme of the specialization is the guiding question “<strong>can we do better?</strong>”. This principle is applicable whenever one is writing code, and data science is no exception.</p><p>To best illustrate the importance of algorithms and data structures, I have included the below video. This video demonstrates 24 different sorting algorithms, all running at the same rate. Notice how dramatically the completion times vary.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FBeoCbJPuvSE&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DBeoCbJPuvSE&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FBeoCbJPuvSE%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/b91d692bb2eb8e958bbdebb64791dca0/href">https://medium.com/media/b91d692bb2eb8e958bbdebb64791dca0/href</a></iframe><h3>Big-O Notation</h3><p>To understand algorithms and data structures, it is important to understand runtime notation. Frequently, Big-O notation is used to describe an algorithms efficiency. If you are already familiar with this notation, the video below is not for you. Otherwise, I recommend that you review the video.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F__vX2sjlpXU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D__vX2sjlpXU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F__vX2sjlpXU%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/f53aab147429358a76674f4da0cc4ce1/href">https://medium.com/media/f53aab147429358a76674f4da0cc4ce1/href</a></iframe><h3>Algorithms and Data Structures in Data Science</h3><p>So why are algorithms and data structures important in the field of data science? I will list three reasons:</p><ol><li>You will inevitably run into scenarios where you will be unable to implement a program without proper knowledge of algorithms and data structures. Do not make the same mistake I did when trying to use a pandas dataframe to preprocess my data. Since that first attempt at preprocessing more than 20 years of data, I have learned about a wonderful data structure known as a hash table which supports O(1) insert and search times. Furthermore, hash tables can be easily implemented in Python through dictionaries (<em>all</em> dictionaries in Python are hash tables). Now when I try to achieve the exact same result, I can preprocess the data set in under a minute. That is literally more than 4200 times faster than my naïve implementation. This fact alone reinforces just how important a proper understanding of algorithms and data structures are.</li><li>It is a fundamental topic that employers expect you to know during technical interviews. A key step in technical interviews is <strong>always </strong>using hash tables for inserts and searches because of their O(1) runtimes. Every single individual I know that is a professional in the computer science field has learned about algorithms and data structures at one point. It is the bread and butter of efficient programming. If you are serious about data science and machine learning, you need to be serious about algorithms and data structures.</li><li>Your programming abilities will increase dramatically. As I mentioned before, learning algorithms and data structures requires good programming abilities. I know personally that my skills with Python increased tremendously during the time when I was learning algorithms and data structures. I can not guarantee that you will become a professional developer, but you will be forced to utilized programming paradigms that you are likely unaware of.</li></ol><h3>Closing Thoughts</h3><p>The field of data science is both exciting and promising. It technologies like machine learning hold the potential to revolutionize the world in the same way electricity did in the 19th century. It is easy to be swept up in the hype of this technology, and rapidly race to a point where you are over your head without even realizing it. As with any science, a solid understanding of fundamentals is required to achieve mastery. A thorough education in algorithms and data structures takes you a step ahead of the curve, opening doors and opportunities you may not have even realized existed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d7a4e62758e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/algorithms-data-structures-and-data-science-8d7a4e62758e">Algorithms, Data Structures, and Data Science</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[Machine learning model deployment with fast.ai]]></title>
            <link>https://medium.com/analytics-vidhya/machine-learning-model-deployment-with-fast-ai-658cfde878d0?source=rss-5400136c5bd9------2</link>
            <guid isPermaLink="false">https://medium.com/p/658cfde878d0</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Wilhem Kornhauser]]></dc:creator>
            <pubDate>Tue, 22 Dec 2020 17:44:08 GMT</pubDate>
            <atom:updated>2021-01-04T17:01:28.873Z</atom:updated>
            <content:encoded><![CDATA[<p>Prior to COVID-19 turning the whole world upside down, I was eagerly developing my very first neural network project — a model that could take APPL stock data as features and predict short-term price fluctuations. The idea was simple; buy low, sell high.</p><p>After reviewing my test dataset results, I excitedly realized that this model <em>could </em>work. My enthusiasm was short lived however, as I was a senior chemical engineering major who had not practiced programming since my first year at university. In order to make something of this hot new technology, I would have my work cut out for me.</p><p>Fortune favors the bold, and I immediately began consulting my network to learn as much as possible to turn this novel program written in Python on my PC into something more. As luck would have it, my roommate and friend of several years was a software engineering major who I (naively) believed could answer all my questions, especially the one most prominent in my mind: <strong>how do I turn a model developed in my Python IDE into a working piece of software that can be used in the “real” world?</strong></p><p>I cannot recall the exact answer I received, probably because so much of the terminology flew right over my head. Unshaken by this, I have taken much of my free time over the last year teaching myself how to answer this question, among many more that are associated with utilizing this technology.</p><h3>Binary Serialization</h3><p>Before delving into binary serialization, one would do well to understand binary numbers. Simply put, binary often refers to the binary number system. In mathematics and computers, a binary number is a number expressed in the base-2 numeral system. “Normal” numbers which you are probably most used to are expressed in base-10 numeral system. Below, I have included a quick video from one of my favorite online teachers who can illustrate all of this much better than I could hope to.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.khanacademy.org%2Fembed_video%3Fv%3DH4BstqvgBow&amp;display_name=Khan+Academy&amp;url=https%3A%2F%2Fwww.khanacademy.org%2Fmath%2Falgebra-home%2Falg-intro-to-algebra%2Falgebra-alternate-number-bases%2Fv%2Fdecimal-to-binary&amp;image=https%3A%2F%2Fimg.youtube.com%2Fvi%2FH4BstqvgBow%2F0.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=khanacademy" width="853" height="520" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c995f07b763b42bb2437b2b79f555d9/href">https://medium.com/media/7c995f07b763b42bb2437b2b79f555d9/href</a></iframe><p>Now, what binary serialization constitutes is a method of converting “objects” (such as a trained machine learning model) into binary information. So much like how you can convert the number seven into binary representation and vice versa, you can take an object such as a computer program and convert it into binary format.</p><p>How is all of this relevant though? Your model can be imagined as a very complex computer program. Through binary serialization you can “save” the state of the model to a file of 1’s and 0&#39;s, and deserialize it back to the same complex model when required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*s7pkIuD7jO-yGsQkE13osg.png" /></figure><p>Taking this down a step, imagine you have written a simple program, like this hello_world.py file containing the following lines of code:</p><p>print(‘Hello world!’)</p><p>Now imagine that by performing binary serialization you end up with the following binary chain:</p><p>101010010101010001010010101001010101001010010101010000101001</p><p>These 1’s and 0’s don’t mean anything to you, but a computer can take them and turn them back into the hello_world.py file that when called will print “Hello world!”.</p><p>Suppose that instead of serializing a program that prints out a string, that the program runs a very simple linear regression model:</p><p>slope = 1.5<br>y_intercept = 4<br>y_pred = input_value * slope + y_intercept<br>print(y_pred)</p><p>In order to run this model, the input_value corresponding to x is required, much like an input vector for a neural network. Upon reserialization, this program could be given any arbitrary input_value and it would make a prediction.</p><p>A neural network model is an object in a program, and not the program itself. Regardless, this is not a challenge, as it is effortless to serialize a model when using the right code.</p><h3>Deployment with fast.ai library</h3><p>Below, I am going to illustrate just how easy it is to perform the serialization of neural network model objects with the fast.ai library in Python.</p><p>As this is not a tutorial on creating neural network models, I will skip over the development of a functional model in using fast.ai. Below, the performance analysis of a model given the name “learn” is found. It is a CNN model which performs classification on images of bears.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*_s5OQUX11f04xHVeBUWnEw.png" /></figure><p>From this point, all that is required to serialize the model is one simple line of code:</p><p>learn.export()</p><p>The .export() method creates a serialized file called “export.pkl” (pkl pronounced as “pickle”).</p><p>This is the file that is required wherever you wish to deploy your application. In order to utilize the model, the file is deserialized back into an object, and given input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*o5QTYohuGsHgEfWvxIwlQg.png" /></figure><p>From a very basic, fundamental perspective, that is all there is to it! Now, to put this model into production is a very different story, requiring a server to host the model and a data pipeline to provide input data in pseudo real time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=658cfde878d0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/machine-learning-model-deployment-with-fast-ai-658cfde878d0">Machine learning model deployment with fast.ai</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>