8.13 Anomaly Detection | Choosing what features to use -- [Machine Learning| Andrew Ng]
 When building an anomaly detection algorithm, I found that choosing a good choice of features turns out to be really important. In supervised learning, if you don't have the features quite right, or if you have a few extra features that are not relevant to the problem, that often turns out to be okay because the algorithm has the supervised signal, that is enough labels y for the algorithm to figure out what features ignore or how to rescale a feature and to take the best advantage of the features you do give it. But for anomaly detection, which runs or learns just from unlabeled data, it's harder for the algorithm to figure out what features to ignore. So I've found that carefully choosing the features is even more important for anomaly detection than for supervised learning approaches. Let's take a look at this video at some practical tips for how to tune the features for anomaly detection to try to get you the best possible performance. One step that can help your anomaly detection algorithm is to try to make sure the features you give it are more or less Gaussian. And if your features are not Gaussian, sometimes you can change it to make it a little bit more Gaussian. Let me show you what I mean. If you have a feature x, I will often plot a histogram of the feature, which you can do using the Python command plt.his. You see this in the practice lab as well. In order to look at a histogram of the data. This distribution here looks pretty Gaussian. So this would be a good candidate feature if you think this is a feature that helps distinguish between anomalies and normal examples. But quite often when you plot a histogram of your features, you may find that a feature has a distribution like this. This does not at all look like that symmetric bell shaped curve. When that is the case, I would consider if you can take this feature x and transform it in order to make it more Gaussian. For example, maybe if you were to compute the log of x and plot a histogram of log of x, it'll look like this and this looks much more Gaussian. And so if this feature was feature x1, then instead of using the original feature x1, which looks like this on the left, you might instead replace that feature with log of x1 to get this distribution over here. Because when x1 is made more Gaussian, when anomaly detection models p of x1 using a Gaussian distribution like that is more likely to be a good fit to the data. Other than the log function, other things you might do is given a different feature x2, you may replace it with x2 log of x2 plus one. This would be a different way of transforming x2. And more generally, log of x2 plus c would be one example of a formula you can use to change x2 to try to make it more Gaussian. Or for a different feature, you might try taking a square root or really the square root of x cubed is x3 to the power of one half and you may change that exponentiation term. So for a different feature x4, you might use x4 to the power of one third, for example. So when I'm building an anomaly detection system, I'll sometimes take a look at my features and if I see any of the highly non-Gaussian by plotting a histogram, I might choose transformations like these or others in order to try to make it more Gaussian. It turns out a larger value of c will end up transforming this distribution less. But in practice, I just try a bunch of different values of c and then try to take a look to pick one that looks better in terms of making the distribution more Gaussian. Now let me illustrate how I actually do this in a Jupyter notebook. So this is what the process of exploring different transformations in the features might look like. When you have a feature x, you can plot a histogram of it as follows. It actually looks like, um, this is a pretty coarse histogram. Let me increase the number of bins in my histogram to 50. So bins equals 50. There that's my histogram bins. Oh, and by the way, if you want to change the color, you can also do so as follows. And if you want to try a different transformation, you can try, for example, to plot x square root of x. So x to the power of 0.5 with again, 50 histogram bins, in which case it might look like this. And this actually looks somewhat more Gaussian, but not perfectly. And let's try a different parameter. So let me try to the power of 0.25. Maybe I adjusted a little bit too far. Still 0.4. That looks pretty Gaussian. So one thing you could do is replace x with x to the power of 0.4. And so you would set x to be equal to x to the power of 0.4 and just, you know, use the value of x in your training process instead. Well, let me show you another transformation. Here I'm going to try taking the log of x. So log of x, let's plot it with 50 bins. I'm going to use the NumPy log function as follows. And oops, it turns out you get an error because it turns out that x in this example has some values that are equal to 0 and well, log of 0 is negative infinity is not defined. So common trick is to add just a very tiny number there. So x plus 0.001 becomes non-negative. And so you get a histogram that looks like this. But if you want the distribution to look more Gaussian, you can also play around with this parameter to try to see if there's a value that causes the data to look more symmetric and maybe look more Gaussian as follows. And just as I'm doing right now in real time, you can see that you can very quickly change these parameters and plot the histogram in order to try to take a look and try to get something a bit more Gaussian than was the original data x that you saw in this histogram up above. If you read the machine learning literature, there are some ways to automatically measure how close these distributions are to Gaussians, but I found that in practice, it doesn't make a big difference. If you just try a few values and pick something that looks right to you, that will work well for our practical purposes. So by trying things out in a Jupyter Notebook, you can try to pick a transformation that makes your data more Gaussian. And just as a reminder, whatever transformations you apply to the training set, please remember to apply the same transformation to your cross validation and test set data as well. Other than making sure that your data is approximately Gaussian, after you've trained your anomaly detection algorithm, if it doesn't work that well on your cross validation set, you can also carry out an error analysis process for anomaly detection. In other words, you can try to look at where the algorithm is not yet doing well, where it's making errors, and then use that to try to come up with improvements. So as a reminder, what we want is for p of x to be large for normal examples x, so greater than or equal to epsilon, and p of x to be small or less than epsilon for the anomalous examples x. When you've learned to model p of x from your unlabeled data, the most common problem that you may run into is that p of x is comparable in value, say is large for both normal and for anomalous examples. As a concrete example, if this is your data set, you might fit that Gaussian to it. And if you have an example in your cross validation set or test set that is over here, that is anomalous, then this has a pretty high probability. And in fact, it looks quite similar to the other examples in your training set. And so even though this is an anomaly, p of x is actually pretty large. And so the algorithm will fail to flag this particular example as an anomaly. In that case, what I would normally do is try to look at that example and try to figure out what is it that made me think is an anomaly, even if this feature x1 took on values similar to other training examples. And if I can identify some new feature, say x2, that helps distinguish this example from the normal examples, then adding that feature can help improve the performance of the algorithm. Here's a picture showing what I mean. If I can come up with a new feature x2, say I'm trying to detect fraudulent behavior, and if x1 is the number of transactions they make, maybe this user looks like they're making similar transactions as everyone else. But if I discover that this user has some insanely fast typing speed, and if I were to add a new feature x2, that is the typing speed of this user. And if it turns out that when I plot this data using the old feature x1 and this new feature x2 causes x2 to stand out over here, then it becomes much easier for the anomaly detection algorithm to recognize that x2 is an anomalous user. Because when you have this new feature x2, the learning algorithm may fit a Gaussian distribution that assigns high probability to points in this region, a bit lower in this region, and a bit lower in this region. And so this example, because of the very anomalous value of x2, becomes easier to detect as an anomaly. So just to summarize, the development process I'll often go through is to train a model and then to see what anomalies in the cross validation set the algorithm is failing to detect. And then to look at those examples to see if that can inspire the creation of new features that would allow the algorithm to spot that. That example takes on unusually large or unusually small values on the new features so that it can now successfully flag those examples as anomalies. Just as one more example, let's say you're building an anomaly detection system to monitor computers in a data center to try to figure out if a computer may be behaving strangely and deserves a closer look, maybe because of a hardware failure or because it's been hacked into or something. So what you'd like to do is to choose features that might take on unusually large or small values in the event of an anomaly. You might start off with features like x1 is the memory use, x2 is number of disk accesses per second, then the CPU load and the volume of network traffic. And if you train the algorithm, you may find that it detects some anomalies but fails to detect some other anomalies. In that case, it's not unusual to create new features by combining old features. So for example, if you find that there's a computer that is behaving very strangely, that neither is CPU load nor network traffic is that unusual. But what is unusual is it has a really high CPU load while having a very low network traffic volume. If you're running a data center that streams videos, then computers may have high CPU load and high network traffic or low CPU load and no network traffic. But what's unusual about this one machine is it has very high CPU load despite a very low traffic volume. In that case, you might create a new feature x5, which is a ratio of CPU load to network traffic. And this new feature would help the anomaly detection algorithm flag future examples like the specific machine you may be seeing as anomalous. Or you can also consider other features like the square of the CPU load divided by the network traffic volume. And you can play around with different choices of these features in order to try to get it so that p of x is still large for the normal examples, but it becomes small in the anomalies in your cross validation set. So that's it. Thanks for sticking with me to the end of this week. I hope you enjoyed hearing about both clustering algorithms and anomaly detection algorithms and that you also enjoy playing with these ideas in the optional labs and the practice labs. Next week, we'll go on to talk about recommender systems. When you go to a website and it recommends products or movies or other things to you, how does that algorithm actually work? This is one of the most commercially important algorithms in machine learning that gets talked about surprisingly little. But next week, we'll take a look at how these algorithms work so that you understand the next time you go to a website and it recommends something to you, maybe how that came about as well as you be able to build other algorithms like that for yourself as well. So have fun with the labs and I look forward to seeing you next week.
