<?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 Samy TAFASCA on Medium]]></title>
        <description><![CDATA[Stories by Samy TAFASCA on Medium]]></description>
        <link>https://medium.com/@samy.tafasca?source=rss-cfb7b85a39------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*K0ittHDASHjZi78gdHZp6Q.png</url>
            <title>Stories by Samy TAFASCA on Medium</title>
            <link>https://medium.com/@samy.tafasca?source=rss-cfb7b85a39------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 05:16:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@samy.tafasca/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[Multi-View Image Classification]]></title>
            <link>https://medium.com/data-science/multi-view-image-classification-427c69720f30?source=rss-cfb7b85a39------2</link>
            <guid isPermaLink="false">https://medium.com/p/427c69720f30</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[convolution-neural-net]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[feature-extraction]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Samy TAFASCA]]></dc:creator>
            <pubDate>Tue, 24 Dec 2019 05:14:49 GMT</pubDate>
            <atom:updated>2021-07-12T02:14:36.351Z</atom:updated>
            <content:encoded><![CDATA[<h4>From Logistic Regression to Multi-View Convolutional Neural Networks (MVCNN)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WbsyIA1_VBsXGD-zKuyXzQ.png" /><figcaption>Vintage Car Design. Credit © Publicdomainphotos | <a href="https://www.stockfreeimages.com/121708322/Motor-Vehicle-Car-Automotive-Design-Vintage-Car.html#">Link</a></figcaption></figure><h3>Introduction</h3><p>Not long ago, I took part in a machine learning hackathon hosted by Daimler-Benz. The problem we were presented with was rather interesting and not so common. So I decided to write an article about it, in case my approach(es) can help someone else faced with a similar task.</p><p>In the first chapter of this article, I will try to present my winning approach, walk you through my thought process, justify some design choices and elaborate on some concepts of interest. The second chapter, on the other hand, will be dedicated to a more sophisticated neural network based solution that is inherently adapted to this kind of problem. At the bottom of the page, you can find the link to my Github repository where I share the code to support the information presented in this post.</p><p>The problem we had to solve was to classify 3D models of Car Plugs in one of the five categories available, based on 2D visual information. Solving this task is of great value, especially in the context of autonomous planning of assembly processes for car manufacturing.</p><p>The most interesting aspect of the problem was the availability of 8 images for each Car Plug, 6 of which correspond to orthographic projections of the object (i.e. different views : top, bottom, front, rear, left and right) while the 2 others are random isometric projections. Figure 1 below shows an example of orthographic projections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*7u8P01ZdQavM-j0PpUZRPQ.png" /><figcaption>Figure 1 : Orthographic Projections.</figcaption></figure><h3>The Challenges</h3><p>There were three main challenges in this contest, and scoring well rested on identifying these obstacles and addressing them properly. The first of which, and probably the most obvious one, is a case of class imbalance where two classes are a lot less common in the dataset than the three others. It was important to take this into account, because the performance metric used in the competition was an extremely uneven weighted accuracy that factors in the distribution of the classes (i.e. rare classes are comparatively more important to classify correctly, sometimes by a factor of 80). The second challenge was that we had a timeframe of five hours to code everything up, without access to the cloud or any other means of accelerated computing (unless our personal laptops came equipped with Nvidia GPUs, which most weren’t). Lastly, the availability of multiple images for each object to classify posed the question of how to combine the visual information gathered from all 8 images in order to make a well informed prediction. This last challenge is the main motivation behind this post.</p><p>For the problem of class imbalance, resampling techniques were not a good option. Indeed, downsampling was practically impossible as we only had 833 Car Plugs in total (totaling 833x8 = 6664 images) and the rare classes had a very low number of samples. Furthermore, using data augmentation, though technically possible, did not seem like a good idea for me, simply because orthographic projections that produced the image views are a type of engineering drawing with a strict set of rules. Consequently, applying any sort of geometric transformation would result in images that do not belong to the original distribution of the data : using those for training is basically like pushing your model to learn how to predict images that it will never face, thus unnecessarily increasing the complexity of the problem. It is also worth noting that colors have no meaning in our images. To get a better sense of this, Figure 2 below provides an example of the different raw images of a Car Plug.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GkikFTx6UBIwkW01WF94Vw.png" /><figcaption>Figure 2 : Different views of a Car Plug (code name anonymized)</figcaption></figure><p>The way I decided to address the class imbalance problem is through Cost-Sensitive Learning, which basically means modifying the cost function of the machine learning algorithm by introducing a set of weights, to assign heavier penalties for mistakes that occur in “important” classes. This change helps to steer model training towards making less of those costly mistakes at the expense of potentially making more of the “cheaper” mistakes. To illustrate this point further, imagine we have 50 data points, 49 belonging to class A and 1 belonging to class B. For the sake of simplicity, we also assume the 0–1 loss (0 for a correct prediction, 1 otherwise) instead of the prevalent cross-entropy loss. Under normal circumstances, where the weights of all the classes are 1, the model will try to learn how to predict most of the data points correctly, irrespective of their class. But if we assume that misclassifying a sample of class B bears x100 the cost of that of class A, and we modify our cost function to take this into account, then the model will end-up choosing to classify that one data point of class B correctly, even if it meant failing in the prediction of all other 49, because that is the setting that minimizes the overall cost: 49*1 + 0*100= 49. Instead, if we made a mistake in the class B data point, and we got all other class A samples right, the cost would be: 49*0 + 1*100 = 100 which is still much higher than the previous case. Using cost-sensitive learning in practice is as simple as passing in a weight dictionary to the algorithm constructor (those that support it at least).</p><p>For the time constraint and absence of suitable computational resources, I decided to stay away from any neural network-based approaches, simply because it would take too much time to configure properly and train on a CPU. Instead, I opted for a more traditional computer vision solution, combining popular hand-engineered feature extractors with classical machine learning algorithms. And this, folks, is the tale of how a Logistic Regression won the 1st prize in a computer vision hackathon.</p><p>First, we will introduce the approach I used during the hackathon. Then, we will present a potentially better alternative based on a neural network architecture that can inherently handle the multi-view problem. I had thought of this second solution as well during the contest, but I knew I wouldn’t be able to implement it given the time and resource restrictions. However, I tried it afterwards, and it provided better results as expected.</p><h3>Image Processing</h3><p>As we can see in Figure 2, there are a couple of issues we need to deal with before feeding these images or their vector representations to any machine learning algorithm. First, we need to get rid of the unnecessary visual artifacts on the right and top sides (search bar, menu, etc.). Second, we need to get rid of the shades of gray in the background which should speed up the training significantly by decreasing noise levels in the data.</p><p>It turns out, we can do both of these things using a simple process: we first detect edges using the <strong>Canny Edge Detector</strong>, then we apply two successive morphological operations: <strong>Dilation</strong> to make the edges larger, and connect the parts that got disconnected after edge detection, then we use <strong>Erosion</strong> to thin the edges back to normal (a dilation followed by an erosion is usually called a <strong>Closing</strong>, and is used to fill holes that are smaller than the size of the kernel of those operations). Afterward, it is just a matter of finding all the contours and keeping the largest one, which will correspond to the Car Plug in the middle. This way, we also discard all the extra artifacts around the borders. Figure 3 below shows images of a Car Plug before and after this process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezxBmM5EIKgbEnh1QmKA2g.png" /><figcaption>Figure 3 : Preprocessing of images : Canny edge detection followed by two morphological operations (Dilation and Erosion), followed by a contour detection to isolate the object in the middle.</figcaption></figure><p>At this point, we may be thinking since color has no meaningful value, we might as well convert these images into grayscale. In the first approach based on classical machine learning algorithms, we will do just that. But for the following neural network-based one, we keep the 3 channels since we will make use of transfer learning.</p><h3>Approach 1: Feature Extraction &amp; Machine Learning</h3><p>Before the era of deep learning, researchers used to manually craft feature extractors to characterize images. But what do we mean exactly by a feature extractor? In essence, it is a function that extracts a numeric representation of an image or a part of it and is designed to capture some of its distinguishing characteristics. Imagine we had an RGB image, consisting of three 2D matrices for each of the color channels with values between 0 and 255. We could quantize each of these matrices, into say 4 bins (0–63, 64–127, 128–191, 192–255), where each bin contains the pixel values that are within the associated range. This way, we can represent a 2D matrix with a vector of 4 numeric values (x_1, x_2, x_3, x_4) where each x_k is the number of values in the matrix, that fall within bin number k. We can repeat this process for the 3 channels of the RGB image, and after concatenation, we would end-up with a vector of size 12 (4 bins * 3 channels) representing this image. We just created a simple feature extractor that captures color information of an image. Although simple in nature, you can actually use such technique for tasks where color is the most informative factor. Figure 4 shows this feature extractor in action. Notice how the higher bins of each image’s dominant color are more distinguished in the feature vector. This representation definitely captures the differences between the three images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tBpYZXY1D---OZgHWqooCA.png" /><figcaption>Figure 4 : Example of a color feature extractor.</figcaption></figure><p>The academic community came up with a variety of manually designed feature extractors for different purposes over the years. A few important ones are HOG (Histogram of Oriented Gradients), SIFT (Scale Invariant Feature Transform), SURF (Speeded-Up Robust Features), LBP (Local Binary Patterns) etc. The main focus in the design process of these extractors, is to ensure robustness to certain properties of the images : scale, illumination, partial occlusion, rotation, distortion etc. These methods were a central pillar in traditional computer vision and lasted until the advent of deep learning, where they were essentially replaced by neural networks that can learn their own feature extraction mechanism in relation to the task they need to solve in an end-to-end manner. Unsurprisingly, this helped them yield superior results overall.</p><p>Alright, enough chit-chat! So how can we use these feature extractors to solve our problem? First, we will discuss how they were traditionally used to solve standard image classification problems, then we shall present how I adapted this process to the multi-view task.</p><p>Most Feature Extractors operate by first detecting key points of interest in an image, then producing a vector description for each key point. The descriptors are usually numeric vectors of a fixed size.</p><p>Descriptors from all images are collected, and then clustered to come up with a set of prototypes (i.e. centroids) that act as a “Vocabulary of Visual Words”. Then, we perform image quantization: we find the visual words in each image, and create the count feature vector, similar to how we would do it in the Bag Of Words approach typically encountered in text classification tasks. The steps of the process are detailed next :</p><ol><li>Extract all features from all “training” images (potentially many features per image), after converting them to grayscale, into a matrix of shape FxM where F is the number of features found and M is the dimension of the feature extractor (typically 64 or 128).</li><li>Cluster the FxM matrix using a clustering algorithm (e.g. K-means) where K, the number of clusters, will represent our vocabulary of visual words found in the entire dataset. Each cluster is then a visual word.</li><li>For each image, extract all the features, predict their clusters, and count how many features fall under each cluster. In other words, we count the occurrence of each visual word of the vocabulary (also called codebook) in the image. The result is a feature vector of size (1, K) representing the image. Applied to all the images in the dataset, we end up with a matrix of shape (N, K) where N is the number of images and K is the size of the vocabulary (i.e. number of clusters). In other words, a matrix where rows represent our images (data points) and columns represent the attributes or features. Each cell of this matrix represents the number of features found in the row image, that belong to the column cluster.</li><li>Use any classical machine learning algorithm on this matrix for classification: Logistic Regression, SVM, Random Forest, MLP, etc. That said, tree-based methods should be avoided in such situations because the problem is likely linear as it is the case in most text classification tasks.</li></ol><p>Because a picture is worth a thousand words, let us further explain this process through a simple flow diagram. Notice the keypoints detected (colored circles) on the grayscaled images after Step 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2JBbd4VT4dlTnIY8ubin-A.png" /><figcaption>Figure 5 : Flow diagram of the process of converting a set of images into a feature matrix where each row is an image and each column is an attribute or feature.</figcaption></figure><p>Armed with this knowledge, we can come up with a way to adapt this approach to our multi-view classification problem. The change we need to introduce is actually very straightforward, and happens at step 3: Instead of extracting features from an image and turning them into a bag of words feature vector, we will extract features from all 8 images, then turn them into a single feature vector representing the Car Plug. If we were to apply the same approach to a multi-view text classification task (where a concept consisting of multiple texts needs to be classified), this would amount to combining the words found in all the texts related to the given concept, and then building the word occurrence feature vector. Figure 6 visualizes the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v766rJmAba7qxiE0VmUGCg.png" /><figcaption>Figure 6 : Combining features extracted from all 8 view images into a single feature vector for the Car Plug.</figcaption></figure><p>Alright, now let us talk about some practicalities. Most of my decisions were made in an effort to optimize for both time and performance. In terms of feature extractors, SIFT is a pretty solid choice, but I actually used SURF which is basically a faster version of SIFT with relatively similar performance. For the dimension of SURF features, I chose 64 instead of 128 mainly to speed-up any training further down the line. I expect 128 to provide slightly better performance though. The resulting matrix had about 800K features of size 64. Choosing the number of clusters K in K-means was the next important decision. This is because K represents the number of visual words that will make up the columns of the final feature matrix. Oftentimes in such situations, the higher the value the better, but the law of diminishing returns applies, and past a certain point, the marginal improvement will not be worth the complexity increase. In my case, I opted for K=200, but values up to 800 are standard and should be experimented with. After this point, I just created the final feature matrix of size 833x200 (number of car plugs x number of clusters). Figure 7 shows two examples of feature vectors and one randomly selected image view for each plug.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nfeuznojY67cJvk6pzs2Tg.png" /><figcaption>Figure 7 : Two examples of key-point detection on a single view and the final feature vector of the associated Car Plug.</figcaption></figure><p>After training a Logistic Regression model, I ended up with around 87% of the weighted accuracy on average (the unweighted accuracy is easily in the 90–95% range). This is a pretty decent score, but can we do better? We can definitely try!</p><h3>Approach 2: Multi-View Convolutional Neural Networks</h3><p>This section is devoted to a custom neural network architecture to handle the multi-view problem. If we step back and take a second to think about the problem, how would we use a neural network to map our inputs to their class? Well, in a standard image classification problem, we’d select the base of a popular CNN architecture (ResNet, Inception, VGG, etc.) as a feature extractor, then add a classifier block on top of it, consisting of one or multiple dense layers as a form of transfer learning. If we tried to use a similar principle in our multi-view image task, we could imagine creating the base block of the network (feature extractor) multiple times, one for each image view. This way, we extract features from all of the 8 images separately using transfer learning. However, we will still be left with the same question we had before: instead of having to combine the information from the images at the beginning, we delayed the matter, and now we have to combine the information from multiple sets of feature maps (i.e. the feature maps representing each view produced by the base CNNs). One way to deal with this problem is to stack those feature maps together. For example, if each view’s feature maps had a shape of KxKxC, we could stack the 8 of them along the dimension of channels into one big set of feature maps of shape KxKx8C. Figure 8 illustrates this process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eF8RdwDVN5X2oWbh-Upfew.png" /><figcaption>Figure 8 : Combining views’ features maps by stacking them across the channel dimension.</figcaption></figure><p>The problem with this approach, however we choose to stack, is that it assumes there is an order to the image views, when in fact there isn’t one. If we stack the feature maps of the top view first, and bottom view last, then we are expected to do the same thing for each and every Car Plug. However, there is no reference specifying what is top for a Car Plug and what is bottom, we can consider any view to be any side. Or said otherwise, if we take two Car Plugs, and one view of the first one, there is no way to find the “equivalent” view in the second Car Plug. Thus, any assumption based on order should be avoided.</p><p>We are left with a second option, to find an operation that combines information from multiple values into one. In turns out, in CNNs there is one such function, and we call it Pooling. We could use some form of Pooling across the dimension of Views, to combine 8 sets of feature maps into one of the same shape, thereby combining information from all image views. This is all good and well, but it’s just a theoretical idea so far, is there any evidence that this can actually work ? Well, one such proof can be found in text classification, where we combine word embeddings of every word in a text into a single embedding by taking the average of all embeddings for example. We are trying to do something similar for our image views here. But perhaps, a better proof would be to find a paper that attempted such approach and that provides experimental results supporting it. A quick google search will reveal that there is one such paper (not the only one though), and it’s conveniently called : Multi-View Convolutional Neural Networks for 3D Shape Recognition. Figure 9 shows the architecture proposed in the paper, which is almost exactly what we explained above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uyK6DmBr1OgrPYz-kKE0wQ.png" /><figcaption>Figure 9 : Each object view is fed to the same CNN1 base, then we apply a pooling operation across the view dimension. The pooled view is then fed into a second CNN2 before being classified. The authors use the second CNN in order to learn a compact representation for the 3D shape, which they use for both classification and retrieval. For a simple classification, we can do away with it [1].</figcaption></figure><p>I implemented this MVCNN architecture in PyTorch and used a <em>ResNet34 Base</em> for the CNN1. After an <em>Average View Pooling</em> layer, I added a block on top, consisting of a series of <em>Dense</em> layers and <em>Dropout</em> regularization which I call the <em>Classifier Block</em>. For training, I initially fixed the base CNN1 and only trained the <em>Classifier Block</em>: this is typically called <strong>feature extraction in transfer learning</strong>. Then, I unfroze all the weights in the entire network, reduced the learning rate to a very low value, and trained the whole MVCNN end-to-end: this is referred to as <strong>fine-tuning in transfer learning</strong>. Ultimately, my weighted accuracy was hitting the 98% mark … pretty impressive, huh? Not so much actually. Aside from the weird performance metric and class imbalance, high scores should be expected because this task is arguably not very challenging for machine learning.</p><p>Yeah, yeah I know you’re probably here just for the code, and I’m happy to oblige! You will find everything you need in this github repo: <a href="https://github.com/SAMY-ER/Multi-View-Image-Classification">code</a>. The notebook is well commented, but unfortunately, I cannot share the data. If you’re keen on experimenting with the techniques proposed here, and you don’t have a proper dataset, think of using the benchmark for multi-view image classification: <a href="https://modelnet.cs.princeton.edu/">ModelNet40</a>. If you’re more interested in the first approach, any normal image classification dataset would do.</p><p>That’s it for me folks, I hope you learned a thing or two. Don’t hesitate to come back if you enjoyed the content, I’ll be pushing more articles soon.</p><p>Until then, sayonara ~</p><h3>References</h3><p>[1] Su, Hang, et al. “Multi-view convolutional neural networks for 3d shape recognition.” <em>Proceedings of the IEEE international conference on computer vision</em>. 2015.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=427c69720f30" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/multi-view-image-classification-427c69720f30">Multi-View Image Classification</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[Data Science : A Tour Of Prerequisites]]></title>
            <link>https://medium.com/data-science/data-science-a-tour-of-prerequisites-7738c7c900aa?source=rss-cfb7b85a39------2</link>
            <guid isPermaLink="false">https://medium.com/p/7738c7c900aa</guid>
            <category><![CDATA[university]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[resources]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Samy TAFASCA]]></dc:creator>
            <pubDate>Sun, 15 Sep 2019 22:00:05 GMT</pubDate>
            <atom:updated>2019-09-22T21:55:40.256Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Science : A Tour Of Prerequisites</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JLJKcYOp2OTLap0LdwvjDg.png" /></figure><h3>INTRODUCTION</h3><p>Data Science has known a massive surge of attention ever since the publication of that article in the Harvard Business Review back in 2012. But beyond the vain media portrayals, the field has actually shown an enormous potential for companies with the right skillset, resources and infrastructure or those willing to invest in order to acquire them. As a result, many older practitioners with relevant experiences shifted careers while younger students redirected themselves hoping to make it in the Data and Analytics job market after graduation. But the question most of these aspiring data scientists face at the start of their journey is : How do you actually get started ?</p><p>It can feel overwhelming to approach a vast and highly technical field such as Data Science. Thus, this document is an effort to provide interested parties with general information regarding the subject as well as guide them through the process of acquiring the prerequisite knowledge prior to diving into Data Science itself. Many individuals make the mistake of jumping right into the topic without the necessary background knowledge, only to end up frustrated with the difficulty soon afterwards and lacking the motivation to keep going further. Therefore, it is imperative to take the time to review the few required modules first in order to ensure subsequent data science concepts are intelligible and easier to digest.</p><p>It is worth noting that this document is not meant to teach you Data Science, nor is it meant to teach you the prerequisites of it. Instead, this should be seen as a reference article where I gather relevant resources I found useful over the course of my experience and describe each one of them to explain why you might need them. As such, it is a reflexion of my own personal experience, and is by no means “the right path” to mastering data science. However, what I will be sharing here seemed to have helped guide many in the past, and I wanted to make it available to everyone out there who might benefit from it as well. The point of this piece is to help guide you through your initial learning phase and prevent you from wasting time filtering the plethora of existing resources on the subject.</p><h3>ABOUT ME</h3><p>Before moving further, I thought I should start by sharing some information about myself, my experience and why I might know a thing or two that can be of help to you. But if you’re only here to get your answer on how to start, then feel free to skip this section.</p><p>From an academic perspective, my Bachelor studies were focused on theoretical Maths while my first Master’s degree (otherwise known as Engineer’s Degree in France) was in Telecommunications. By the end of it, I accidentally ended up doing an internship in Data Science, and that’s how everything started. At that point, I had already decided what I wanted to do with my professional career moving forward. The only question that needed answering is how to get there.</p><p>After graduating with a masters in telecommunications, I decided to switch careers. Bold move you may think, and you’re definitely right. But hey, what is life without some risk ?</p><p>Against the advice of all my friends and relatives, instead of looking for a Telco related role I was qualified for, I took several months off, and worked daily on acquiring the necessary knowledge in Data Science to be employable. The good thing was that I had a good and relevant postgraduate degree and most of the background knowledge I needed to make the transition, but I still had a lot of work to do. Six months and dozens of rejections later, I managed to land a few jobs offers, all related to Data Science. Hard work does pay off, huh !</p><p>Fast forward about a year and a half, I decided to go for another move : I was set on going back to University to complete a proper master’s degree in Data Science. You are probably wondering why, after all I already had the title and some experience in the industry. There are a lot of reasons that motivated this decision, but for the sake of this article, let’s just say I was hungry for more knowledge. And with that, I moved to London to join the MSc Data Science program at City, University of London. At the time of this article, I’m on the verge of completing this masters.</p><p>The point I’m trying to make is that I’ve done both, I know what it’s like to start from scratch, alone behind a computer for months, and somehow find the motivation to keep going. And I also know what it’s like to do a proper university program where you find yourself in a collaborative learning environment with your peers.</p><p>With this in mind, let’s actually get to the core of the article, shall we ?</p><h3>DATA SCIENCE</h3><p>First, let us attempt to define Data Science in order to understand where the following information fits into the bigger picture.</p><p>It is actually very difficult to come up with a unique definition for the term. Today, it is being used in a variety of contexts, to describe seemingly different roles and tasks. However, there are a few common factors between all these positions, which we can use to provide a general definition that applies to most situations. These common factors are Data, Problem Solving and Business Value. Data Science can then be thought of as using data as a raw material, combined with analytical thinking and specific tools, in order to solve business problems thereby generating commercial value. The nuances in the definition are mainly due to the context of the work and the specific tools and knowledge used to turn data into business value. For example, some practitioners could be using BI tools and Excel spreadsheets to generate reports while others might resort to a full-fledged programming language to incorporate machine learning into their processes. Some might argue that the first category is not really Data Science, and I personally agree with that statement, but in many companies, people with Data Science titles are doing that very exact work.</p><p>Another interesting point that is mostly overlooked by the community is the word Science in Data Science. Fundamentally, Data Science is about intellectual curiosity and the scientific process. The analyst starts by asking a question of interest, formulates a hypothesis, then gathers the necessary data to be analyzed or modeled in order to support or reject said hypothesis. Naturally, rigor and attention to details are of great importance here. This statement follows from the fact that it’s extremely easy to obtain results by applying data science methods. Despite what many think, the main difficulty in Data Science is not the sheer body of knowledge that is required, or the number of algorithms one needs to know, or even the programming languages to be mastered. Instead, the main challenge is making sure methods are used appropriately, results are validated and then interpreted correctly before being communicated to stake-holders using intuitive language.</p><p>Now that the definition is out of the way, let’s move on to the next section to discuss the requirements.</p><h3>LEVELS OF UNDERSTANDING</h3><p>Throughout my experience learning about data science topics alone or in university, I observed a few trends regarding the nature of resources meant to teach a new concept to a given audience. There are two fundamental perspectives based on which content can be delivered : Theoretical and Applied. A book, an article, a university course or any other educational medium will likely focus on one of these two aspects. In Data Science, these two levels of understanding can further be decomposed into sub-groups. Let us first present them, then I will explain and illustrate each point with an example to drive the point home.</p><p>Theoretical content has two levels, with the second building on top of the first : Formulation and Mathematical Derivation. The formulation provides the steps an algorithm needs to execute along with any necessary equations where applicable, the formula of the solution if you will. The mathematical derivation, as the name suggests, derives a solution starting from a problem statement and potentially some hypotheses. This can include proofs and explanations about the origins of the methods and their link to other adjacent subjects.</p><p>Let us give a simple example using the algorithm Linear Regression, which fits a line (or hyperplane in higher dimensions) to a dataset comprised of pairs ( <strong><em>x</em></strong>, <em>y</em>) where <strong><em>x</em></strong> is a vector of input data and <em>y</em> is the outcome (do not worry if you don’t understand some or all of these terms). The mathematical formulation of Linear Regression is comprised of two elements. First, there is the general equation of the line, which represents the set of all the lines from which we need to choose, and can be written as <em>y</em> = ∑ <em>βi xi </em>+ <em>β</em>0 where <strong><em>β </em></strong>= (<em>β</em>0, <em>β</em>1, . . . . , <em>βn</em>) are the parameters of the line/hyperplane. Then, there is the formula of the solution to the problem, which represents the values of the parameters reflecting the specific line that best fits our data (for now let us put aside what “best fits the data” actually means). The solution is written as follows <strong><em>β</em></strong> = (<strong>X^</strong>⊤<strong>X</strong>)^−1*<strong>X^</strong>⊤*<strong>y </strong>(again, it’s ok if you do not understand where this formula comes from). The mathematical derivation would be to demonstrate how to move from the general equation of a line into finding the parameter values of the line that best fits our data. It is important to make the distinction between these two levels. The formulation is what most of us need in terms of theory, as it allows the practitioner to understand useful mathematical details, reason about the strengths and limitations of the method and more importantly, enables him/her to build the algorithm or the method from scratch using some programming language if needs be. Derivations and proofs on the other hand, come in the second position, and are useful to develop a deeper understanding of the method, make connections between topics and learn the origins of some design choices. In Linear Regression for example, the mathematical derivation helps to understand that the popular choice of Mean Squared Error as a cost function for this algorithm is not arbitrary but arises naturally when we maximize the likelihood function under certain conditions. These theoretical details can also be extended to provide different perspectives of the same concept and its connections to other topics, such as providing a geometric view of Linear Regression.</p><p>The Applied facade however, can be decomposed into 3 categories : Intuition, Programming and Application. Intuition is about gaining a high level understanding of a specific concept or method and why we should care about it. This is usually achieved using simple graphs and plain words without any mathematical equations, while providing some simple use-cases to elicit interest and highlight its potential value. If we take our Linear Regression example, the intuition behind the algorithm is to consider a point cloud in a space (usually 2D space) and visually place a line in the middle so that it is somewhat close to all the data points. We’d consider this the line that best fits our data. In terms of importance, this algorithm is useful for both prediction and statistical inference purposes. The second aspect in the applied space is Programming, which is self-explanatory, and is concerned with transforming abstract ideas into code. This can either be done automatically using some package or API (such as Scikit-learn, a popular machine learning package in Python) that has already implemented the technique of interest, or coding the method ourselves from scratch. We could use Scikit-learn for example, to call the LinearRegression class which implements the algorithm of the same name. Similarly, we could rely on our knowledge of the closed-form formula of Linear Regression (given above) to implement the solution ourselves using basic matrix manipulation. The last point in the Applied space is about Application, and specifically, understanding the suitability of the algorithm or concept in a given situation. Like I mentioned before, knowing how a method or an algorithm works and using it correctly are two different things, and the difficulty is usually confined in the latter. Technically, we could always use Simple Linear Regression if the output variable (the outcome we are interested in) is numeric. However, if the relationship between inputs and output is not linear, we’d probably be better off using a more complex regressor instead.</p><p>It is important to know what kind of educational resource we need in order to achieve our goal. But prior to that, we also need to have a clear purpose in mind in terms of the knowledge we require for the work we intend to accomplish. It is also worth noting at this point, that most educational resources will cover a mix of these categories but will usually have a single dominant aspect (Theoretical or Applied).</p><p>In reality, most analytics professionals in the industry use applied data science. The better ones however, are also well versed in some aspects of the theory to ensure they make the right decisions when it comes to choosing their methods. Researchers on the other hand, are more concerned with the theoretical underpinnings of the different algorithms since they rely on that deep understanding to produce new pieces of knowledge.</p><p>Now, off to the next section we go, where I provide a few key-points on how to learn.</p><h3>ON THE ART OF LEARNING</h3><p>Learning is difficult, this is a fact that nobody can argue with. But this doesn’t imply it can’t be fun or made easier. Here are a few guidelines you may want to follow in order to make the best use of your time. Apart from their intuitive importance, most of these ideas are also supported by research results.</p><ul><li><strong>Make a Plan and stick to it. </strong>Have an idea about what you need to cover, which resources you’ll use to do it, and the estimated time to complete each task. It is ok to adjust your time estimates along the way (you certainly will).</li><li><strong>Review the previous key ideas.</strong> At the start of each study session, review the key points covered during the last session. This helps persist the information in the long term memory.</li><li><strong>Take notes. </strong>It is important to write down summarized key concepts in your own words. You can do this at the end of each chapter for example. This process helps with understanding and memorizing information.</li><li><strong>Use a combination of senses</strong>. The learning process can be much more efficient if the individual is making use of different perception faculties at the same time : seeing, hearing and doing. Watching countless hours of YouTube videos alone about data science will not make you a data scientist. In fact, you’ll forget most of that information soon afterwards.</li><li><strong>Know the scope of your intended study. </strong>Having an idea about the level of details that needs to be covered in advance can help keep you in your lane and prevent you from wandering off topic or getting lost in a myriad of books and other sources of information.</li></ul><p>Let us now move onto the main purpose of this article and discuss the prerequisite subjects of Data Science along with selected resources to learn more about them.</p><h3>PREREQUISITES &amp; RESOURCES</h3><p>Data Science as a new emerging field is interdisciplinary by nature. It sits at the intersection of various fields ranging from Mathematics and Programming to Statistics and Artificial Intelligence, to cite a few.</p><p>Fortunately, there are a handful of core subjects that make up most of the prerequisites of the data science space, and help the practitioner build a solid foundation for everything else to come. Other areas can also be useful for understanding specific algorithms, but in most cases, newcomers can do without them. These core topics are : <strong>Probability</strong>, <strong>Statistics</strong>, <strong>Linear Algebra</strong>, <strong>Calculus </strong>and <strong>Programming</strong>. Before even thinking about doing Data Science, one needs to have covered at least the basics of these subjects. Let us define each one of them, explain why they’re important and list some concepts you may need to be familiar with. Finally, I’ll provide a selection of resources to help you gain the necessary knowledge while specifying the amount of time and effort required to cover each of them.</p><h4>PROBABILITY</h4><p><strong>Description: </strong>Probability theory is a mathematical branch concerned with the study of random phenomena. It assigns a measure to quantify the likelihood that events will occur, which is usually estimated through repeated random sampling. Probability allows us to reason effectively in situations where being certain is impossible. it is heavily used in statistics and also forms the basis of many machine learning algorithms.</p><p><strong>Level of Mastery:</strong> Beginner to Intermediate knowledge is desired.</p><p><strong>Essential Concepts:</strong></p><p>❖ <strong>Foundations : </strong>Counting, Probability Axioms, Events and Sample Spaces.</p><p>❖ <strong>Conditional Probability : </strong>Conditional Probability, Independence, Bayes’ rule.</p><p>❖ <strong>Random Variables : </strong>Discrete/Continuous Random Variables, Expected Value, Variance, Higher-Order Moments, Cumulative Distribution Function (CDF), Probability Density/Mass Function (PDF, PMF), Important Probability Distributions (Bernoulli, Binomial, Poisson, Exponential, Uniform, Normal), Joint Distributions.</p><p>❖ <strong>Limit Theorems : </strong>Weak Law of Large Numbers, Central Limit Theorem (CLT), Strong Law of Large Numbers.</p><p><strong>Resources:</strong></p><p>➡ <strong>Probability Primer — mathematicaimonk (YouTube Playlist): </strong>This channel is dedicated to postgraduate and upper-level undergraduate mathematics. Probability Primer is a playlist of 43 short videos which will cover most of the concepts outlined above. Check out the first few videos, and if you appreciate the channel owner’s way of explaining things, then give this a shot. This channel also has a complete playlist of 160 videos covering all of the Machine Learning you might need at the start of your journey.</p><p>➡ <strong>Probability — Khan Academy (YouTube Playlist): </strong>This is a non-profit organization with the mission of providing world-class education everywhere and free of charge. It has both a youtube channel and a website. Probability is a playlist of 41 short videos that provides a good introduction to probability and combinatorics. I personally used it and I highly recommend it.</p><p>➡ <strong>A first Course in Probability — Sheldon Ross (Book): </strong>This is the go-to textbook in most graduate courses of probability. It is a very comprehensive book with many exercises (some of them can be relatively difficult and require some mathematical intuition). There is also a PDF summary of the book which can be used as a probability refresher. I personally own the book, and I recommend it (especially for people with a mathematics background). The book can be found online.</p><p>➡ <strong>Machine Learning A Probabilistic Perspective — Kevin Murphy (Book): </strong>This is a very popular machine learning book, and one of the recommended textbooks in my MSc’s ML module. Murphy starts by introducing most probability concepts you need to know for ML in about 30 pages. This is another great summary that is specifically tailored for machine learning. A PDF version of the book is available online.</p><h4><strong>STATISTICS</strong></h4><p><strong>Description : </strong>Statistics is the branch of mathematics that deals with the collection, organization, analysis and interpretation of data. It is particularly useful when we need to draw conclusions about a population through analyzing a finite sample from this population. Statistics and Probability are two related but separate academic disciplines. Statistical Analysis often uses probability distributions and theorems, and the two subjects are usually studied together. These two topics come up literally everywhere in Data Science, from data analysis and visualization to machine learning and statistical modeling.</p><p><strong>Level of Mastery : </strong>Intermediate to advanced knowledge is desired.</p><p><strong>Essential Concepts :</strong></p><p>❖ <strong>Descriptive Statistics : </strong>Central Tendency <em>(Mean, Median, Mode)</em>, Dispersion <em>(Variance, Standard Deviation, Percentiles, Interquartile Range)</em>, Shape <em>(Skew, Kurtosis)</em>, Dependence <em>(Pearson’s Correlation, Spearman’s Correlation, Kendall’s Correlation)</em>, Graphics <em>(Bar Chart, Box Plot, Histogram, Scatter Plot …)</em>.</p><p>❖ <strong>Statistical Inference : </strong>Statistical Theory <em>(Population, Sample, Statistic, Sampling Distribution, Density Estimation)</em>, Frequentist Inference <em>(Point Estimation, Confidence Intervals, Hypothesis Testing)</em>, Bayesian Inference<em>(Bayesian Probability, Credible Intervals, Bayesian Estimators) </em>…</p><p>❖ <strong>Regression Analysis : </strong>Linear Regression <em>(Ordinary-Least Squares, General Linear Model, Bayesian Regression)</em>, Analysis <em>(Errors and Residuals, Q-Q Plots, Validation, Interpretation)</em>, Generalized Linear Models <em>(Exponential Family)</em>.</p><p><strong>Resources :</strong></p><p>➡ <strong>Statistics — Khan Academy (YouTube Playlist) : </strong>Another playlist from Khan Academy offering 67 videos of ~10 mins each. The playlist provides a solid foundation of statistics (both descriptive and inferential). It will teach you most of what you need to know about statistics to get started with Data Science. I highly recommend complementing it with some practical exercises to help persist all the information and know how to apply different concepts.</p><p>➡ <strong>Think Stats — Allen Downey (Book) : </strong>A very good introductory book to statistical concepts through python programming. For each concept, an intuition is provided along with an explanation for why it is useful. Then the author outlines the mathematical formulation and turns it into python code (from scratch). The book is applied, avoids heavy math and essentially provides you with working knowledge of statistics without too many proofs and equations. I personally covered most of it, and I recommend it. The PDF of the book is freely available online.</p><p>➡ <strong>Think Bayes — Allen Downey (Book) : </strong>Another book from the same author, I haven’t read it, but it comes highly recommended from the community as well. This should introduce you to concepts from bayesian statistics which you will need for ML. Similarly, the book relies on python to code everything from scratch. A PDF version is freely available online.</p><p>➡ <strong>Statistical Inference — Casella &amp; Berger (Book) : </strong>This is one of the best books on inferential statistics out there. It is used as a textbook for statistics courses in many universities. However, this is also a very theoretical book with mathematical formulations, theorems and proofs. I haven’t personally used it yet though I already own a hardcopy of it. If you’re looking for a sound treatment of statistical inference, you can’t go wrong with this one. Though keep in mind, this book is not meant to be read from cover to cover, but rather meant to be used a reference. A PDF version is available online.</p><h4><strong>LINEAR ALGEBRA</strong></h4><p><strong>Description : </strong>This is hands-down the most important discipline to know before doing any machine learning. Prior to feeding it to an algorithm, data usually needs to be represented in a tabular format with numeric values, where rows represent instances of an entity (Person, Customer, Year etc.) and each column depicts a specific feature of the entity (such as Age, Salary, Sex etc. for the entity Person). In this structured shape, rows can be viewed as vectors in a vector space, or data points in a geometric space. The collection of rows (i.e the dataset) forms a matrix. And it so happens that Linear Algebra is the branch of Mathematics that studies vectors, matrices, their characteristics and operations to manipulate them. Apart from the theoretical reasons, knowledge of linear algebra also allows us to efficiently vectorize relevant parts of our code (perform matrix multiplications as opposed to for loops) to make it run faster.</p><p><strong>Level of Mastery : </strong>Intermediate to Advanced knowledge is desired.</p><p><strong>Essential Concepts :</strong></p><p>❖ <strong>Introduction to Vectors : </strong>Vectors, Linear Combinations, Independence, Dot Product, Norms, Matrices, Inverse, Transpose, Determinant, Rank …</p><p>❖ <strong>Vector Spaces and Subspaces : </strong>Vector Spaces, Basis, Dimension, Null Space of a Matrix …</p><p>❖ <strong>Orthogonality : </strong>Dot Product, Orthogonality, Projections, Orthonormal Bases and Gram-Schmidt.</p><p>❖ <strong>Eigen Decomposition : </strong>Eigen Values, Eigen Vectors, Symmetric Matrices, Positive Definite Matrices, Diagonalizing a Matrix, Spectral Theorem.</p><p>❖ <strong>Other Decompositions : </strong>Singular Value Decomposition (SVD), LU Decomposition and Solving Linear Equations, Cholesky Decomposition, QR Decomposition …</p><p><strong>Resources :</strong></p><p>➡ <strong>Essence of Linear Algebra — 3Blue1Brown (YouTube Playlist) : </strong>This channel is about mathematics explained in an easy and digestible manner with intuitive visualizations. It is one of the best channels out there to explain difficult math concepts in a way everyone can understand. The Playlist contains 15 videos of ~12 mins each and can provide you with an intuitive feel of linear algebra beyond the mathematical formulations. I found these videos to be useful even after studying linear algebra for years. Again, it’ll give you a conceptual understanding about mathematical constructs such as Matrices, Linear Maps, Eigenvalues, Eigenvectors, Vector Spaces, Determinant, Dot Product, Cross Product etc. I have personally covered it from start to finish, and I highly recommend it. However, alone, it’s not enough as you also need exposure to some equations because that’s what you’ll be using to understand ML. I suggest pairing this playlist with a book or a refresher about Linear Algebra.</p><p>➡ <strong>Mathematics for Machine Learning — Marc Peter (Book Ch. 2 to Ch. 5): </strong>This is an amazing book that covers most of the mathematics required for machine learning, it was specifically written for that purpose. In particular, it has detailed chapters about concepts related to linear algebra. One of the things I like most about this book is how rich in examples it is, as well as the illustrative figures it contains. Also, the authors have a very clear and concise writing style which makes reading the book manageable even for non mathematicians. It also has an exercises section at the end of each chapter for more practice. This is a good resource for condensed knowledge and can be found online in PDF.</p><p>➡ <strong>Linear Algebra Done Right — Sheldon Axler (Book) : </strong>This is another book that receives a lot of attention. It’s only 250 pages, covers most of the concepts you’ll need. This is also the only introductory book i’ve come across that starts with Vector Spaces, which I think is the way to introduce Linear Algebra. As mentioned earlier, given a structured dataset, every record (or example or row) can be regarded as a vector in a M-dimensional vector space where M is the number of columns in the dataset. This way of picturing data helps understand many ML algorithms such as PCA (through the concept of intrinsic dimensionality of data, or rank of the matrix).</p><p>➡ <strong>Introduction to Linear Algebra — Gilbert Strang (Book) : </strong>This is one of the best introductory books to linear algebra out there and is used as a textbook in many graduate courses. Gilbert Strang is an MIT professor who teaches the Linear Algebra class. The mathematics in the book is not very rigorous making it approachable for audiences with different levels of math. This book covers more than you will ever need to know about Linear algebra to understand the mathematics behind machine learning (be it from books or research papers). Gilbert is also known for his teaching style : he explains concepts in a digestible way, focusing first on the intuition before providing the mathematical formulation and proof when applicable. This is a comprehensive book of about 550 pages, and will require time to cover in full. I personally own and use this book, and I highly recommend it. A PDF version of the book can be found online.</p><p>➡ <strong>Linear Algebra — Gilbert Strang (University Course) : </strong>As you may have guessed, this is the actual MIT module that Gilbert teaches. There are 34 Lectures of ~40 mins each and cover the same concepts that are in the book. This is a long course and will require about 25 hours just to finish the lectures. If you like Gilbert’s teaching style, I recommend going through the book, and referring back to his MIT lectures when you find it difficult to understand some concept or for practicing with exercices after each lecture.</p><h4><strong>CALCULUS</strong></h4><p><strong>Description : </strong>Another central topic in Machine Learning, Calculus is a branch of Mathematics that studies continuous change, in the same way that Geometry studies shapes and Algebra studies the generalization of arithmetic operations [Wikipedia]. There are two major sub-branches of calculus : Differential Calculus, which deals with instantaneous rates of changes (represented analytically by derivatives and geometrically by slopes of curves), and Integral Calculus, which is more concerned with accumulated quantities and areas under curves. So why is Calculus actually needed here ? Well, most Machine Learning algorithms are framed as an optimization problem where we seek to minimize some Cost Function or maximize some Reward Function. Differential Calculus plays a key role in optimization routines given that derivatives inform the rates of change, and thus, help identify stationary points. Concepts such as partial derivatives and gradients are important here. As for Integral Calculus, it mostly comes up in probability-based methods dealing with continuous random variables. The discrete sum you would use in the case of a discrete variable turns into an integral for continuous random variables. Fortunately, there aren’t many concepts to know here for most of your data science work, but the few ones you should know, need to be well understood.</p><p><strong>Level of Mastery : </strong>Beginner to Intermediate knowledge is desired.</p><p><strong>Essential Concepts :</strong></p><p>❖ <strong>Differentiation : </strong>Limits, Continuity, Derivatives, Partial Derivatives, Chain Rule, Gradient, Higher-Order Derivatives, Hessian Matrix, Jacobian Matrix.</p><p>❖ <strong>Integrals : </strong>Integrals as Riemann Sums, Integration Techniques.</p><p><strong>Resources :</strong></p><p>➡ <strong>Essence of Calculus — 3Blue1Brown (YouTube Playlist) : </strong>12 videos of ~15 mins each from the same channel offering Essence of Linear Algebra. I’ve never done it personally, but from the previous playlist, and other videos i watched on this channel, I’m pretty sure this one is of high quality as well. However, just like before, the purpose here is to teach you the intuition motivating mathematical concepts, not the hardcore formulas and equations supporting them. For that, you need other resources.</p><p>➡ <strong>Calculus Early Transcendentals — James Stewart (Book) : </strong>This is the standard textbook for calculus courses in Universities. The last edition (8th) is comprised of 1400 pages, so needless to say, this is a very comprehensive book that will teach you more than you need to know about calculus. You do not need to cover every chapter, you can just select the ones you require to complement your knowledge. It is detailed, very well written, illustrated with colorful figures, and clearly organized. And once again, the book is available online.</p><p>➡ <strong>Calculus — Michael Spivak (Book) : </strong>Another good book on calculus. This one is much shorter (around 600 pages) but still covers the required concepts of Calculus (both derivatives and integrals), though it lacks in term of multivariate calculus which is important in Machine Learning since we usually deal with high dimensional data. It’s available online.</p><p>➡ <strong>Mathematics for Machine Learning Marc Peter (Book Ch. 5) : </strong>The same book mentioned before in the Linear Algebra section. It also has a chapter on vector calculus. Combined with some chapters from Calculus by Michael Spivak, it could provide you with a nice overview of the pre-required knowledge in this area. Download the book if you haven’t already.</p><h4><strong>PROGRAMMING</strong></h4><p><strong>Description : </strong>Knowing various fancy algorithms and statistical concepts is good, but applying them to solve problems is even better. In this day and age, with the amounts of data available, and the complexity of techniques used, one needs to off-load the computations to a piece of hardware designed for that purpose (Don’t believe me ? Try finding the inverse of a random 100-dimensional square matrix using a pen and paper). But in order to communicate our intent to the machine, we need to be well versed in a programming language. There are many languages out there, each of which was developed with a specific goal in mind, and is therefore better suited for a certain class of tasks. In the Data Science space, practitioners seem to favor R and Python in particular, mainly due to their flexibility, ease-of-use and the specialized libraries or packages they provide to do applied data science. This is a key point motivating the choice, as these two languages offer off-the-shelf implementations of various techniques and algorithms that can be used with a simple function call and a few lines of code. This essentially helps the analyst focus more on solving the task at hand than writing pages of code. For the purpose of City’s Data Science MSc program and most companies out there, Python is the language of choice and will be the focus of this article. That said, apart from the libraries which are language dependent, most other concepts introduced here constitute a foundational knowledge in computer programming and generalize equally to other programming languages.</p><p>Python is an interpreted, high-level, general purpose programming language [Wikipedia]. Its flexibility allows it to be used as a scripting tool for interactive analyses and fast prototyping, but also as a full-fledged programming language to develop programs destined for other tasks such as networking, web development etc. Before delving into the specialized data science libraries Python has to offer, one needs to understand the base Python distribution first, along with general programming principles, which will subsequently make the process of picking up new libraries much easier when the time comes.</p><p><strong>Level of Mastery : </strong>Beginner to Intermediate knowledge is desired.<br><strong>Essential Concepts : </strong>These are most of the concepts you need to know in base python (and programming in general).</p><p>❖ <strong>Data Types : </strong>Integers, Floats, Strings, Booleans …</p><p>❖ <strong>Data Structures : </strong>Lists, Tuples, Sets, Dictionaries, their similarities, their differences, their use-cases and how to manipulate them.</p><p>❖ <strong>Control Flow : </strong>If statements, For Loops, While Loops, Break / Pass / Continue statements …</p><p>❖ <strong>Functions : </strong>Function definition, arguments, keyword arguments, lambda expressions …</p><p>❖ <strong>Input / Output (I/O) : </strong>Reading/writing from/to files and output formatting.</p><p>❖ <strong>Errors and Exceptions : </strong>How to catch errors and handle exceptions.</p><p>❖ <strong>Classes (Object-Oriented Programming) : </strong>How to define and manipulate classes in python. This one is very important because every package you will use in Python is written in classes. In Scikit-learn for example, LinearRegression is a class, and LinearRegression() creates an object instance of that class, with methods for functionality and attributes for storing values.</p><p>❖ <strong>Other Modules : </strong>These are complementary modules included in the Standard Python Library and can be handy at times. They include the “math” module (for mathematical functions), the “datetime” module (for date and time manipulation), the “re” module (for regular expressions), the “collections” module (which offers new containers and data structures better suited for some tasks) etc.</p><p><strong>Resources :</strong></p><p>➡ <strong>Think Python — Allen Downey (Book) : </strong>This is the third book by Allen Downey I mention in this writing, so needless to say, I do believe his books are of high quality. This is a 250-page book introducing the reader to fundamentals of computer science and specifically the Python programming language. However, I do not recommend doing the exercises of the book (they are too time consuming for what they offer). The book is freely available online.</p><p>➡ <strong>Python 3 Tutorial — Officiel Python Documentation (Website) : </strong>This tutorial is offered as a part of the official python documentation. It is probably the best resource to cover all the topics mentioned above and more if needed. Choose either this or Think Python because they contain similar information and are organized in a similar way too. That said, the teaching style is not the same, so pick whatever works best for you.</p><p>➡ <strong>Hackerrank (Website) : </strong>Reading books and tutorials about a programming language is great, but more importantly, you need practice. While going through the book or tutorial, have your terminal or some IDE open on the side, and practice while reading. Hackerrank is a platform offering exercises which you can solve in Python. It’s a great place to practice, and has the great benefit of being beginner-friendly. I highly recommend it.</p><p><strong>Remark 1 : </strong>The list of resources outlined above reflects my own opinion of what I think is important to know before doing Data Science, and what resources can teach you that. However you don’t have to pick any of them, you can choose whatever works best for you. That said, I do recommend you get the necessary knowledge about the topics mentioned here from their respective books. Meaning, avoid trying to cover all these pre-requisites at once with a single book that presents itself under the vague umbrella of data science. It will probably miss many important concepts and topics because you can’t cover everything with a single book. Leave those general Data Science books until you have covered a decent amount of knowledge and use them as references to brush up on topics.</p><p><strong>Remark 2 : </strong>It is imperative to understand that there is no “best resource” to learn a given topic. It’s all about whether the difficulty level, the pace, the language of the author, the depth of explanations, and the way of teaching are convenient for you or not. That said, when a particular resource is very popular, it essentially means that it is compatible with many people.</p><p><strong>Remark 3 :</strong> At this point, I’m pretty sure some of the readers are wondering “Whoa ! I need to know all of this before even starting Data Science ? Nevermind.” You need to understand that this is a learning journey, which will take a lot of time and dedication. However, you do not need to know every single thing mentioned in this article before getting into Data Science. Even I still brush up on some of these topics, or refresh my knowledge of others when I forget. So take it easy, one step at a time, and as long as you keep advancing, you’ll get there eventually.</p><h3><strong>THEN WHAT ?</strong></h3><p>Congratulations if you’ve made it this far ! I know the journey couldn’t have been easy, but rest assured … At this point, you have (most of) what it takes to delve into actual data science training. You may still need to review other topics occasionally depending on what you choose to study next, but you are well equipped to safely learn enough Data Science to be a working professional.</p><p>The next step from here is to tackle Applied Data Analysis, Machine Learning and Scientific Programming (mostly Python libraries designed for specific purposes). I’ll focus on the last two.</p><p>In terms of Machine Learning, you could start with simple algorithms such as Linear Regression, Logistic Regression, Decision Trees, K-Nearest Neighbors and K-means. These are not only easy to understand but they also form a solid foundation for the rest to come. They will also introduce you to various essential concepts encountered in ML such as the Type of Learning (supervised vs unsupervised), Cost Functions, Overfitting, Bias- Variance Trade-off, Regularization, Performance Metrics, Hyper-parameter Tuning and Validation Strategy. You should preferably start with an easy resource that explains some of the intuition and provides you with the mathematical formulations. One such resource is a very recent book called : The Hundred-Page Machine Learning Book <strong>by Andriy Burkov </strong>(can be found online in PDF).</p><p>The other aspect is Scientific Programming. We mentioned earlier that you need to understand base Python well and become familiar with computer science basics before moving further. If you’ve accomplished that already, then it’s time to start looking into specific libraries destined for data analysis and modeling. The core libraries are :</p><ul><li><strong>NumPy : </strong>which stands for Numeric Python, and is intended for Linear Algebra operations such as vector/matrix manipulation. It’s blazing fast since it has a back-end written mostly in C, and many other scientific libraries are built on top of it. NumPy introduces the <em>N-dimensional array </em>as its main data structure, and makes it easy to “vectorize” the code in order to avoid the awfully slow “for loops”.</li><li><strong>Pandas : </strong>which stands for Python Data Analysis Library, and is used to manipulate (transform, join, merge, group, aggregate, clean) datasets presented in a tabular format. Pandas is built on top of NumPy and makes use of two different data structures : a Series which can be viewed as a named NumPy array (where each cell of the array has a label), and the DataFrame which is a list of horizontally concatenated Series that share the same index labels.</li><li><strong>Matplotlib : </strong>This is the standard visualization library in Python. It is also the basis of other visualization libraries such as Seaborn. Visualization is an important aspect of data science which provides the practitioner with crucial complementary information, and a more intuitive view of the data being analyzed.</li><li><strong>Scikit-Learn : </strong>This is the go-to library for classic machine learning in Python. It has a clean and unified API which allows the use of many algorithms through similar function calls and pipelines. This library also offers some convenience functions and preprocessing tools that are usually involved with the ML process such as normalizing, one-hot encoding etc.</li><li><strong>Seaborn : </strong>A different visualization library that is built on top of Matplotlib. It offers functions that are tailored for statistical visualizations such as regression lines, conditional box-plots, density estimation plots etc. Oh … and did I mention it is more visually appealing than Matplotlib using default parameters ?</li><li><strong>Statsmodels : </strong>This package provides functions and classes destined for statistical modeling, hypothesis testing and statistical data exploration. Unlike Scikit-learn, which is tailored towards predictive analytics, statsmodels is geared towards descriptive and inferential statistics even though some of their algorithms may overlap.</li><li><strong>SciPy : </strong>A library that provides the practitioner with many user-friendly and efficient (the keyword here is efficient) scientific numerical routines such as integration, interpolation, optimization, linear algebra and statistics. It also offers some interesting, efficiency- aware data structures and algorithms that are handy when the scale becomes problematic, such as Sparse Matrices and K-D Trees.</li><li><strong>Keras : </strong>A popular high-level, intuitive and user-friendly deep learning library that will allow you to focus on learning deep learning instead of wasting time learning the library itself. It offers the user everything he/she may need, as long as it doesn’t involve modifying and tinkering with the very low-level details and inner-workings of the algorithms. For such fine-grained control, one can always opt for the lower level PyTorch or TensorFlow libraries instead. Though these two typically have a steeper learning curve (TensorFlow more so than PyTorch).</li></ul><h3>CONCLUSION</h3><p>This concludes my article about data science prerequisites. To you my reader, I wish to say thank you … thank you for taking the time to read me, and I hope you will benefit, even just a little bit, of what I had to say and the various resources I talked about. I also hope I haven’t discouraged you from taking up the challenge of learning Data Science, if I managed to do it, then so can you ! Just be honest with yourself in terms of what you want to achieve and why, and set reasonable expectations. The rest will naturally follow.</p><p>Finally, I welcome any suggestions to make the article better, or to correct mistakes if any, so feel free to use the comment section or contact me directly. Also, I have created a shared drive about a year ago where I share resources about Data Science that I collected and hand-picked over the years. It was initially meant to help my peers during the MSc program, and it got a lot more attention than I expected. If you’d like, drop me an e-mail, and I’ll be happy to share it with you as well.</p><p>Here’s my contact information in case you want to reach out :</p><ul><li>Email : samy.tafasca@gmail.com</li><li>LinkedIn : <a href="https://www.linkedin.com/in/samy-tafasca/">https://www.linkedin.com/in/samy-tafasca/</a></li></ul><p>Edit 20/09/2019 : corrected a mistake in the formula of OLS regression.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7738c7c900aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/data-science-a-tour-of-prerequisites-7738c7c900aa">Data Science : A Tour Of Prerequisites</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>