Machine Learning Overview

Jose Portilla
A free video tutorial from Jose Portilla
Head of Data Science, Pierian Data Inc.
4.6 instructor rating • 34 courses • 2,476,998 students

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 [Auto] 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 literally learn from data, that is to say, machine learning algorithms can actually find insights and data even if they are 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 Tenzer flow 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 tensor flow for, such as word embedding with words to EQ. 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 labels 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. I remember since this is supervised learning and its classification, we already know the labels in this case are 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 no 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 predict that male. Then there's also a regression problems. This is, again, a supervised learning technique because of 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 a house price, so that when 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 you're only using one feature. So on the x axis, we have our feature, the square feet of 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 kind of has a trend here that the larger the houses, the higher end price. So then when you get a new house whose price you don't know, but you do know it's 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 train 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 or only the features are known to attempt prediction so that can be released. Well, 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 rights 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 a 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, this 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 clustered 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 the 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 I 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 know, especially when it comes to evaluating unsupervised learning models. Now, you might be wondering, what about machine learning tasks that have heard about or read about like a computer learning to play a video game or drive a car, et cetera, and that sort of 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 of 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 car, the environment may be what it's reading in from the camera feed, such as a street, the signs, et cetera. Or if you're training a 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 car, you could say brake or hit the accelerator, turn, etc. 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 award is your high score. Then what you're going to do is have the 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 test flow in neural nets to actually solve these problems later on. Much later in the course, we'll discuss reinforcement learning, which kind of has its own particular machine learning process. It doesn't really fall quite into this general machine learning process. OK, so let's go ahead and go step by step. What a normal process looks like. First thing you 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 a previous house sales and you maybe get that from something like Zill dotcom, 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 organized 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 going to 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 the whole body, et cetera, or maybe 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 going to spent here on data cleaning. So once you do that, you do what's called a trained test split, and so you're going to 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 percent of your data be test and then 70 percent of your data be training. But it really depends on the situation, how clean your data is, how much data you have, cetera. And then we'll also discuss hold up data sets later on once you perform that train to split its 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 be use tensor flow in neural networks as our model. And you're going to 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 tests is so we don't basically cheat, since the model has already been trained on the training set, we want to 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, if your model, you can then deploy onto new incoming data. So that's a very basic approach to machine learning, acquire the data, clean data, split it into a test set and a training set, train your model on that training set, evaluate against the test set, adjust the model parameters, repeat that process until you're ready and set aside 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 you're going to end up doing instead you're going to 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, unsupervised learning, typically not going to have that test trained 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 does a really similar smell 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 hold out really differ, depending on how much they do 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 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 whole that 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 hold that data. So let's quickly dive into more details for certain problems later on in the course. So supervised learning for a 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 tests, 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. You can see here especially kind of on that second row from the top, that for humanised, it's really easy to see. Look, correct, cluster's 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 is just the 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, etc.. And again, we'll discuss this a lot more when we actually show you how to perform reinforcement learning. OK, 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.