A Gentle Introduction to Data Science
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Garcia, Marc
A Gentle Introduction to Data Science This introductory talk, will cover the basics of datascience. From the incluence of artificial intelligence, and the quest to replicate a human mind, to a practical demo on how to build a hello world machine learning in Python. The talk will try to answer questions such as: What do we understand by data science? What do we know about the human mind, that can be an inspiration for our programs? Which problems can we solve with data science? What tools are available to do data science in Python
 Hello, everyone. Thanks for coming to my talk. And even if it was not in the app, so I guess it was a bit challenging for you to know what's going on here. This, as the title says, it's this one's to be a gentle introduction to data science just to give an intuition. There are some formulas, some stuff, so I'm not sure how gentle is this being gentle. The goal is not that you really understand everything on that or really all the concepts. It's more to get an intuition or first, where data science comes from or where artificial intelligence comes from that it's quite related. It's my area. And second, just to see some applications, how it can be used. It's not really technical, but there are some parts that are a bit more about formulas and understanding some concepts. So who I am, I'm working currently in a dating site, but I'm a data scientist there. I have a master in artificial intelligence to give some context that this is data science, but also I'll be talking about the human brain and things that are more considered artificial intelligence than data science. I'm also the non-focus ambassador here at EuroPython. Non-focus is a foundation that is sponsoring many of the PiData projects or all the PiData projects, even the PiData brand is a non-focus thing. Non-focus is also organizing the PiData events. So you can find me most of the time at the non-focus both later on if you are interested in some of the projects to do data science in Python or even not in Python. Some of them are also in other technologies like Julia or Stan. So let's talk a bit about the human brain. And I would like to do a kind of a small experiment, but just try to make you visualize a bit to really be able to show what I want to tell. It's kind of a silly example. It probably will sound to you more as a meditation exercise than as an artificial intelligence. But what I want you to think is that your own eyes are kind of like two cameras. Let's imagine that they are like 20 by 20 pixel cameras. And this image on the screen is just like the number five. There is nothing magic on it and it's not like anything that fancy. But it's just like 20. It's a famous, it's from a famous data set named NINST. It's quite common just as a benchmark in artificial intelligence in deep learning and other techniques. And what I want you to do is just to imagine that your eyes are just cameras and that you just perceive this image, this 20 by 20 pixel. So what you arrive in your eyes, in your retinas, is just like this 20 by 20 information that can have values, let's say that zero for one and zero for white and one for black. If you imagine this, then how the information it goes into your brain, it's like it feels arrived to the eyes, these spheres you can see there. There are these channels of neurons. We'll talk a bit about neurons in a second. But there are these channels that what just do is propagate this 20 by 20 pixels. So imagine 20 by 20 neurons just taking this to the end of the brain where the visual cortex is. The visual cortex is the part as the name visual says that it's mostly focused on the understanding and the recognition of images. So back to the example, we've got this number five. It's just like zero and one to say that get to your eyes and then at the end get to the visual cortex. So some years ago, I just started to think this brain, I think it's something quite obvious, but I think it's still worth mentioning that the human brain is just like a network of neurons. And neurons basically are just like these cells that transmit electric information from one side to the other. The tricky part, the whole human brain, the whole human mind, everything we know or we think we know, it comes from these neurons just interacting among them in a massive scale and all the interactions are what are really making all lower thoughts or lower perceptions, everything. Okay, it's probably not very intuitive when you think as a single neuron like having all these powerful, but when you combine thousands of them, it's really like that. It's like if you imagine a switch, a switch is actually not nothing intelligent, but if you have a microprocessor of a computer, it's just like switch. It's just like zeroes and ones, just activating some signals, some electrical signals. And at the end, it's so powerful what you can do with a computer. So it's exactly the same thing. So Hubble and Thorsten were two researchers quite advanced for their period that they did an experiment with this poor cat. He did an amazing contribution, but I think he wasn't really happy about that. They basically connected some sensors to his brain, to the initial part of the visual cortex. As I was saying in my example, you are getting these information, zeroes and ones, it's like perceived by your eyes as if they were a camera, then they go to the visual cortex and what they were studying is this first layer of the visual cortex. So what happens when these neurons, instead of being just a channel that propagates the information, they start to mix one with another. So they start to build these networks. So the idea is like, okay, probably this cat in this visual cortex is recognizing circles like the one you can see in the experiment is probably recognizing squares, recognizing different shapes. So they took this cat, they had the cat just looking at shapes for many hours, looking for circles and waiting for neurons to activate. And the funny part of the story, I don't know if you can see in this, I think it can be seen in the screen, you can see these, those are the oldest lights, it was just a transparent paper and they had like the shapes on that. The funny part is that the neurons of the cat, of the visual cortex of the cat, the first layer, actually activated not because of the circle, not because of the triangle, not because of any of the shapes, but because of the edge of the, like the border of this paper. You can see this line over here in diagonal. That was really what it made, it made the cat activate these neurons. So in the first layer, the takeaway of this is that in the first layer of these neurons, of these neurons connecting one with another, actually what it's going on is that they activate for very, very small patterns to say, very small, just like edges in different rotations and that. Another important experiment that Donald has, based in the Heavian theory, is that these connections on the brain actually are, besides some of them that are, of course, when you're born, you already get some connections in your brain, but some of them are created just because they get activated. So if you keep watching this edge we've seen before, for many, many times, what this theory says, this theory is a bit complex and I don't expect you to even read that, so you'll have them in the slides. But the whole point is that if you keep activating, if you have like an impulse, you'll see like this person, this phase, this phase, this phase, one time and another time and once and once more, then at some point, the neurons that are activating, the first time you see them, they become stronger and stronger and they're kind of hard coding the information in the brain. So it's like something that you've never seen, one activate much neurons and something that you see often they will activate much more neurons. That's something very interesting because at the end, like memory or the learning, actually basically everything starts from this, everything is based on seeing something and then having it hard coded because some connections on the neurons are there and then being able to reproduce that. So we'll see this is kind of like a bit of the history of the human brain, what's in the human brain, now I'll go to the counterparty like code, computers are kind of cloning all those things. I'll start this, this is just like a linear regression, I assume that most of you know a linear regression, it's just like I got some input, let's say that you told me your age and you told me your weight to say and I want to predict your height, so I just multiply each of the values and then I add them together, that's a linear regression and at some point you find if there is a correlation between these input features and that, you get that. So this is something quite simple but at the end it's just like a way, if you think as this, as neurons, it's a way that every neuron can have a weight, so every input you will have more or less importance, at the end you pack all together, you will have like a single value and what's very important in this is that this activate function, what it does is binarize the result, at the end what you have is that the output of this is a zero and a one. This is something similar, it's almost a logistic regression if you ever heard about that in data science but it's still quite powerful if you start to do that. How is it binarized? I won't talk much about that but it's not usually taking like positive plus negative and making positive zero or positive one and negative zero, it's usually used in this sigma functions just as a reference that what they do is just do the same exact thing but you can take the derivative on that and it is very key because in optimization problems when you want to build these networks and you need to see which weights are the good ones, being able to derivate that is really useful, how you really optimize. I'm going to talk about hopeful networks, I'm going to cover this briefly. Hopful networks are just like networks of these artificial neurons that everything is connected with everything. The nice properties, it's kind of something super simple, it's nothing really, really complex. Just a linear regression you can implement this in a single line of code and then you just connect them among them. The nice thing is that this has a property that it's called an associative memory. What it does is you show, as I said before, with the number five you keep showing images and then this network is remembering the images in the same weights. In the weights of the linear regression it's learning these weights. In this example what you can see is you have the original image in the left is the image that you shown to the network and then at some point you show an image that is similar to this one. The network kind of remembers and it optimizes in a way that after several iterations what you get is the original image again. It can be used, for example, to recover corrupted documents, corrupted images because whatever you've shown to the network before at some point will be back to you. That's kind of the point. If you show all this to a neuron and of course you need to a hopeful network and of course you need a proportional number of pixels or neurons that are able to store all this information but if you show all this at the end and you check the weights and you represent the weights in a matrix you have something like this. It's kind of subtle but you can see that this is like the shape of the average number and in every of the pixels at the same time it have the average of the numbers that are activated that have values at that pixel. So, for example, if you check on this side over here on the top right corner you will see the number seven, number five that go in the direction. Well, if you see, for example, in the top left you will see the number three because the number three actually it ends up in that dimension. This is actually it's kind of more a trivial thing but this really shows how the weights of the linear regression I was talking about before actually are keeping information on this images. They are able to recover it later. After hopeful networks there are Boltzmann machines that start to be the basis of deep learning if you've heard about that, I guess you do. Boltzmann machines are the same with the difference that in the previous example all the networks are the same as the pixels you are getting. So, if you are giving like 20 by 20 pixels you have this network, this neurons and this is exactly what you have to store the information. In this cases you have like hidden neurons that they don't have a direct exposure, you won't have like the initial perception but you will have like an indirect perception. And these are actually much more powerful because this work as a generative network. A generative network is something similar what we've seen before but the idea is that you've got a model that it learns some parameters in this cases like the weights of the neurons but if you think as a Gaussian imagine that I want to generate data that it comes from the distribution of the height of the people in this room or the ages. So, at some point I can have like a Gaussian distribution I say okay the mean of the age in the people in the room is 30 to say on the standard deviation is 5. So, I can start generating samples and whatever samples I'm getting it would be like the real samples like if it was real people that I knew the age of the people like the same as if I get the data from people entering the room. So, what is quite important if you do this with image recognition you can start making like these models, these networks start to learn patterns. This is something I think it's named like the deep dream, I think it's an experiment by Google that they started to show images to one of these networks and what was happening is that then they say like okay now tell me you about the data, give me this data as I was saying with the ages. Don't show me more data, don't show me more, don't tell me about the data you have already seen generate new one and this is what they got I'm not sure exactly what they used to train this network but this is something generated by a computer that just seen some images I guess they saw some animals for what you see here, these capsules I don't know exactly what they are it looks like it also saw people maybe a temple I don't know exactly what it saw but it can actually show again what based on the images that he's been seen. Again, just to emphasize a bit on the example if you tell me the age and I start to assume that the distribution is this and then I start saying numbers it's like I think a normal age would be like I don't know 32 and 28 so this is basically what it's doing but with images which I think is quite an interesting thing. The problem with artificial intelligence usually is that you find these models they are super cool they are quite amazing but at some point you realize that they are NP complete which it means that a computer would take like from the same time as the big bang to the present day to compute all this information to get like the optimal solution. So in practice what is being used is these restricted Boltzmann machines that they have some properties that they don't have all the connections so they don't really have these properties in the same way it was proved for the Boltzmann machines but it still have mostly everything it's kind of an approximation but a good approximation and this one can be trained somehow there are some techniques to optimize them and train them easily which is quite nice to make things in practice. In practice you don't have just one of these networks what you do is you have layers of networks and one connect to the other and as I said before the first layer with the cut was just an edge you can see this in the left you have these very small patterns that for themselves they are not that useful but when you start to combine them in the neurons in these networks on the next layer actually you start to have an eye you start to have a nose you start to have things so it's kind of a sequential thing like a cascading thing that you start with no pattern at all you start creating a small patterns at some point you have an eye and at some point you combine eyes and you have a face and you can construct anything you want if you have enough number of layers. I'll talk very briefly about that just to give you an intuition on how this can be done. What you need in data science is just to have the error so you have some data whenever you have some data you know that let's say that you know that this is an eye or what you are looking for so you are comparing the answer with the prediction of your network and whatever is mismatching if you are trying to predict a cat and you don't have this cat image you compute the difference between this cat and that this is what represent this is for a linear regression it would be much complex but imagine that you just have that you can really compare the images that your model is generating with the images that you want to see and based on this error you just optimize it. I was talking about before about this derivative how these functions can be you can derivate them because they are just linear regression with this sigma function that can be derivated and because you know that the derivative is showing you where how you can go to the minimum point to the point with less error so you start up to this hill and you just see okay you derivate your result your function that you are using to estimate and then you see that it's going down in that direction so you do a step in that direction you keep iterating at some point you end up with a place where where the error is minimum if the error is minimum it means that your error actually that your model actually it's performing as expected if we're being able to reproduce cats or whatever it can it can reproduce and you do this by layers so you start doing that in the in the last layer you check the error and then you you do it in in a recursive way backwards this is actually from a Google experiment they took I think it was 40,000 CPUs and they train these sort of neurons with YouTube videos frames from YouTube videos for a whole weekend to see what was the the internal representation that the these models were learning and what they found or what they say they found it's this cat in one of the neurons it's look like it's what it learned and it probably makes sense because in YouTube it's full of cats so at the end if you think on this whole thing on how the brain is learning the neurons are changing the transformations based on the information we see you can see the brain as a thing that that it's really the just a set of patterns that have been learned like these shapes that if you have children play you can recognize and at some point you have like these edges these triangles these faces and you are only able to really recognize whatever you've seen before your brain has been trained to to understand certain patterns and only these patterns and the one that you can really understand and it's it's exactly what you what your brain is doing in terms of of recognition these are very interesting experiment what they did is like you have this this picture from from Van Gogh the one in the middle in a small and they train a deep neural network with with this information what that that information what what it happened is that the neural network it happened to to really get a representation of the world the neurons were trained in a way that actually only could see in Van Gogh pictures so after that after all the training and after all the these neurons that has been has been coded to to activate at certain stages they shown this picture I think not sure if it's Amsterdam what's this place and whenever you ask it tell me show me this picture that I just shown you because the the model the the reality of the model the internal representation of the model is just about Van Gogh what it returns actually the same exact picture but just with the with the pattern from Van Gogh is like the the Van Gogh patterns like there is no way it can paint like a red a red ceiling a red roof because the the neuron has never been trained for that so I think it's it's really really interesting how how this works now I just wanted to give like an intuition on why or what can be achieved or what's the direction of of this whole world of artificial intelligence and and what's like the top trending but I I would know when now to talk more about like practical applications what's really being done as a as a data scientist nowadays today's job the first one is classification I would say it's the most common one some something usually name a supervised learning that you have some data and I work for this dating site but we have many problems with the spammers people trying to abuse the system people trying to cheat on on our users and that and we need to to detect them and block them we need to block set like like some accounts so at some point as a data scientist you get a data set with many people reviewed profiles and they said this is a spammer this is not a spammer this is a spammer this is not a spammer and you have certain information you can imagine here that the y-axis is the age of the profile and the the exact cc is whatever feature you can imagine like the I don't know it can be the the time the user has been registered on but and you start to see that there are some patterns that that the the kind of profile that you're looking for or the kind of data that you're looking for fall more in one of these sites so you just need to plot like a line or a separator so you can identify that and this can be used for like the classical example is from a spam whenever you go to your inbox and you see some spam that has been classified they're using the same technique just having some features they represent them they plot a line and or whatever and at some point they they are able to distinguish which one are the goods from the but they this is done on also on cancer prevention for example they analyze images of tumors and they decide based on these models whether this is a cancer or not a maling cancer or not for credit payments whether you someone is going to return your credit you always in this sort of project that it's the most just one and the easier to start I would say what you need is someone who really labeled or in some way that you get labels to the data you know that certain users didn't pay that certain things like that and and what you do is just try to replicate the same decisions that were being made you start to replicate it in the same way a regression you probably know what exactly this quite similar thing but let's say I want to know the price of these of this building and based on the on the square meters it it got so you can plot all these plot all these dots and and then you do the linear regression we can also do it in robotics I'll quickly show a video okay you've got an idea this is like the state of the art in robotics it's a that I think a different technique it's usually named reinforcement learning that it's a way that the robot keeps learning based on experience so the robot it used at the beginning of the on the training stage it keeps falling and then even if you kick it it doesn't fall wouldn't surprise me I think the one of the concerns in artificial intelligence is whether whether robots are going to control and make their slaves at some point I think it will make sense after seeing how they treat this this poor robot yeah more more applications recommendation systems whenever you go to Amazon they're using all these data science artificial techniques to see what one customer both actually it's the same that that everybody else who is buying this product is buying so you'll find these patterns on these association then clustering is a is similar to what I was saying mentioning before about classification but in this case the the whole point is that you don't know the labels you know that you have two different types of users I'll talk about dating sites again let's say that I have the users who are interested mostly in sex and the user that are interested mostly in sex but in a more subtle way okay and we really want to to identify them but I don't have labels I nobody is gonna just review them and say okay we'll have this so you have these techniques to train models and these models at the end are able to really split the the data by itself on finding the distance between different groups saying okay there is this group that is quite similar but at the same time another group that is quite similar among them but they are very different groups so it's it's about finding these patterns network analysis is quite another interesting topic they are able to predict for example some some problems with sicknesses like like the flu I think it was like the some of the variants of the flu that they are started to detect based on the network of flight connections when it was gonna start the first cases in every single country and they are predicting that with with great accuracy also for the banking system they check like the transactions upon banks and they say okay if this bank is defaulting this other bank is is gonna default because they make so much transitions together image recognition it's quite challenging topics in many cases in this case the idea is this thing which I think this is a she wow I'm not sure which kind of dog and there is muffins and yeah deep learning is is managing to to identify which is a muffin which is a dog even probably better than a person because in some cases it becomes quite tricky I would say also self-driving cars is like the the state of the art probably you've heard about them they are already in in the state in several places they are already driving autonomously they have these cameras the sensors and they are they're really being able to even in cities stop when there is a pedestrian who wants to close and all that final just briefly mentioned I was mentioning before there are many projects in in Python that you can that you can use the more famous ones you probably know already about pandas Mumbai which is like the internal representation of of any of these software at the end you have Jupiter and probably you already know about this one is just like a web application it's like a Python terminal but web based and it's very useful when you are in data science because you usually plot things so also you have pi mc3 is for by issue and probabilistic models quite advanced one J Jensim is a pretty cool one that it's it's being used for topic modeling so you can really find the topics of conversations what I was mentioning before which are the topics that people is talking about so that's it I'm just a quick mention we're thinking on organizing something related to data on on Saturday probably it would be partly a pandas sprint so people who wants to contribute to pandas but if people is new to pandas or new to data science we can also do a tutorial and things like that so please get in touch with me if you're interested I'll be around on Saturday just just in case anyone wants to contribute to these projects or or just get a tutorial or discuss about that yeah that's it thank you very much we have a couple of minutes for questions if we have any I guess no one really understood anything and it wasn't as gentle as I pretended to be I don't know if my question is really related to mostly on computers but on the other side of human brain so you said that when there is a I mean an image or a pattern that it's already I mean at the you the observer has already seen more neurons activated than I mean a new image so my question is why do we feel much more tired when we learn new things at least instead of you know I would my guess would be if there are more neurons that are activated one should be like more tired why is the opposite I didn't quite get the question why the number of of neurons activated change so my question is you said that I was expecting that you get more tired at least intellectually where more neurons are activated okay but if I can I mean I would guess at the same time that when I'm learning new things I get much more tired okay okay but why is not the case I mean well I think there are two two different steps in this process to say one is about training I would say that when you feel tired is because if you are seeing something new you go to your new day at job and that of course you feel much more tired because everything is new so your neurons are actually kind of training in this training stage so all the connections need to be activated need to be created so you have new connections that some neurons that are not connected among them and they are gonna get getting the activated for the first time so I would say it's related to that and then when you are doing something repetitive it's like just your your your neurons are just already being activated the ones you are using so it's just like the information just flows and I'm not a neuroscientist I think it's kind of a question for more for a neuroscientist but but yeah I think that would be probably the reason and I have another another question do you use any other languages than Python like machine learning like the language is designed for machine learning like Prologue or something I think all the I don't use much other languages in than Python actually I think everybody is like using C in there because numpy is mostly programming C there is also Cyton that it's quite the standard for for all those things so I would say that I would use pandas I use I would use something that is not Python for for in terms of performance because for coding actually I love Python so I would never really like to have to use another language in some cases there is for example TensorFlow, theano all these things some of them I think theano it's it's probably what writing in Python but but TensorFlow it's not but usually you have bindings and then I think Python is very good with the interaction with the user with the programmer think it's the most beautiful code you can read is in Python more than in C or anything else so yeah I think it's like that the training is moving there you have a stand for example for probabilistic programming you first have R that it's quite good and quite quite used in in in this world but in my case I'm not using anything else and I think you can really do a lot of data science use with Python. That's great thanks and that's all the time we have for this talk so thanks again.
 Hello, everyone. Thanks for coming to my talk. And even if it was not in the app, so I guess  it was a bit challenging for you to know what's going on here. This, as the title says, it's  this one's to be a gentle introduction to data science just to give an intuition. There  are some formulas, some stuff, so I'm not sure how gentle is this being gentle. The goal  is not that you really understand everything on that or really all the concepts. It's more  to get an intuition or first, where data science comes from or where artificial intelligence  comes from that it's quite related. It's my area. And second, just to see some applications,  how it can be used. It's not really technical, but there are some parts that are a bit more  about formulas and understanding some concepts. So who I am, I'm working currently in a dating  site, but I'm a data scientist there. I have a master in artificial intelligence to give  some context that this is data science, but also I'll be talking about the human brain  and things that are more considered artificial intelligence than data science. I'm also the  non-focus ambassador here at EuroPython. Non-focus is a foundation that is sponsoring many of  the PiData projects or all the PiData projects, even the PiData brand is a non-focus thing.  Non-focus is also organizing the PiData events. So you can find me most of the time at the  non-focus both later on if you are interested in some of the projects to do data science  in Python or even not in Python. Some of them are also in other technologies like Julia  or Stan. So let's talk a bit about the human brain. And I would like to do a kind of a  small experiment, but just try to make you visualize a bit to really be able to show  what I want to tell. It's kind of a silly example. It probably will sound to you more  as a meditation exercise than as an artificial intelligence. But what I want you to think  is that your own eyes are kind of like two cameras. Let's imagine that they are like  20 by 20 pixel cameras. And this image on the screen is just like the number five. There  is nothing magic on it and it's not like anything that fancy. But it's just like 20. It's a  famous, it's from a famous data set named NINST. It's quite common just as a benchmark  in artificial intelligence in deep learning and other techniques. And what I want you  to do is just to imagine that your eyes are just cameras and that you just perceive this  image, this 20 by 20 pixel. So what you arrive in your eyes, in your retinas, is just like  this 20 by 20 information that can have values, let's say that zero for one and zero for white  and one for black. If you imagine this, then how the information it goes into your brain,  it's like it feels arrived to the eyes, these spheres you can see there. There are these  channels of neurons. We'll talk a bit about neurons in a second. But there are these channels  that what just do is propagate this 20 by 20 pixels. So imagine 20 by 20 neurons just  taking this to the end of the brain where the visual cortex is. The visual cortex is  the part as the name visual says that it's mostly focused on the understanding and the  recognition of images. So back to the example, we've got this number five. It's just like  zero and one to say that get to your eyes and then at the end get to the visual cortex.  So some years ago, I just started to think this brain, I think it's something quite obvious,  but I think it's still worth mentioning that the human brain is just like a network of  neurons. And neurons basically are just like these cells that transmit electric information  from one side to the other. The tricky part, the whole human brain, the whole human mind,  everything we know or we think we know, it comes from these neurons just interacting  among them in a massive scale and all the interactions are what are really making all  lower thoughts or lower perceptions, everything. Okay, it's probably not very intuitive when  you think as a single neuron like having all these powerful, but when you combine thousands  of them, it's really like that. It's like if you imagine a switch, a switch is actually  not nothing intelligent, but if you have a microprocessor of a computer, it's just like  switch. It's just like zeroes and ones, just activating some signals, some electrical signals.  And at the end, it's so powerful what you can do with a computer. So it's exactly the  same thing. So Hubble and Thorsten were two researchers quite advanced for their period  that they did an experiment with this poor cat. He did an amazing contribution, but  I think he wasn't really happy about that. They basically connected some sensors to his  brain, to the initial part of the visual cortex. As I was saying in my example, you are getting  these information, zeroes and ones, it's like perceived by your eyes as if they were a camera,  then they go to the visual cortex and what they were studying is this first layer of  the visual cortex. So what happens when these neurons, instead of being just a channel that  propagates the information, they start to mix one with another. So they start to build  these networks. So the idea is like, okay, probably this cat in this visual cortex is  recognizing circles like the one you can see in the experiment is probably recognizing  squares, recognizing different shapes. So they took this cat, they had the cat just looking  at shapes for many hours, looking for circles and waiting for neurons to activate. And the  funny part of the story, I don't know if you can see in this, I think it can be seen in  the screen, you can see these, those are the oldest lights, it was just a transparent paper  and they had like the shapes on that. The funny part is that the neurons of the cat,  of the visual cortex of the cat, the first layer, actually activated not because of the  circle, not because of the triangle, not because of any of the shapes, but because of the edge  of the, like the border of this paper. You can see this line over here in diagonal. That  was really what it made, it made the cat activate these neurons. So in the first layer, the  takeaway of this is that in the first layer of these neurons, of these neurons connecting  one with another, actually what it's going on is that they activate for very, very small  patterns to say, very small, just like edges in different rotations and that. Another important  experiment that Donald has, based in the Heavian theory, is that these connections on the brain  actually are, besides some of them that are, of course, when you're born, you already get  some connections in your brain, but some of them are created just because they get activated.  So if you keep watching this edge we've seen before, for many, many times, what this theory  says, this theory is a bit complex and I don't expect you to even read that, so you'll have  them in the slides. But the whole point is that if you keep activating, if you have like  an impulse, you'll see like this person, this phase, this phase, this phase, one time and  another time and once and once more, then at some point, the neurons that are activating,  the first time you see them, they become stronger and stronger and they're kind of hard coding  the information in the brain. So it's like something that you've never seen, one activate  much neurons and something that you see often they will activate much more neurons. That's  something very interesting because at the end, like memory or the learning, actually basically  everything starts from this, everything is based on seeing something and then having  it hard coded because some connections on the neurons are there and then being able to  reproduce that. So we'll see this is kind of like a bit of the history of the human brain,  what's in the human brain, now I'll go to the counterparty like code, computers are  kind of cloning all those things. I'll start this, this is just like a linear regression,  I assume that most of you know a linear regression, it's just like I got some input, let's say  that you told me your age and you told me your weight to say and I want to predict your  height, so I just multiply each of the values and then I add them together, that's a linear  regression and at some point you find if there is a correlation between these input  features and that, you get that. So this is something quite simple but at the end it's  just like a way, if you think as this, as neurons, it's a way that every neuron can  have a weight, so every input you will have more or less importance, at the end you pack  all together, you will have like a single value and what's very important in this is  that this activate function, what it does is binarize the result, at the end what you  have is that the output of this is a zero and a one. This is something similar, it's  almost a logistic regression if you ever heard about that in data science but it's still  quite powerful if you start to do that. How is it binarized? I won't talk much about that  but it's not usually taking like positive plus negative and making positive zero or  positive one and negative zero, it's usually used in this sigma functions just as a reference  that what they do is just do the same exact thing but you can take the derivative on that  and it is very key because in optimization problems when you want to build these networks  and you need to see which weights are the good ones, being able to derivate that is really  useful, how you really optimize. I'm going to talk about hopeful networks, I'm going  to cover this briefly. Hopful networks are just like networks of these artificial neurons  that everything is connected with everything. The nice properties, it's kind of something  super simple, it's nothing really, really complex. Just a linear regression you can  implement this in a single line of code and then you just connect them among them. The  nice thing is that this has a property that it's called an associative memory. What it  does is you show, as I said before, with the number five you keep showing images and then  this network is remembering the images in the same weights. In the weights of the linear  regression it's learning these weights. In this example what you can see is you have  the original image in the left is the image that you shown to the network and then at  some point you show an image that is similar to this one. The network kind of remembers  and it optimizes in a way that after several iterations what you get is the original image  again. It can be used, for example, to recover corrupted documents, corrupted images because  whatever you've shown to the network before at some point will be back to you. That's  kind of the point. If you show all this to a neuron and of course you need to a hopeful  network and of course you need a proportional number of pixels or neurons that are able  to store all this information but if you show all this at the end and you check the weights  and you represent the weights in a matrix you have something like this. It's kind of  subtle but you can see that this is like the shape of the average number and in every of  the pixels at the same time it have the average of the numbers that are activated that have  values at that pixel. So, for example, if you check on this side over here on the top  right corner you will see the number seven, number five that go in the direction. Well,  if you see, for example, in the top left you will see the number three because the number  three actually it ends up in that dimension. This is actually it's kind of more a trivial  thing but this really shows how the weights of the linear regression I was talking about  before actually are keeping information on this images. They are able to recover it later.  After hopeful networks there are Boltzmann machines that start to be the basis of deep  learning if you've heard about that, I guess you do. Boltzmann machines are the same with  the difference that in the previous example all the networks are the same as the pixels  you are getting. So, if you are giving like 20 by 20 pixels you have this network, this  neurons and this is exactly what you have to store the information. In this cases you  have like hidden neurons that they don't have a direct exposure, you won't have like  the initial perception but you will have like an indirect perception. And these are actually  much more powerful because this work as a generative network. A generative network is  something similar what we've seen before but the idea is that you've got a model that  it learns some parameters in this cases like the weights of the neurons but if you think  as a Gaussian imagine that I want to generate data that it comes from the distribution of  the height of the people in this room or the ages. So, at some point I can have like a Gaussian  distribution I say okay the mean of the age in the people in the room is 30 to say on  the standard deviation is 5. So, I can start generating samples and whatever samples I'm  getting it would be like the real samples like if it was real people that I knew the  age of the people like the same as if I get the data from people entering the room. So,  what is quite important if you do this with image recognition you can start making like  these models, these networks start to learn patterns. This is something I think it's named  like the deep dream, I think it's an experiment by Google that they started to show images  to one of these networks and what was happening is that then they say like okay now tell me  you about the data, give me this data as I was saying with the ages. Don't show me more  data, don't show me more, don't tell me about the data you have already seen generate new  one and this is what they got I'm not sure exactly what they used to train this network  but this is something generated by a computer that just seen some images I guess they saw  some animals for what you see here, these capsules I don't know exactly what they are  it looks like it also saw people maybe a temple I don't know exactly what it saw but it can  actually show again what based on the images that he's been seen. Again, just to emphasize  a bit on the example if you tell me the age and I start to assume that the distribution  is this and then I start saying numbers it's like I think a normal age would be like I  don't know 32 and 28 so this is basically what it's doing but with images which I think  is quite an interesting thing. The problem with artificial intelligence usually is that  you find these models they are super cool they are quite amazing but at some point you  realize that they are NP complete which it means that a computer would take like from  the same time as the big bang to the present day to compute all this information to get  like the optimal solution. So in practice what is being used is these restricted Boltzmann  machines that they have some properties that they don't have all the connections so they  don't really have these properties in the same way it was proved for the Boltzmann  machines but it still have mostly everything it's kind of an approximation but a good approximation  and this one can be trained somehow there are some techniques to optimize them and train  them easily which is quite nice to make things in practice. In practice you don't have just  one of these networks what you do is you have layers of networks and one connect to the  other and as I said before the first layer with the cut was just an edge you can see  this in the left you have these very small patterns that for themselves they are not  that useful but when you start to combine them in the neurons in these networks on  the next layer actually you start to have an eye you start to have a nose you start to  have things so it's kind of a sequential thing like a cascading thing that you start  with no pattern at all you start creating a small patterns at some point you have an  eye and at some point you combine eyes and you have a face and you can construct anything  you want if you have enough number of layers. I'll talk very briefly about that just to  give you an intuition on how this can be done. What you need in data science is just to have  the error so you have some data whenever you have some data you know that let's say that  you know that this is an eye or what you are looking for so you are comparing the answer  with the prediction of your network and whatever is mismatching if you are trying to predict  a cat and you don't have this cat image you compute the difference between this cat and  that this is what represent this is for a linear regression it would be much complex but imagine  that you just have that you can really compare the images that your model is generating with  the images that you want to see and based on this error you just optimize it. I was talking  about before about this derivative how these functions can be you can derivate them because  they are just linear regression with this sigma function that can be derivated and because  you know that the derivative is showing you where how you can go to the minimum point  to the point with less error so you start up to this hill and you just see okay you  derivate your result your function that you are using to estimate and then you see that  it's going down in that direction so you do a step in that direction you keep iterating  at some point you end up with a place where where the error is minimum if the error is  minimum it means that your error actually that your model actually it's performing as  expected if we're being able to reproduce cats or whatever it can it can reproduce and you  do this by layers so you start doing that in the in the last layer you check the error  and then you you do it in in a recursive way backwards this is actually from a Google experiment  they took I think it was 40,000 CPUs and they train these sort of neurons with YouTube  videos frames from YouTube videos for a whole weekend to see what was the the internal representation  that the these models were learning and what they found or what they say they found it's  this cat in one of the neurons it's look like it's what it learned and it probably makes  sense because in YouTube it's full of cats so at the end if you think on this whole thing  on how the brain is learning the neurons are changing the transformations based on the  information we see you can see the brain as a thing that that it's really the just a set  of patterns that have been learned like these shapes that if you have children play you  can recognize and at some point you have like these edges these triangles these faces and  you are only able to really recognize whatever you've seen before your brain has been trained  to to understand certain patterns and only these patterns and the one that you can really  understand and it's it's exactly what you what your brain is doing in terms of of recognition  these are very interesting experiment what they did is like you have this this picture  from from Van Gogh the one in the middle in a small and they train a deep neural network  with with this information what that that information what what it happened is that  the neural network it happened to to really get a representation of the world the neurons  were trained in a way that actually only could see in Van Gogh pictures so after that after  all the training and after all the these neurons that has been has been coded to to activate  at certain stages they shown this picture I think not sure if it's Amsterdam what's  this place and whenever you ask it tell me show me this picture that I just shown you  because the the model the the reality of the model the internal representation of the model  is just about Van Gogh what it returns actually the same exact picture but just with the with  the pattern from Van Gogh is like the the Van Gogh patterns like there is no way it can  paint like a red a red ceiling a red roof because the the neuron has never been trained  for that so I think it's it's really really interesting how how this works now I just  wanted to give like an intuition on why or what can be achieved or what's the direction  of of this whole world of artificial intelligence and and what's like the top trending but I  I would know when now to talk more about like practical applications what's really being  done as a as a data scientist nowadays today's job the first one is classification I would  say it's the most common one some something usually name a supervised learning that you  have some data and I work for this dating site but we have many problems with the spammers  people trying to abuse the system people trying to cheat on on our users and that and we need  to to detect them and block them we need to block set like like some accounts so at some  point as a data scientist you get a data set with many people reviewed profiles and they  said this is a spammer this is not a spammer this is a spammer this is not a spammer and  you have certain information you can imagine here that the y-axis is the age of the profile  and the the exact cc is whatever feature you can imagine like the I don't know it can be  the the time the user has been registered on but and you start to see that there are  some patterns that that the the kind of profile that you're looking for or the kind of data  that you're looking for fall more in one of these sites so you just need to plot like  a line or a separator so you can identify that and this can be used for like the classical  example is from a spam whenever you go to your inbox and you see some spam that has  been classified they're using the same technique just having some features they represent them  they plot a line and or whatever and at some point they they are able to distinguish which  one are the goods from the but they this is done on also on cancer prevention for example  they analyze images of tumors and they decide based on these models whether this is a cancer  or not a maling cancer or not for credit payments whether you someone is going to return your  credit you always in this sort of project that it's the most just one and the easier  to start I would say what you need is someone who really labeled or in some way that you  get labels to the data you know that certain users didn't pay that certain things like  that and and what you do is just try to replicate the same decisions that were being made you  start to replicate it in the same way a regression you probably know what exactly this quite similar  thing but let's say I want to know the price of these of this building and based on the  on the square meters it it got so you can plot all these plot all these dots and and  then you do the linear regression we can also do it in robotics I'll quickly show a video  okay you've got an idea this is like the state of the art in robotics it's a that I think  a different technique it's usually named reinforcement learning that it's a way that the robot keeps  learning based on experience so the robot it used at the beginning of the on the training  stage it keeps falling and then even if you kick it it doesn't fall wouldn't surprise me  I think the one of the concerns in artificial intelligence is whether whether robots are  going to control and make their slaves at some point I think it will make sense after seeing  how they treat this this poor robot yeah more more applications recommendation systems  whenever you go to Amazon they're using all these data science artificial techniques to  see what one customer both actually it's the same that that everybody else who is buying  this product is buying so you'll find these patterns on these association then clustering  is a is similar to what I was saying mentioning before about classification but in this case  the the whole point is that you don't know the labels you know that you have two different  types of users I'll talk about dating sites again let's say that I have the users who  are interested mostly in sex and the user that are interested mostly in sex but in a  more subtle way okay and we really want to to identify them but I don't have labels I  nobody is gonna just review them and say okay we'll have this so you have these techniques  to train models and these models at the end are able to really split the the data by itself  on finding the distance between different groups saying okay there is this group that is quite  similar but at the same time another group that is quite similar among them but they  are very different groups so it's it's about finding these patterns network analysis is  quite another interesting topic they are able to predict for example some some problems with  sicknesses like like the flu I think it was like the some of the variants of the flu that  they are started to detect based on the network of flight connections when it was gonna start  the first cases in every single country and they are predicting that with with great accuracy  also for the banking system they check like the transactions upon banks and they say okay  if this bank is defaulting this other bank is is gonna default because they make so much  transitions together image recognition it's quite challenging topics in many cases in  this case the idea is this thing which I think this is a she wow I'm not sure which kind  of dog and there is muffins and yeah deep learning is is managing to to identify which  is a muffin which is a dog even probably better than a person because in some cases it becomes  quite tricky I would say also self-driving cars is like the the state of the art probably  you've heard about them they are already in in the state in several places they are already  driving autonomously they have these cameras the sensors and they are they're really being  able to even in cities stop when there is a pedestrian who wants to close and all that  final just briefly mentioned I was mentioning before there are many projects in in Python  that you can that you can use the more famous ones you probably know already about pandas  Mumbai which is like the internal representation of of any of these software at the end you  have Jupiter and probably you already know about this one is just like a web application  it's like a Python terminal but web based and it's very useful when you are in data  science because you usually plot things so also you have pi mc3 is for by issue and probabilistic  models quite advanced one J Jensim is a pretty cool one that it's it's being used for topic  modeling so you can really find the topics of conversations what I was mentioning before  which are the topics that people is talking about so that's it I'm just a quick mention  we're thinking on organizing something related to data on on Saturday probably it would be  partly a pandas sprint so people who wants to contribute to pandas but if people is new  to pandas or new to data science we can also do a tutorial and things like that so please  get in touch with me if you're interested I'll be around on Saturday just just in case  anyone wants to contribute to these projects or or just get a tutorial or discuss about  that yeah that's it thank you very much we have a couple of minutes for questions if  we have any I guess no one really understood anything and it wasn't as gentle as I pretended  to be I don't know if my question is really related to mostly on computers but on the other  side of human brain so you said that when there is a I mean an image or a pattern that  it's already I mean at the you the observer has already seen more neurons activated than  I mean a new image so my question is why do we feel much more tired when we learn new things  at least instead of you know I would my guess would be if there are more neurons that are  activated one should be like more tired why is the opposite I didn't quite get the question  why the number of of neurons activated change so my question is you said that I was expecting  that you get more tired at least intellectually where more neurons are activated okay but if  I can I mean I would guess at the same time that when I'm learning new things I get much  more tired okay okay but why is not the case I mean well I think there are two two different  steps in this process to say one is about training I would say that when you feel tired  is because if you are seeing something new you go to your new day at job and that of  course you feel much more tired because everything is new so your neurons are actually kind of  training in this training stage so all the connections need to be activated need to be  created so you have new connections that some neurons that are not connected among them  and they are gonna get getting the activated for the first time so I would say it's related  to that and then when you are doing something repetitive it's like just your your your neurons  are just already being activated the ones you are using so it's just like the information  just flows and I'm not a neuroscientist I think it's kind of a question for more for  a neuroscientist but but yeah I think that would be probably the reason and I have another  another question do you use any other languages than Python like machine learning like the  language is designed for machine learning like Prologue or something I think all the  I don't use much other languages in than Python actually I think everybody is like using C  in there because numpy is mostly programming C there is also Cyton that it's quite the  standard for for all those things so I would say that I would use pandas I use I would  use something that is not Python for for in terms of performance because for coding actually  I love Python so I would never really like to have to use another language in some cases  there is for example TensorFlow, theano all these things some of them I think theano it's  it's probably what writing in Python but but TensorFlow it's not but usually you have  bindings and then I think Python is very good with the interaction with the user with the  programmer think it's the most beautiful code you can read is in Python more than in C or  anything else so yeah I think it's like that the training is moving there you have a stand  for example for probabilistic programming you first have R that it's quite good and  quite quite used in in in this world but in my case I'm not using anything else and I  think you can really do a lot of data science use with Python.  That's great thanks and that's all the time we have for this talk so thanks again.
Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_0_227.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_228_431.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_432_2819.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_2820_3335.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_3336_3971.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_3972_5663.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_5664_9743.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_9744_12287.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_12288_12575.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_12576_14339.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_14340_14987.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_14988_15035.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_15036_15215.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_15216_16007.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_16008_16355.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_16356_17039.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_17040_17159.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_17160_17459.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_17460_17507.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_17508_18899.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_18900_20099.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_20100_21431.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_21432_21983.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_21984_22283.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_22284_22331.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_22332_22535.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_22536_24455.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_24456_25055.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_25056_28703.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_28704_29111.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_29112_29255.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_29256_30983.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_30984_34811.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_34812_35219.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_35220_35339.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_35340_35675.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_35676_35759.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_35760_35807.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_35808_35867.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_35868_35915.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_35916_36071.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_36072_38903.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_38904_42383.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_42384_45059.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_45060_46823.png Marc_Garcia_-_A_Gentle_Introduction_to_Data_Science_jufpfjjpgUU_46824_48189.png