[{"start": 0.0, "end": 8.28, "text": " When building an anomaly detection algorithm, I found that choosing a good choice of features"}, {"start": 8.28, "end": 11.040000000000001, "text": " turns out to be really important."}, {"start": 11.040000000000001, "end": 15.08, "text": " In supervised learning, if you don't have the features quite right, or if you have a"}, {"start": 15.08, "end": 20.8, "text": " few extra features that are not relevant to the problem, that often turns out to be okay"}, {"start": 20.8, "end": 26.52, "text": " because the algorithm has the supervised signal, that is enough labels y for the algorithm"}, {"start": 26.52, "end": 32.08, "text": " to figure out what features ignore or how to rescale a feature and to take the best"}, {"start": 32.08, "end": 35.36, "text": " advantage of the features you do give it."}, {"start": 35.36, "end": 41.4, "text": " But for anomaly detection, which runs or learns just from unlabeled data, it's harder for"}, {"start": 41.4, "end": 44.519999999999996, "text": " the algorithm to figure out what features to ignore."}, {"start": 44.519999999999996, "end": 49.239999999999995, "text": " So I've found that carefully choosing the features is even more important for anomaly"}, {"start": 49.239999999999995, "end": 53.239999999999995, "text": " detection than for supervised learning approaches."}, {"start": 53.24, "end": 58.32, "text": " Let's take a look at this video at some practical tips for how to tune the features for anomaly"}, {"start": 58.32, "end": 61.84, "text": " detection to try to get you the best possible performance."}, {"start": 61.84, "end": 67.48, "text": " One step that can help your anomaly detection algorithm is to try to make sure the features"}, {"start": 67.48, "end": 71.92, "text": " you give it are more or less Gaussian."}, {"start": 71.92, "end": 77.88, "text": " And if your features are not Gaussian, sometimes you can change it to make it a little bit"}, {"start": 77.88, "end": 78.88, "text": " more Gaussian."}, {"start": 78.88, "end": 81.4, "text": " Let me show you what I mean."}, {"start": 81.4, "end": 89.56, "text": " If you have a feature x, I will often plot a histogram of the feature, which you can"}, {"start": 89.56, "end": 94.68, "text": " do using the Python command plt.his."}, {"start": 94.68, "end": 97.72, "text": " You see this in the practice lab as well."}, {"start": 97.72, "end": 101.34, "text": " In order to look at a histogram of the data."}, {"start": 101.34, "end": 104.10000000000001, "text": " This distribution here looks pretty Gaussian."}, {"start": 104.10000000000001, "end": 109.04, "text": " So this would be a good candidate feature if you think this is a feature that helps"}, {"start": 109.04, "end": 114.12, "text": " distinguish between anomalies and normal examples."}, {"start": 114.12, "end": 119.04, "text": " But quite often when you plot a histogram of your features, you may find that a feature"}, {"start": 119.04, "end": 121.54, "text": " has a distribution like this."}, {"start": 121.54, "end": 127.32000000000001, "text": " This does not at all look like that symmetric bell shaped curve."}, {"start": 127.32000000000001, "end": 136.48000000000002, "text": " When that is the case, I would consider if you can take this feature x and transform"}, {"start": 136.48, "end": 139.79999999999998, "text": " it in order to make it more Gaussian."}, {"start": 139.79999999999998, "end": 147.0, "text": " For example, maybe if you were to compute the log of x and plot a histogram of log of"}, {"start": 147.0, "end": 152.6, "text": " x, it'll look like this and this looks much more Gaussian."}, {"start": 152.6, "end": 159.12, "text": " And so if this feature was feature x1, then instead of using the original feature x1,"}, {"start": 159.12, "end": 165.79999999999998, "text": " which looks like this on the left, you might instead replace that feature with log of x1"}, {"start": 165.8, "end": 168.84, "text": " to get this distribution over here."}, {"start": 168.84, "end": 177.96, "text": " Because when x1 is made more Gaussian, when anomaly detection models p of x1 using a Gaussian"}, {"start": 177.96, "end": 182.68, "text": " distribution like that is more likely to be a good fit to the data."}, {"start": 182.68, "end": 187.52, "text": " Other than the log function, other things you might do is given a different feature"}, {"start": 187.52, "end": 193.28, "text": " x2, you may replace it with x2 log of x2 plus one."}, {"start": 193.28, "end": 197.92, "text": " This would be a different way of transforming x2."}, {"start": 197.92, "end": 204.92000000000002, "text": " And more generally, log of x2 plus c would be one example of a formula you can use to"}, {"start": 204.92000000000002, "end": 209.08, "text": " change x2 to try to make it more Gaussian."}, {"start": 209.08, "end": 213.6, "text": " Or for a different feature, you might try taking a square root or really the square"}, {"start": 213.6, "end": 219.88, "text": " root of x cubed is x3 to the power of one half and you may change that exponentiation"}, {"start": 219.88, "end": 221.24, "text": " term."}, {"start": 221.24, "end": 227.74, "text": " So for a different feature x4, you might use x4 to the power of one third, for example."}, {"start": 227.74, "end": 232.76000000000002, "text": " So when I'm building an anomaly detection system, I'll sometimes take a look at my features"}, {"start": 232.76000000000002, "end": 239.64000000000001, "text": " and if I see any of the highly non-Gaussian by plotting a histogram, I might choose transformations"}, {"start": 239.64000000000001, "end": 243.64000000000001, "text": " like these or others in order to try to make it more Gaussian."}, {"start": 243.64, "end": 251.32, "text": " It turns out a larger value of c will end up transforming this distribution less."}, {"start": 251.32, "end": 257.28, "text": " But in practice, I just try a bunch of different values of c and then try to take a look to"}, {"start": 257.28, "end": 262.64, "text": " pick one that looks better in terms of making the distribution more Gaussian."}, {"start": 262.64, "end": 267.5, "text": " Now let me illustrate how I actually do this in a Jupyter notebook."}, {"start": 267.5, "end": 272.03999999999996, "text": " So this is what the process of exploring different transformations in the features might look"}, {"start": 272.04, "end": 273.84000000000003, "text": " like."}, {"start": 273.84000000000003, "end": 279.52000000000004, "text": " When you have a feature x, you can plot a histogram of it as follows."}, {"start": 279.52000000000004, "end": 284.08000000000004, "text": " It actually looks like, um, this is a pretty coarse histogram."}, {"start": 284.08000000000004, "end": 287.84000000000003, "text": " Let me increase the number of bins in my histogram to 50."}, {"start": 287.84000000000003, "end": 291.32000000000005, "text": " So bins equals 50."}, {"start": 291.32000000000005, "end": 292.76, "text": " There that's my histogram bins."}, {"start": 292.76, "end": 300.68, "text": " Oh, and by the way, if you want to change the color, you can also do so as follows."}, {"start": 300.68, "end": 308.28000000000003, "text": " And if you want to try a different transformation, you can try, for example, to plot x square"}, {"start": 308.28000000000003, "end": 309.28000000000003, "text": " root of x."}, {"start": 309.28000000000003, "end": 318.52, "text": " So x to the power of 0.5 with again, 50 histogram bins, in which case it might look like this."}, {"start": 318.52, "end": 323.64, "text": " And this actually looks somewhat more Gaussian, but not perfectly."}, {"start": 323.64, "end": 325.64, "text": " And let's try a different parameter."}, {"start": 325.64, "end": 331.32, "text": " So let me try to the power of 0.25."}, {"start": 331.32, "end": 333.76, "text": " Maybe I adjusted a little bit too far."}, {"start": 333.76, "end": 334.84, "text": " Still 0.4."}, {"start": 334.84, "end": 336.12, "text": " That looks pretty Gaussian."}, {"start": 336.12, "end": 342.47999999999996, "text": " So one thing you could do is replace x with x to the power of 0.4."}, {"start": 342.47999999999996, "end": 349.71999999999997, "text": " And so you would set x to be equal to x to the power of 0.4 and just, you know, use the"}, {"start": 349.71999999999997, "end": 353.59999999999997, "text": " value of x in your training process instead."}, {"start": 353.6, "end": 356.64000000000004, "text": " Well, let me show you another transformation."}, {"start": 356.64000000000004, "end": 359.48, "text": " Here I'm going to try taking the log of x."}, {"start": 359.48, "end": 366.16, "text": " So log of x, let's plot it with 50 bins."}, {"start": 366.16, "end": 370.12, "text": " I'm going to use the NumPy log function as follows."}, {"start": 370.12, "end": 376.56, "text": " And oops, it turns out you get an error because it turns out that x in this example has some"}, {"start": 376.56, "end": 383.12, "text": " values that are equal to 0 and well, log of 0 is negative infinity is not defined."}, {"start": 383.12, "end": 389.18, "text": " So common trick is to add just a very tiny number there."}, {"start": 389.18, "end": 393.6, "text": " So x plus 0.001 becomes non-negative."}, {"start": 393.6, "end": 396.76, "text": " And so you get a histogram that looks like this."}, {"start": 396.76, "end": 401.08, "text": " But if you want the distribution to look more Gaussian, you can also play around with this"}, {"start": 401.08, "end": 408.4, "text": " parameter to try to see if there's a value that causes the data to look more symmetric"}, {"start": 408.4, "end": 412.48, "text": " and maybe look more Gaussian as follows."}, {"start": 412.48, "end": 418.92, "text": " And just as I'm doing right now in real time, you can see that you can very quickly change"}, {"start": 418.92, "end": 424.8, "text": " these parameters and plot the histogram in order to try to take a look and try to get"}, {"start": 424.8, "end": 433.92, "text": " something a bit more Gaussian than was the original data x that you saw in this histogram"}, {"start": 433.92, "end": 434.92, "text": " up above."}, {"start": 434.92, "end": 439.64000000000004, "text": " If you read the machine learning literature, there are some ways to automatically measure"}, {"start": 439.64, "end": 445.0, "text": " how close these distributions are to Gaussians, but I found that in practice, it doesn't make"}, {"start": 445.0, "end": 446.0, "text": " a big difference."}, {"start": 446.0, "end": 450.4, "text": " If you just try a few values and pick something that looks right to you, that will work well"}, {"start": 450.4, "end": 452.8, "text": " for our practical purposes."}, {"start": 452.8, "end": 459.3, "text": " So by trying things out in a Jupyter Notebook, you can try to pick a transformation that"}, {"start": 459.3, "end": 461.91999999999996, "text": " makes your data more Gaussian."}, {"start": 461.91999999999996, "end": 468.2, "text": " And just as a reminder, whatever transformations you apply to the training set, please remember"}, {"start": 468.2, "end": 473.44, "text": " to apply the same transformation to your cross validation and test set data as well."}, {"start": 473.44, "end": 480.32, "text": " Other than making sure that your data is approximately Gaussian, after you've trained your anomaly"}, {"start": 480.32, "end": 487.7, "text": " detection algorithm, if it doesn't work that well on your cross validation set, you can"}, {"start": 487.7, "end": 493.32, "text": " also carry out an error analysis process for anomaly detection."}, {"start": 493.32, "end": 498.0, "text": " In other words, you can try to look at where the algorithm is not yet doing well, where"}, {"start": 498.0, "end": 504.0, "text": " it's making errors, and then use that to try to come up with improvements."}, {"start": 504.0, "end": 512.8, "text": " So as a reminder, what we want is for p of x to be large for normal examples x, so greater"}, {"start": 512.8, "end": 519.2, "text": " than or equal to epsilon, and p of x to be small or less than epsilon for the anomalous"}, {"start": 519.2, "end": 520.6, "text": " examples x."}, {"start": 520.6, "end": 526.92, "text": " When you've learned to model p of x from your unlabeled data, the most common problem that"}, {"start": 526.92, "end": 533.4, "text": " you may run into is that p of x is comparable in value, say is large for both normal and"}, {"start": 533.4, "end": 535.5999999999999, "text": " for anomalous examples."}, {"start": 535.5999999999999, "end": 542.92, "text": " As a concrete example, if this is your data set, you might fit that Gaussian to it."}, {"start": 542.92, "end": 549.76, "text": " And if you have an example in your cross validation set or test set that is over here, that is"}, {"start": 549.76, "end": 552.7199999999999, "text": " anomalous, then this has a pretty high probability."}, {"start": 552.72, "end": 557.5600000000001, "text": " And in fact, it looks quite similar to the other examples in your training set."}, {"start": 557.5600000000001, "end": 563.6, "text": " And so even though this is an anomaly, p of x is actually pretty large."}, {"start": 563.6, "end": 568.44, "text": " And so the algorithm will fail to flag this particular example as an anomaly."}, {"start": 568.44, "end": 576.1600000000001, "text": " In that case, what I would normally do is try to look at that example and try to figure"}, {"start": 576.16, "end": 584.8399999999999, "text": " out what is it that made me think is an anomaly, even if this feature x1 took on values similar"}, {"start": 584.8399999999999, "end": 587.9599999999999, "text": " to other training examples."}, {"start": 587.9599999999999, "end": 597.1999999999999, "text": " And if I can identify some new feature, say x2, that helps distinguish this example from"}, {"start": 597.1999999999999, "end": 603.48, "text": " the normal examples, then adding that feature can help improve the performance of the algorithm."}, {"start": 603.48, "end": 605.76, "text": " Here's a picture showing what I mean."}, {"start": 605.76, "end": 612.84, "text": " If I can come up with a new feature x2, say I'm trying to detect fraudulent behavior,"}, {"start": 612.84, "end": 620.24, "text": " and if x1 is the number of transactions they make, maybe this user looks like they're making"}, {"start": 620.24, "end": 623.08, "text": " similar transactions as everyone else."}, {"start": 623.08, "end": 630.72, "text": " But if I discover that this user has some insanely fast typing speed, and if I were to"}, {"start": 630.72, "end": 635.48, "text": " add a new feature x2, that is the typing speed of this user."}, {"start": 635.48, "end": 640.6800000000001, "text": " And if it turns out that when I plot this data using the old feature x1 and this new"}, {"start": 640.6800000000001, "end": 647.9200000000001, "text": " feature x2 causes x2 to stand out over here, then it becomes much easier for the anomaly"}, {"start": 647.9200000000001, "end": 653.04, "text": " detection algorithm to recognize that x2 is an anomalous user."}, {"start": 653.04, "end": 658.48, "text": " Because when you have this new feature x2, the learning algorithm may fit a Gaussian"}, {"start": 658.48, "end": 663.88, "text": " distribution that assigns high probability to points in this region, a bit lower in this"}, {"start": 663.88, "end": 667.12, "text": " region, and a bit lower in this region."}, {"start": 667.12, "end": 674.52, "text": " And so this example, because of the very anomalous value of x2, becomes easier to detect as an"}, {"start": 674.52, "end": 675.52, "text": " anomaly."}, {"start": 675.52, "end": 683.0, "text": " So just to summarize, the development process I'll often go through is to train a model"}, {"start": 683.0, "end": 688.52, "text": " and then to see what anomalies in the cross validation set the algorithm is failing to"}, {"start": 688.52, "end": 689.8, "text": " detect."}, {"start": 689.8, "end": 695.4, "text": " And then to look at those examples to see if that can inspire the creation of new features"}, {"start": 695.4, "end": 699.4799999999999, "text": " that would allow the algorithm to spot that."}, {"start": 699.4799999999999, "end": 705.92, "text": " That example takes on unusually large or unusually small values on the new features so that it"}, {"start": 705.92, "end": 709.68, "text": " can now successfully flag those examples as anomalies."}, {"start": 709.68, "end": 714.76, "text": " Just as one more example, let's say you're building an anomaly detection system to monitor"}, {"start": 714.76, "end": 720.52, "text": " computers in a data center to try to figure out if a computer may be behaving strangely"}, {"start": 720.52, "end": 725.08, "text": " and deserves a closer look, maybe because of a hardware failure or because it's been"}, {"start": 725.08, "end": 727.24, "text": " hacked into or something."}, {"start": 727.24, "end": 731.64, "text": " So what you'd like to do is to choose features that might take on unusually large or small"}, {"start": 731.64, "end": 735.2, "text": " values in the event of an anomaly."}, {"start": 735.2, "end": 740.56, "text": " You might start off with features like x1 is the memory use, x2 is number of disk accesses"}, {"start": 740.56, "end": 745.76, "text": " per second, then the CPU load and the volume of network traffic."}, {"start": 745.76, "end": 753.0799999999999, "text": " And if you train the algorithm, you may find that it detects some anomalies but fails to"}, {"start": 753.0799999999999, "end": 755.9599999999999, "text": " detect some other anomalies."}, {"start": 755.9599999999999, "end": 762.0, "text": " In that case, it's not unusual to create new features by combining old features."}, {"start": 762.0, "end": 769.04, "text": " So for example, if you find that there's a computer that is behaving very strangely,"}, {"start": 769.04, "end": 774.12, "text": " that neither is CPU load nor network traffic is that unusual."}, {"start": 774.12, "end": 781.0, "text": " But what is unusual is it has a really high CPU load while having a very low network traffic"}, {"start": 781.0, "end": 782.5999999999999, "text": " volume."}, {"start": 782.5999999999999, "end": 788.4, "text": " If you're running a data center that streams videos, then computers may have high CPU load"}, {"start": 788.4, "end": 792.64, "text": " and high network traffic or low CPU load and no network traffic."}, {"start": 792.64, "end": 796.9599999999999, "text": " But what's unusual about this one machine is it has very high CPU load despite a very"}, {"start": 796.9599999999999, "end": 798.7199999999999, "text": " low traffic volume."}, {"start": 798.72, "end": 803.12, "text": " In that case, you might create a new feature x5, which is a ratio of CPU load to network"}, {"start": 803.12, "end": 804.32, "text": " traffic."}, {"start": 804.32, "end": 810.1600000000001, "text": " And this new feature would help the anomaly detection algorithm flag future examples like"}, {"start": 810.1600000000001, "end": 814.12, "text": " the specific machine you may be seeing as anomalous."}, {"start": 814.12, "end": 822.32, "text": " Or you can also consider other features like the square of the CPU load divided by the"}, {"start": 822.32, "end": 824.6800000000001, "text": " network traffic volume."}, {"start": 824.68, "end": 830.1999999999999, "text": " And you can play around with different choices of these features in order to try to get it"}, {"start": 830.1999999999999, "end": 838.8, "text": " so that p of x is still large for the normal examples, but it becomes small in the anomalies"}, {"start": 838.8, "end": 841.0799999999999, "text": " in your cross validation set."}, {"start": 841.0799999999999, "end": 842.0799999999999, "text": " So that's it."}, {"start": 842.0799999999999, "end": 844.7199999999999, "text": " Thanks for sticking with me to the end of this week."}, {"start": 844.7199999999999, "end": 850.68, "text": " I hope you enjoyed hearing about both clustering algorithms and anomaly detection algorithms"}, {"start": 850.68, "end": 856.3199999999999, "text": " and that you also enjoy playing with these ideas in the optional labs and the practice"}, {"start": 856.3199999999999, "end": 858.52, "text": " labs."}, {"start": 858.52, "end": 862.4799999999999, "text": " Next week, we'll go on to talk about recommender systems."}, {"start": 862.4799999999999, "end": 867.66, "text": " When you go to a website and it recommends products or movies or other things to you,"}, {"start": 867.66, "end": 870.88, "text": " how does that algorithm actually work?"}, {"start": 870.88, "end": 876.68, "text": " This is one of the most commercially important algorithms in machine learning that gets talked"}, {"start": 876.68, "end": 879.16, "text": " about surprisingly little."}, {"start": 879.16, "end": 883.16, "text": " But next week, we'll take a look at how these algorithms work so that you understand the"}, {"start": 883.16, "end": 888.1999999999999, "text": " next time you go to a website and it recommends something to you, maybe how that came about"}, {"start": 888.1999999999999, "end": 893.24, "text": " as well as you be able to build other algorithms like that for yourself as well."}, {"start": 893.24, "end": 909.84, "text": " So have fun with the labs and I look forward to seeing you next week."}]