We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Machine Learning for dummies with Python

00:00

Formal Metadata

Title
Machine Learning for dummies with Python
Title of Series
Part Number
3
Number of Parts
169
Author
License
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
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Javier Arias Losada - Machine Learning for dummies with Python Machine Learning is the next big thing. If you are a dummy in terms of Machine Learning, but want to get started with it... there are options. Still, thanks to the Web, Python and OpenSource libraries, we can overcome this situation and do some interesting stuff with Machine Learning. ----- Have you heard that Machine Learning is the next big thing? Are you a dummy in terms of Machine Learning, and think that is a topic for mathematicians with black-magic skills? If your response to both questions is 'Yes', we are in the same position. Still, thanks to the Web, Python and OpenSource libraries, we can overcome this situation and do some interesting stuff with Machine Learning.
11
52
79
Multiplication signMereologyVirtual machineArithmetic meanVideo gameSoftware developerOffice suiteDigital photographySpring (hydrology)Film editingGoodness of fitLecture/Conference
Ext functorVideo gameRoutingMultiplication signFirmwareRevision controlInheritance (object-oriented programming)Generic programmingView (database)Uniformer RaumOffice suiteComputer animation
DistanceMusical ensembleCasting (performing arts)Lecture/Conference
Video gameMachine learningPresentation of a groupVirtual machineCategory of beingPresentation of a groupMusical ensembleBitDigital photographyFlickrComputer architectureMachine learningArea
Presentation of a groupMachine learningArithmetic meanVirtual machineObservational studyExpert systemElement (mathematics)Lecture/ConferenceComputer animation
Sample (statistics)Presentation of a groupMachine learningVirtual machineVirtual machineOpen setLibrary (computing)Video gameOpen sourceSource codeTheorySampling (statistics)Machine codeLecture/ConferenceJSON
Machine learningMachine learningDependent and independent variablesPattern recognitionAlgorithmGoodness of fitSummierbarkeitMedical imagingVirtual machineComputer animation
Game theorySimilarity (geometry)Medical imagingAlgorithmComputer chessGame theoryNumberMultiplication signSoftware testingAtomic numberDeep Blue (chess computer)Universe (mathematics)Software developerLecture/ConferenceComputer animation
Inclusion mapComplex (psychology)Spring (hydrology)AlgorithmGoogolLecture/Conference
Game theoryAlpha (investment)GoogolVirtual machineMathematical singularityPredictabilityMoment (mathematics)Multiplication signRhombusBitObservational studyComputer animation
Row (database)Machine learningContent (media)E-learningOpen setMassMachine learningVideoconferencingPattern recognitionInternet forumInternet service providerVirtual machineArithmetic meanInteractive televisionLine (geometry)Scalar field1 (number)MathematicsUniverse (mathematics)Lecture/Conference
Reading (process)Electronic mailing listMultiplication signMachine learningVirtual machineLecture/Conference
Computer programmingClassical physicsNatural numberoutputPredictabilityMachine learningComputer animation
Computer programmingComplex numberMedical imagingComplex (psychology)Pattern recognitionInsertion lossImage resolutionCASE <Informatik>Revision controlRule of inferenceScaling (geometry)Lecture/ConferenceComputer animation
Machine learningComputerAlgorithmWave packetComputerNeuroinformatikVirtual machineMultiplication signLevel (video gaming)MathematicsPoint (geometry)View (database)Execution unitPrice indexSpacetimeLecture/ConferenceComputer animation
Sample (statistics)AlgorithmView (database)Point (geometry)Level (video gaming)Virtual machineOptical character recognitionAlgorithmOrder (biology)MeasurementCorrespondence (mathematics)10 (number)Machine learningMedical imagingLecture/ConferenceComputer animation
AlgorithmWave packetPredictionNetwork topologyDecision theoryVector spaceInheritance (object-oriented programming)Wave packetMultiplication signMedical imagingWater vaporCombinational logicEvent horizonProjective planeAlgorithmTheoryModemProcess (computing)MereologyMultilaterationVirtual machineFitness functionConfiguration spaceLecture/ConferenceComputer animation
Open sourceDifferent (Kate Ryan album)AlgorithmProcess (computing)PredictionWave packetData modelClefMaizeMetropolitan area networkProgrammer (hardware)State of matterDataflowTensorGraph (mathematics)MathematicsVertex (graph theory)Operator (mathematics)Array data structureArtificial neural networkDifferent (Kate Ryan album)Video gameEndliche ModelltheorieFormal languageWordPredictabilityDataflowAlgorithmOperator (mathematics)Sinc functionRevision controlSet (mathematics)Functional (mathematics)Maxima and minimaWeightVector potentialImplementationFunction (mathematics)MultiplicationArtificial neural networkFitness functionLocal ringOpen sourceLinear regressionLogistic distributionResultantWave packetMetric systemSemantics (computer science)AdditionConfiguration spaceMeasurementSelectivity (electronic)Software testingRandomizationMoment (mathematics)State of matterWater vaporMedical imagingScalar fieldRight angleMatching (graph theory)Level (video gaming)Speech synthesisCycle (graph theory)Event horizonPattern recognitionClassical physicsDemosceneSystem callMereologyLibrary (computing)Coordinate systemMachine codeLine (geometry)Multiplication signVirtual machineMatrix (mathematics)Pattern languageGoodness of fitProduct (business)Graph (mathematics)Machine learningHydraulic jumpAuthorizationImperative programmingOcean currentHeegaard splittingOptical character recognitionImage processingComputer animation
Virtual machineFreewareGoodness of fitOpen sourceComputer animation
DemonCategory of beingLoop (music)Core dumpNatural languagePrototypeMultiplication signDifferent (Kate Ryan album)Physical systemDependent and independent variablesLevel (video gaming)Endliche ModelltheorieComputer hardwareCASE <Informatik>Library (computing)Process (computing)SoftwareFunctional (mathematics)Virtual machineArtificial neural networkAlgorithmComputer graphics (computer science)Multiple Regression4 (number)FrequencyRevision controlFormal languageActive contour modelRight angleMoment (mathematics)Vector spaceSampling (statistics)Graph coloringMereologyType theoryComputer animationMeeting/Interview
Transcript: English(auto-generated)
Good afternoon, everyone. It's my pleasure to introduce Javier Arias, who's a senior developer at Telefónica in Barcelona, here in Spain, and he's gonna be talking about machine learning for the means using Python, of course.
Do you hear me well during the back? Yeah, it's okay? Okay, if not, please let me know, because if I lower my voice, let me take part of the contest, of the photos, because, police, also for my mama.
Okay, this could be a day in your life.
This could be today. It's about time to leave the office, and your phone tells you the best route to go home. It's fun, because you never told your phone
where home is, or what's the appropriate time to leave the office. In fact, on Fridays, the phone will tell you the best route to your parents' home, because on Fridays, you visit your parents. So, you go to a parking, and you happen to be a happy Tesla owner.
Not that everybody of us can beat, but let's imagine for a minute. In the latest version of the firmware's car, there is an autopilot feature. With autopilot, the car is able to keep the lane by moving the steering wheel, keep the speed,
and the distance with the rest of the cars. And not only that, the car is able to learn, not only from its own experiences, but from experiences from the Teslas from around the world. So, you get home, and you want to play some music, but you don't feel like choosing any music,
so you trust on Spotify to play some music for you that you don't know, but you actually like. While listening to the music, you check your photos, which are very well organized in categories like here,
with architecture and arts, but you never tag them. It was Flickr that is able to look inside your photos and see what's inside, and tag them accordingly. These things are happening daily to thousands, or even millions of people from around the world, and all of them have something in common.
Do you know what it is? It's machine learning. Machine learning is already in your life. It's everyone around us, and it will be very important in the next years. So, what's this presentation about?
I'll try to explain a little bit why machine learning is so important for us as users, as engineers, and for companies, and for the rest of the world. Also, I'll try to explain about my journey with machine learning. My name is Javier Diaz, and I am a backend engineer.
Six months ago, I didn't know anything about machine learning, and I'm not an expert. It would need years of study and practice to do so, but you can get started pretty quick,
and do very interesting and funny things, because there are many technologies and many resources around that are free, that are open source, and of course, using Python and libraries with Python. And also, I'll try to explain some very basic machine learning concepts,
and we'll see a couple of code samples. So, as many of you know, machine learning will be very important during the next years, but one of the first questions that came to my mind when starting with it is, is really machine learning intelligent?
Are these algorithms already better than us? And the response is that in some concrete questions, in some concrete aspects, machines and algorithms are already better than us. One example of that is image recognition. ImageNet is hosting a yearly challenge
on machine learning, on image recognition, and the performance of the winner algorithms have been improving a lot during the last years, thanks to the adoption of deep learning and this kind of technologies. In 2015, the winner algorithm performed better than human at recognizing things inside images.
Something similar happened to chess about 20 years ago, when IBM's Deep Blue defeated the world champion, Garry Kasparov. I remember vividly reading about this in the news, and reading it in the newspaper.
It was 20 years ago, maybe. That's why some colleagues tell me that I'm a senior developer. But there are, it was quite a milestone at the time, but there are other games that are much more complex than chess. For example, the game of Go. The game of Go is so complex
that the number of movements is bigger than the number of atoms in the universe. For such a complex game, it was thought, for such a complex game, it's very important to play with intuition. And for that reason, many people thought that algorithms could never win the champions,
until this spring, when AlphaGo by Google defeated the world champion, Lucidor. This thing, algorithms being better than us, and concrete tasks, are happening more and more frequently. And for that reason, many people are making
apocalyptic predictions on the moment that machines will be more intelligent than us. It's the singularity point. But, okay, I don't want to be so apocalyptic. I want to talk to you about my journey. As I said, six months ago, I didn't know anything about machine learning,
and I thought that it would take weeks or months of study just to get started. But that's not true. If you are a dummy like me, you don't know anything about machine learning, you can get started, and in a little bit of time, you can get very useful and very surprising things, at least for me.
When I started, I decided to study, not by using courses or books, but by using massive open online courses. And these courses have videos and exercises, and there are different providers. There are forums where you can discuss with other people
about the things you are doing. And there are many different providers, so you have to do your research here. What I chose was the Udacity Introduction to Machine Learning. But it could be any other one, which will fit for you. It's very well organized, and it's using Python and Sklearn, and this was a plus for me.
And also, for me, it was very important that you can do it at your own pace, because I can't stick to deadlines. So this was a plus for me. And one thing that caught my attention was the subtitle, which is Battle Recognition for Fun and Profit.
I can't imagine about the profit, but what about the fun? And the course starts like this. A couple of friends sharing a bottle of wine, not bad. And it ends like this, with same friends and more wine. So it seems that machine learning can also be fun after all.
So what is machine learning? I want to explain very basic concepts and some insights that, many times, are not well explained or just overlooked when you start with machine learning. I think that there are things that are important, at least for me, I want to share them with you.
Of course, this is not a short course, and you should learn and read books and do courses and these things. But when we work in machine learning, we want to solve a complex problem. So we have something here in the middle. And you have some inputs, which is the data.
Machine learning is features. And we have to do a prediction, which is the outcome of this thing here in the middle. The first approach, classical approach, is programming. Probably all of us here know how to program. So you have to understand your problem, and you have to explain it step by step,
in baby steps, to the computer, so that it can follow your steps to achieve the solution. But the problem is that, for very complex domains, such as image recognition, medicine, these kind of things, this doesn't scale.
Because let's imagine that we have to solve something for medicine. Medicine, maybe you have to quote thousands and thousands of rules, and these rules are not exact, because medicine is not an exact science. So maybe you have conflicts, and you have to solve them.
And it's very difficult to solve. But if you use machine learning, the approach is totally different. Instead of explaining the computer, what are the steps to solve the problem, you show the computer some real world data, some examples of data, and you let the algorithm learn,
and take its own conclusions from the data. This has huge implications, and it's that we can teach computers to do things that we don't know how to do. And I'll show you that in some minutes.
So I'll try to explain from a user point of view, I'm not going to enter into mathematical details, because I studied mathematics something like 23 years ago, and I couldn't remember, but I'll try to explain from the point of view of users
how machine learning works at a high level. And we will solve an example for character recognition. So we will have thousands of images like this, each one is containing a character, a letter. And we will have the labels telling us that the first letter is an F,
the second an E, and so on. So the first step in machine learning is getting our data. We have that blue image that corresponds to an F there, the yellow image, which is a G, and so on. Second step is to choose an algorithm. Lorena, in the talk before this,
was talking about Naive Bayes, but there are many, many tens or maybe hundreds of algorithms out there. There is super vector machines, or k-means, decision trees, neural networks, many of them. And you have to choose. And there are different algorithms
that can be a good fit for your project. And also, these algorithms can be configured. So you have to choose a combination of algorithms and configuration. So this is part of the machine learning art. And then you train your algorithm.
For training the algorithm, you start by showing some images, and you say, okay, this blue image is an F. And this yellow image is a G, and so on. In some respect, it's like showing a baby to read.
It's like teaching a baby to read. First step is to get predictions. So you show new data to the algorithm, and it will tell you, okay, I think this is a D. But the tricky question here is, is that letter really a D?
Is our algorithm predicting correctly the letters inside? We will answer this question later. So we have a lot of tools, and we have different languages, such as MATLAB and R,
but here we're going to talk about Python, of course. And I don't have to share here the beauty of Python, but it's a very good fit, and it's following its own philosophy of patterns included. There are many, many libraries with very good quality
that will help you to solve problems very easily. And we will solve the character recognition problem using Python, and SKlearn is one of the most popular libraries out there. It's open-source with Python, and the documentation is wonderful,
not just for the library, but just as a reference of algorithms and methodologies and everything. And SKlearn gives support to the full life cycle of machine learning. So we will solve this problem. We will do the following steps.
We will get the features with labels. We already have the data. We will choose and configure an algorithm. We will be using logistic regression with no configuration. We will train the algorithm. Then we will do predictions, and then we will validate them.
So let's get started with the example. We have this big dataset here. It's thousands of images with the labels. We want to separate them in two different datasets. One dataset is for training. The other is for testing, for validating our results. And we will use train test split function from SKlearn,
and we will split our dataset and labels. We will give a size for our training dataset. Size matters, but we will not explain why here. And there is a random state that happens to be a constant,
and this shocked me in the very beginning. Why the hell are we giving a random state that happens to be a constant? And the answer is that the train test split will separate our big dataset in a random set of images for the training and the test.
But by passing this constant, the selection of images for each dataset will be the same always, so that we can compare different configuration of the algorithms or different algorithms. Then we initialize our algorithm, logistic regression, no configuration,
and we do the fit. The fit is the training, and we pass the training dataset and the labels. This is the part where we teach the baby to read. But it's very easy. We don't have to iterate and do things. SKlearn does it for us. To do predictions, we just call the predict function
on our classifier, and that's all. But the question is if our predictions were good or bad. To solve this question, we will use accuracy. There are many different ways in machine learning, but we will use accuracies. It's the simplest one, and we don't have time for more.
So what we do is do predictions on our test dataset, and we have some test predictions. What we do is compare the test labels, which is the ground truth, the things we know are truth, to the test predictions. And this way we know the percentage of images
that we have been predicting correctly. With this example I just gave you, we got 89% of accuracy. This means that of 500, 5,000 images, we're predicting, well, 90% almost.
In just five lines of code. And this is what I mentioned before. I never did image recognition or image processing. It would take me weeks or months to implement such a thing without machine learning. And we did it here in 20 minutes together.
Of course we can improve these results. We can play with training data, as Lorena from the previous talk mentioned before. We can change the algorithm and the configurations. And this is very easy using SKlearn, because the APIs for the different algorithms is almost the same.
And you can give SKlearn different configurations for one algorithm, and it will test all the different configurations and give you the best one. So we already seen this very simple example
with classical machine learning. Currently I'm doing another course at Udacity of deep learning. I just did the very first lesson, and I did the first exercise of couple of exercises. And I want to present them to you,
because I think that it's part of code that you more or less can understand. I'm not going to explain neural networks, and please don't ask it, because I don't know anything about it. But I think that you can get an intuition on how we are going to structure the code.
So this is the course I'm still doing, so I'm going to run. We will use TensorFlow, which is a library by Google, and who is the author of the course as well. And it seems that deep learning is not so fun, because there is no wine in the course for the moment,
but I'm still in the first two lessons. I will, I keep my hope. So we will be using TensorFlow, and I'll jump directly to the code. The difference between SKlearn and TensorFlow is that SKlearn is using an imperative API,
and in TensorFlow what you do is describe a set of mathematical operations in a kind of graph, and then you execute that graph with your data. So you have to know what are the mathematical operations to implement your neural network.
So please don't make questions about this, but this is the simplest possible neural network in the world. This is two layers, neural network, and here in the left we have an image, X, and there on the right, you're right,
we have a prediction. The prediction is a matrix with a set of probabilities for each letter. So we will pick the letter with more probability. And the implementation is very easy. The image is a matrix, and we will do the matrix multiplied by a matrix of weights
and we will add another matrix, which is the bias, and we will apply a ReLU function, which is a kind of filter. This is what I understood from the first lesson. And you have then, you are making a pipe. The result from each one is going to be piped to the next.
Then we go to the second layer, which is again a matrix multiplication, an addition of a bias, and we will get a matrix of weights. And then we will do a softmax, which is a function that transforms a set of weights in a set of probabilities.
So the implementation, it's very simple. It's, if you remember, you have, remember, please? What we do is, we do a multiplication of matrices, of our test dataset with the first matrix of weights
for the first layer, and we add the biases. This is layer one logits. And then we apply the ReLU on the layer one logits. And we will have the output for the first layer. Then we repeat. We do the matrix multiplication,
and then the addition, and then, whoop. And then we apply the softmax over the output of the previous operation. And this is the implementation of a simple neural network. This is the production neural network.
You have to train it so that you can have these different matrices with correct values for your problem, and it's much more complex, and maybe next year I will explain that. So this is what I wanted to share with you. The idea is that, I'll do a very quick summary.
Machine learning is here, already in our lives. And it will become very important for everybody. So if you are a dummy like me, machine learning, don't be afraid. You can do very funny things with the resources and tools
that we have there outside, with very good quality. Free open source to use, and you can do very funny things. So if you want to use them and do interesting things, just do it for your own profit, and of course for fun. Thank you.
Time for questions.
Thank you. Compared to regression analysis,
neural networks are known to be, better take a lot of time. But in your experience, at least you're using Python. It's not as fast as C++.
Thank you for the question. So, in my experience, the question is that, as I understand the question, and correct me if I'm wrong, the question is that how compares the performance
from the first example and from the second, and also how compares that with the performance with other languages, such as C++. And the response is very easy for me, because I'm not sure what to answer, but in my experience, the performance of the,
at least for these neural networks, is more than enough. And there have been many advances in last year, with the adoption of graphic GPUs,
and different algorithms. For example, the ReLU function we are using here, instead of sinusoidal functions, have made possible to train very complex networks. In any case, I don't know how it compares with C++ or others, but what is sure,
that if you want to train very complex models, you will need very, very expensive hardware. But you can play with it with just a small laptop, in my experience. Thank you.
I also have a small question. Like, there are a lot of tools with different level of support, for example, which provide basically API for machine learning, like API.ai, Watson from IBM, something from Google. My question is, have you used them, and is it worth to play around with them?
For example, for text recognition, they do a lot of interesting stuff, as well as they claim to. Or is it better to just develop something on your own? Thank you. I don't have a lot of experience with that system. I just, some weeks ago, I did a small prototype
of a chatbot, using natural language processing libraries from Microsoft, in that case. And my experience is that these models are already very well trained for very specific purposes. And if you have the time and money,
and if you're a core business, probably it's better for you to train your own models and have people specialized. If it's some side thing, it's not main core business, you don't have the money, probably these already built models are more than good enough for you,
but for very specific things, you will not have already trained things. But it's my experience. Thank you. Questions? So at 5.15, we've got some lightning talks.
Otherwise, tomorrow at 9 a.m., there will be a fantastic keynote by Paul Indurant, who will be talking about the use of Python at Walt Disney, and I'm told it's a great talk. So I encourage you all to come. Let's thank the speakers again. Thank you.