 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, this wants 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 come from or where artificial intelligence come 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 booth 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 your visual eyes a bit to really be able to show what I want to tell. It's kind of a silly example. It's 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. 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. Okay, if you imagine this, then hold 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 these 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 zeros and ones 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 our thoughts, all our perceptions, everything. 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 nothing intelligent but if you have a microprocessor of a computer, it's just like switch, it's just like zeros and ones, it's 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 Torsten 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, zeros 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, it's 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 these altes lights that 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 is 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 Hepp is based in the Heppian theory is that these connections on the brain actually are, besides some of them, are of course when you are 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 have them in the slides. But the whole point is that if you keep activating, if you have like an impulse, you 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, when the first time you see them, they become stronger and stronger and they are 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 how computers are kind of cloning, cloning all those things. I'll start this, my son, I'll check it. 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 break 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 fitters and that, you get that. So this is something quite simple, but at the end it's just like a way, if you think of this as neurons, it's a way that every neuron can have a weight, so every input you will have 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 binarizes 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 has it been 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 these sigmoid functions, just as a reference, that what they do is just do kind of 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 on these and you need to see which weights are the good ones, being able to derivate that, it's really useful, it's 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. And the nice properties, everything is super simple. It's nothing 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 is named an associative memory. What it does is like 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 like you have the original image. In the left is the image that you show to the network. And then at some point you show an image that is similar to this one. And the network kind of remembers and it optimizes in a way that after several iterations, what you get is the original image again. So it can be used, for example, to recover corrupted documents, corrupted images, because whatever you've shown to the network before, at some point it will be back to you. That's kind of the point. If you show all this to a neuron, and of course you need a proportionate number of pixels of neurons that are able to store all this information, but if you show all this at the end and you check the weights 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 has 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 that direction. If you see, for example, in the top left, you will see the number three, because the number three actually 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 regressions I was talking about before actually are keeping information on these 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, 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 these neurons and this is exactly what you have to store the information. In these cases, you have hidden neurons that they don't have a direct exposure. You won't have the initial perception, but you will have 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 these 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. At some point I can have, like, a Gaussian distribution, I say, okay, the mean of the age and the people in the room is 30, to say, and 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 these 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 how much it's been seen. Just to emphasise 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'll find these models, they are super cool, they are quite amazing, but at some point you'll realise que el computador és de la mateixa manera que el Big Bang per la present d'aigua per computar la informació per obter la solució optimal. En pràcticament, el que ha estat just són les màxines restrictives que tenen algunes propietaris que no tenen les connexions i que no tenen aquelles propietaris de la mateixa manera que es produeixen per les màxines de vols, però encara hi ha moltes coses. És una aproximació, però una bona aproximació, i això pot ser traïnt. Hi ha unes tecniques per optimitzar-ho i trair-ho més fàcilment, que és molt bo fer-ho en pràcticament. En pràcticament, no tens només una de les màxines, només tenen lliures de màxines i una connexió amb l'altra. I, com he dit abans, la primera màxina amb la cadua és justa. Vostè pot veure això a la esquerda. Vostè tenen aquestes pèrdues que, per a ells, no són tan fàcils, però quan comencen a convèncer-los en les màxines, en aquestes màxines, en la segona màxina, actualment, et comencen a tenir una màxina, et comencen a tenir una màxina, et comencen a tenir coses. És una cosa de sequència, una cosa de cascada que comencen amb una màxina no patent. Et comencen a crear petites màxines, en algun moment hi ha una màxina, i en algun moment hi ha una màxina i hi ha una fase, i hi pots construir el que vulguis, si hi ha una altra quantitat de màxines. Vull parlar molt de això, just per donar-li una intuïsió de com això pot ser fet, però el que necessites en data science és just de tenir l'error. Tu tens alguna data, quan tens alguna data, et diràs que això és una altra, o el que veus, per comparar l'answer amb la predicció de la teva màxina. I, si ets mismatxant, si ets tentant de predictar una màxina i no tens una màxina, computeu la diferència entre aquesta màxina i això. Això és per una regressió línia, és molt complex, però imagina't que tu just tens això. Tu pots comparar les imatges que el model genera amb les imatges que et vols veure. I, a base d'aquest error, just optimitzes-ho. I jo parlava abans de aquest derivatif, com aquestes funcions... Tu pots derivar-los perquè són justes regressions línies amb aquesta funcció segona que pot ser derivada. I, perquè el derivatif, el derivatif és demostrant com pots anar al mínim punt, al punt amb poc d'error. Aleshores, et comença a aquesta màxina i just dius que et derivaràs el resulte, la funcció que usas per estimar-ho, i després veus que és baixant en aquella direcció. Aleshores, et diràs en aquella direcció, et diràs que, a algun punt, aniràs amb un lloc en què l'error és mínim. Si l'error és mínim, és a dir que el model que es formi és expectat, si es poden reproduir càrregues, o el que pot reproduir. I tu facis això a les línies. Aleshores, et comences a fer això a l'última línia, et veus l'error, i després et veus en una recursiva manera. Aquesta és, actualment, d'una experimenta de Google. Vaig prendre, crec, 40.000 CPUs i traien aquestes sortes de neurons amb videoclips de YouTube, frames de videoclips de YouTube, per una segona setmana, per veure què era l'interna representació que aquests models tenien. I el que van fer, o el que van fer, és aquest càrregue, en un de les neurons, que sembla que és el que va fer l'error. I potser es pot fer sens, perquè en YouTube és full de càrregues. Aleshores, si pensem en aquesta cosa, en què el cervell és l'error, els neurons són canviant les transformacions a base de l'informació que veiem, pots veure el cervell com una cosa que és just un set de patterns que han estat estudiats, com aquestes shapes, que, si tens pares, pots reconèixer-ho. I, a un moment, tens aquestes âges, aquestes triangles, aquestes fases, i tu només pots reconèixer el que has vist abans. El teu cervell ha estat traient unes patterns certes, i només aquestes patterns són les que pots entendre. I és exactament el que el teu cervell és fent en termes de recognització. Aquest és un experiment molt interessant. El que van fer és que tens aquesta foto de Van Gogh, l'una a la mida, en una xarxa, i traien una altra neta neural amb aquesta informació. Aquesta informació, el que va fer és que la neta neural ha passat a la repressió del món. Les neurons tenien una manera que només podien veure pictures de Van Gogh. Aleshores, després de tot el entrenament i després de totes aquestes neurons que han estat codificades per activar. A certes estats, han vist aquesta foto. No sé si és Amsterdam o què és aquest lloc. I, quan es va ensenyar, em va ensenyar aquesta foto que he vist, perquè la realitat de la model, la representació interna de la model, és només sobre Van Gogh. El que retorna és la mateixa exacte foto, però només amb un patent de Van Gogh. És com el patent de Van Gogh. No hi ha una manera que es canta a una rècorda, una rècorda rècorda, perquè la neural ha never been trained for that. És molt, molt interessant com això funciona. Ara, jo just volia donar una intuïsió de què pot ser achievat o què és la direcció d'aquesta tota la rècorda d'artificial intel·ligència i què és el top trencament. Però ara vull parlar més de les aplicacions pràctiques, què ha de ser fet com una data científica en el lloc d'avui dia. La primera és la clasificació. Jo diria que és la més commona, una cosa que és una supervisa d'ajuntament, que hi ha alguna data. Jo treballo d'aquesta data d'aigua. Hi ha molts problemes amb espàmeres, persones intentant abusar el sistema, persones intentant conèixer-ho als nostres usos. I hem de detectar-los i bloquejar-los. Hem de bloquejar-los, com a alguns accounts. A un moment, en una data científica hi ha una data set en què moltes persones rebuten profiles i diuen que és una espàmera, no és una espàmera, no és una espàmera, no és una espàmera. I hi ha certes informacions. Imagineu aquí que la y-axis és l'aigua del profe i l'aigua és el que feta el que pots imaginar. No ho sé, potser és el temps que l'user ha registrat. I veus que hi ha patències que el profe que veus o el data que veus falla més en l'una d'aquestes sèries. Per això cal plotar una línia o un separator. Per això ho podem identificar. I això pot ser just per l'exemple clàssic de la espàmera, quan vas a l'inbox i veus una espàmera que ha estat classificada, et veus utilitzant la mateixa línia. Just enllà de tenir uns fitos, representar-los, plotar una línia o altres altres altres altres altres i, a un moment, s'haurien de distinguir quins són els bons del debat. Això és donat també a la prevenció de cancer. Per exemple, analitzen imatges de tumors i decideixen, basant-se en aquests models, si això és cancer o no, si és mal cancer o no, per païments de crèdit, si algú retornarà el seu crèdit. En aquest sort de projecte, que és l'únic i l'anàlisi de començar, vull dir, el que necessites és algú que realment labulti o, en alguna manera, que et faci labultar a la data. Vostè sap que certes users no pateixen, que certes coses així. I el que has de fer és replicar les mateixes decisions que haurien fet, i ho veus replicant en el mateix lloc. A la regressió, probablement s'haurien de saber exactament una cosa similar, però vull dir, vull saber el preu de l'anàlisi de l'anàlisi de crèdit, i, a base de les altres metres d'esquadra, ho hem fet. Aleshores, pots plorar tots aquests dots, i després et facis una regressió línica. També podem fer-ho en robòtics. Vull explicar un vídeo. T'has fet una idea. Aquest és l'estat d'art en robòtics. És una diferent tecnic. És una reforma d'enforçament, que és una manera que el robot segueix en l'experiència. El robot es utilitza al principi de l'estat d'enforçament. Es segueix fallant. I després, si et posa, no es falla. No em sorprèn. Una de les conseqüències en l'artificial intel·ligència és si els robots controlaran i es posen a l'estat d'esquadra. Jo crec que es farà senz després de veure com es tracta aquest robòtics. Més aplicacions, sistemes de recomanació, quan vas a Amazon, es utilitza totes aquestes dades d'artifices, artífics artificials, per veure què un customer, both, és el mateix que algú d'譑 increases que aquest producte que balloons, es compleixen aquestes dades de recomanació. I pak About classification és similar a Byt, però, en aquest cas, el lloc és que no els coneixes els labels. Tu has oir dos darrersproduction de slugs per a l'autodeterminació, el que prenegen per clar és que he d'anar els uns que estarm interessant a arr��ar res Calm發능 sexual i laireix français bak. Okay, and we really want 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 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 about finding these patterns. Network analysis is quite another interesting topic. They are able to predict, for example, some problems with sicknesses like the flu. I think it was like some of the variants of the flu, that they 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 great accuracy. Also for the banking system, they check the transactions upon banks and they say, okay, if this bank is defaulting, this other bank is gonna default because they make so much transition together. Image recognition. It's quite challenging topics in many cases. In this case, the idea is distinguished. I think this is a Xihuahua, not Turkey, which kind of dog. And there is muffins. And deep learning is managing 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 state of the art. Probably you've heard about them. They are already in the state in several places. They are already driving autonomously. They have these cameras, these sensors. And they are really being able to, even in cities, stop when there is a pedestrian who wants to cross and all that. Final, just briefly mention, I was mentioning before, there are many projects in Python that you can use. The more famous ones you probably know already about pandas, NumPy, which is like the internal representation of any of these software at the end. You have Jupyter, probably you already know about this one. It's 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 PyMC3s for Bayesian probabilistic models, quite advanced one. Gensim is a pretty cool one that it's being used for topic modelling. 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 of organising something related to data 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 in case anyone wants to contribute to these projects 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. Have we have any? I guess no one really understood anything. I'm afraid it wasn't as gentle as I pretended. Maybe you both in the field. Hi. 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, I mean, an image or a pattern that it's already... I mean, the user server 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, 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 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, but why is not the case, I mean... Well, I think there are 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 created. So you have new connections, some neurons that are not connected among them and they are going to get 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 neurons are just already being activated, the ones you are using, so it's just like the information just flows. I'm not a neuroscientist. I think it's kind of a question for more for a neuroscientist, but yeah, I think that would be probably the reason. And I have another question. Do you use any other languages than Python, like machine learning, like the language is designed for machine learning, like ProLoc or something? I think all the... I don't use much other languages than Python, actually. I think everybody is like using C in the... because Numpa is mostly programming C. There is also Cyton, that it's quite the standard for all those things. So I would say that I would use Pandas. I would use something that is not Python 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 is partly writing in Python, but TensorFlow, it's not. But usually you have bindings. At the end, I think Python is very good with the interaction with the user, with the programmer, I think it's the most beautiful code you can read in Python, more than in C or anything else. So, yeah, I think it's like the trainee is moving there. You have a stand, for example, for ProLocistic programming. You have R, that it's quite good and quite used 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 just with Python. That's great, thanks. That's all the time we have for this talk, so thanks again.