Machine Learning Overview

A free video tutorial from Jose Portilla
Head of Data Science at Pierian Training
Rating: 4.6 out of 5Instructor rating
83 courses
3,762,398 students
Machine Learning Overview

Learn more from the full course

Complete Guide to TensorFlow for Deep Learning with Python

Learn how to use Google's Deep Learning Framework - TensorFlow with Python! Solve problems with cutting edge techniques!

14:07:23 of on-demand video • Updated April 2020

Understand how Neural Networks Work
Build your own Neural Network from Scratch with Python
Use TensorFlow for Classification and Regression Tasks
Use TensorFlow for Image Classification with Convolutional Neural Networks
Use TensorFlow for Time Series Analysis with Recurrent Neural Networks
Use TensorFlow for solving Unsupervised Learning Problems with AutoEncoders
Learn how to conduct Reinforcement Learning with OpenAI Gym
Create Generative Adversarial Networks with TensorFlow
Become a Deep Learning Guru!
English [CC]
(lively music) -: Welcome everyone to the Machine Learning overview lecture. We're now going to take a little bit of time to discuss some basic machine learning concepts and principles to set a foundation for future lectures. We're going to talk about the basics of supervised learning, unsupervised learning, reinforcement learning, some evaluation methods, and more. Unlike typical computer programs, machine learning techniques will iteratively learn from data. That is to say, machine learning algorithms can actually find insights in data, even if they aren't specifically instructed what to look for in that data. And that's what separates a machine learning algorithm from a typical computer program. You're just giving the machine learning algorithm a set of rules to follow instead of actually telling it what to look for. It will find the insights on its own. Now, in this course, we're going to be discussing how to use TensorFlow for three major types of machine learning algorithms or machine learning topics, and that is supervised learning, unsupervised learning, and reinforcement learning. We'll also touch on other topics that we can use TensorFlow for, such as word embeddings with Word2vec. So let's first discuss supervised learning. Supervised learning uses labeled data to predict the label given some features. And that's the really important part, the fact that the data is labeled. So whenever you think of supervised learning, think label. If the label is continuous, it's called a regression problem, and if it's categorical, it's called a classification problem. So let's go ahead and give an example of a classification problem which would fall under supervised learning. For your data, you'll have some features such as height and weights, and the label could be something like gender. So then your task would be, given a person's height and weight, predict their gender. So, what does this actually look like? Well, for instance, we could just plot out a couple of points here. And remember, since this is supervised learning and it's classification, we already know the labels. In this case, our labels are male and female, the genders, and we have height and weight as our features. So for a classification task, our model ends up being trained on some training data here. Then in the future, we'll get a new point who features we do know, such as we know the weight and the height, but we don't know what class it belongs to. Then our machine learning algorithm will predict, according to what it's been trained on, what class it should be. And in that case, it predicted male. Then there's also regression problems. This is, again, a supervised learning technique because a regression problem does have a given label based off historical values. Now, the only difference here is that the label instead of being categorical, such as male and female, it's continuous, such as the house price. So in this case, we'll have a data set with features, such as the square footage of a house, how many rooms it has, et cetera, and we need to predict some continuous values, such as the house price. So again, the task is, given a house the size and the number of rooms, predict the selling price of the house. So when we plot out this data, it looks like this. We have a price and, let's say, square feet. So here we're only using one feature. So on the x-axis we have our feature, the square feet of the house, indicating how big the house is, and then on the y-axis, we have the actual label that we're trying to predict. And in this case, the label is continuous because it can't be split up into categorical units instead of its continuous pricing value. So your model will end up creating some sort of fit to the data. In this case, it kinda has a trend here that the larger the house is, the higher in price. So then when you get a new house whose price you don't know, but you do know its features, such as the square footage of the house, you end up checking out your model and it returns back its predicted price. So that's how a regression supervised learning algorithm works. And again, this is a very basic example of this. So supervised learning has the model trained on historical data that is already labeled, such as those previous house sales. Once the model is trained on that historical data, it can then be used on new data where only the features are known to attempt prediction. So that can be really useful if you're a real estate agent. You can look up all the features of previous houses that have sold and then match that up to their prices, train your model, and then when a new house comes onto the market, based off its features, you can predict what price it should sell for. Now, the question arises, what if you don't have historical labels for your data? You only have features. Since you technically have no right or correct answer to fit on, that is, you have no label, you actually need to look for patterns in the data and find the structure. And this is known as an unsupervised learning problem because you don't actually have the labels. So let's walk through an example of an unsupervised learning problem. A really common unsupervised learning task is called clustering, where you're given data with just the features, no labels, and your task is to cluster it into similar groups. So for example, maybe you're given data that has as a feature, heights and weights for breeds of dogs. And however, since is unsupervised learning, you actually don't have the label. You don't know what actual breeds these are, so you have no label for the breeds, you just have the actual features, the heights and weights of these dogs. So your task is to cluster together the data into similar groups. It is then up to the data scientist or whoever is performing this machine learning task to interpret what the clusters actually means. And that usually indicates that unsupervised learning has a lot to do with domain knowledge as far as interpreting the results. So, what does this look like as a really basic example? Here we plot out all our data points for these various heights and weights of these dogs, and then after computing your clustering algorithm, you end up deciding that you have these two clusters. Your machine learning model says, hey, I think these two clusters are pretty similar to each other. But you should note that clustering isn't actually able to tell you what the group labels should be. It can't report back what actual breeds of dogs these are, all it can tell you is that these points in each cluster are similar to each other based off the features. So that's a really important thing to note, especially when it comes to evaluating unsupervised learning models. Now, you might be wondering, what about machine learning tasks that I've heard about or read about, like a computer learning to play a video game or drive a car, et cetera? And that's where reinforcement learning comes into play, and it's not quite like supervised learning or unsupervised learning. Reinforcement learning works through trial and error which actions yield the greatest rewards. So when it comes to reinforcement learning, there are three major components, that is the agent, the environment, and the actions. And we'll cover this all more in depth when we actually show you how to do reinforcement learning with Python. But to start off, the first major component is the agent, and that is the learning or decision maker. Then the agent has the environment, and that's what the agent interacts with. So for reinforcement learning, trying to learn how to drive a car or self-driving a car, the environment may be what it's reading in from the camera feed, such as the street, the signs, et cetera. Or if you're training an agent to learn how to play a video game, that would be the actual pixels on the screen that can read. Then you have actions, and that is what the agent can actually do in response to the environment. For example, self-driving a car, you could say, break or hit the accelerator, turn, et cetera. For a video game reinforcement learning, it would be what button to press based off the environment. Then, for the actual process of reinforcement learning, what occurs is that the agent will choose the actions that maximize some specified reward metric over a given amount of time. Maybe if you're training an agent to play a video game, that actual reward is your high score. Then, what you're going to do is have that agent learn the best policy with the environment, and it's going to respond with the best actions. So let's go ahead and walk through the basic machine learning process for a supervised learning problem. Then afterwards, we're going to discuss some key differences for unsupervised learning, as well as discuss holdout data sets. At the very beginning of this course, most of what we're going to cover falls under supervised learning or unsupervised learning. So it's important that we basically discuss what that whole process actually looks like because we're going to be using TensorFlow and neural nets to actually solve these problems. Later on, much later in the course, we'll discuss reinforcement learning, which kinda has its own particular machine learning process. It doesn't really fall quite into this general machine learning process. Okay, so let's go ahead and go step by step what a ML process looks like. First thing I have to do is actually acquire the data. Now, this really depends on what task you're trying to solve. If it's something like a regression problem, you need to acquire previous house sales, and you maybe get that from something like zillow.com. Or if you're trying to classify images into dogs versus cats, you need to somehow acquire the various data of images of dogs and cats. Then the next step is to clean and organize the data. So again, maybe you got those actual images, but they have too many pixels, so it's too much information and it's gonna take a really long time to train your model. So maybe you clean it down or take away edges or just try to get the faces of the dogs and the cats instead of their whole body, et cetera. Or maybe you try to do things like normalize the data, so you do some sort of standard scaling on your data. And unfortunately, a lot of your time is actually spent on cleaning the data and not so much on making the cool models. So again, most of your time is gonna spend here on data cleaning. So once you do that, you do what's called a trained test split. And so you're gonna split your data into a training set and a testing set. Now, there's lots of split ratios you can use. A really common split ratio is to have 30% of your data be test, and then 70% of your data be training. But it really depends on the situation, how clean your data is, how much data you have, et cetera. And then we'll also discuss holdout data sets later on. Once you perform that train test split, it's time to actually train or fit your model on the training data. So you'll have some sort of model, and in this case, we're going to use TensorFlow and neural networks as our model, and you're gonna train that model solely on that training set. Then, once you've trained that model, it becomes time to evaluate that model, and this is where that test set comes in. Now, the reason we use that separate test set is so we don't basically cheat. Since the model has already been trained on the training set, we wanna evaluate it fairly against data that it has never seen before, just like it would in the real world once it becomes time to deploy that model. And that's the main idea behind that test train split. So you train your model on that training data and evaluate your model on data it hasn't seen before, such as that test set. Once you've done that, you go ahead and adjust model parameters to try to get a better fit onto that test set. So again, train your model on the training data, evaluate how it performs on that test data set, and then you can make adjustments and cycle back and forth. Once you're satisfied with your model, you can then deploy it onto new incoming data. So that's a very basic approach to machine learning. Acquire the data, clean the data, split it into a test set and a training set. Train your model on that training set, evaluate it against the test set, adjust the model parameters, repeat that process until you're ready and satisfied to deploy the model. Now, let's go ahead and discuss unsupervised learning. Remember unsupervised learning, those are data sets that had no labels. So for unsupervised learning problems, most of the time, you're not actually going to do some sort of test train split because it doesn't really make sense to evaluate your model against some test set because you don't know the correct labels to evaluate against. So what you're gonna end up doing instead is you're gonna use all the data as training data, and then you're going to evaluate against the training data based off some sort of unsupervised learning metric. And we'll discuss those evaluation metrics in just a little bit. But unsupervised learning, typically not gonna have that test train split because it doesn't really make sense because you don't actually know the correct answer to evaluate against. Then finally, let's go ahead and discuss a holdout set or an evaluation set. Sometimes it's also called that. And this is a really similar ML process to a test train split, except we actually, after we clean the data, split it into three groups, a training set, a testing set, and what we call a holdout set. And again, the ratios between train test and holdout really differ depending on how much data you have and what that particular situation is, so there's no real right or wrong answer on what the ratio should be between those three sets as far as their sizes are. But the actual process is really similar to what we saw before. We take our data in, we clean it, we split it into those three sets, we train our model on the training data, and then we test our model against the test data, and then based off those results, we can adjust the model parameters, test it again, et cetera, go through that little loop. And then once we're ready to deploy our model, we have our holdout data set. Now, the purpose of the holdout data set is to try to get some sort of final metric or idea of how well your model is going to perform upon deployment. You can think of it as not trying to cheat, again, with the test data. Because, technically, we've also been adjusting model parameters against the test data, we still don't have a true sense of how well the model performs against data that it's truly never seen before and truly never been adjusted for, and that's why we have that holdout data set. Now, the main idea here is that once you evaluate your model against the holdout data set, you're not really allowed to go back and adjust the model parameters. The purpose of that holdout data set is to get some sort of final report, some sort of final metric to let you know, hey, when we deploy this to the real world, this is the sort of metrics that we're going to expect because the model has truly never seen this data before and it's never had the parameters adjusted for the data. So that's the purpose of that holdout data set. So we've been discussing a lot about model evaluation. That last step has a lot to do with evaluating against either the test data or the evaluation data, that holdout data. So let's quickly dive into more details for certain problems later on in the course. So supervised learning, for classification evaluation metrics, you have things such as accuracy, recall, and precision. And which metric is the most important really depends on the specific situation, but a lot of times in this course, we're just going to be using accuracy because it's the easiest to understand. And basically all accuracy is, is the number of correctly classified samples divided by the total number of samples given to the actual model. So again, pretty straightforward. For regression evaluation tasks, again, that falls under supervised learning. There's lots of evaluation metrics, things like mean absolute error, mean squared error, root mean squared error. Essentially, all these are just measurements of, on average, how far off are you in your prediction from the correct continuous value? So mean absolute error, mean squared error, root mean squared error, to some manner or degree, they're all trying to say the same thing. On average, your model predicts about this far off numerically. So we'll be using these metrics when we do regression tests. For unsupervised learning, as far as evaluating that model, that becomes actually much harder to evaluate and it really depends on the overall goal of the task. Again, remember, for unsupervised learning, you never really had the correct labels to compare to. However, you can use things like cluster homogeneity or something called the Rand index to evaluate your unsupervised learning model. And we'll discuss those later on in the auto-encoders section of the course. Now remember, for unsupervised learning, even if you have good metrics, your model may not have performed well. And you can see here, especially kind of on that second row from the top, that for human eyes, it's really easy to see what correct clusters should be for those kind of moon shapes. But depending on your evaluation metrics, you may get bad splits or bad clustering on your data where the metrics turn out really well, but the actual groupings don't look correct. So again, unsupervised learning, clustering, it's just a really hard problem, and evaluating it is also a really hard problem. So kind of keep that in mind as you encounter those problems in your own work. Now, for reinforcement learning, evaluation is usually a lot more obvious since that evaluation or reward metric is actually built into the actual training of the model. So it's typically just how well the model performs against the task it's assigned, so that particular score in the video game, et cetera. And again, we'll discuss this a lot more when we actually show you how to perform reinforcement learning. Okay, as a quick review, we discussed machine learning, the types of machine learning, the general machine learning process, just the basic overview, and basic overview of evaluation metrics. Hopefully that gives you a nice little foundation to work off as we continue the rest of the course. Thanks, and I'll see you at the next lecture.