From the course: Applied Machine Learning: Supervised Learning

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Solution: Goldilocks model

Solution: Goldilocks model

- [Instructor] Okay, let's look at a solution for this. What I'm going to do is I'm going to come up here and I'm going to take this code right here that has our pipeline and K-Fold score. We're going to paste it right down here, and then I'm going to loop over these max depth values. So I'm going to say best depth is zero and best accuracy is zero. And then you're going to say for depth in range, and we'll go from one to 15. So again, because Python has that half open interval, we have to say 16 here. Does not include 16, but goes up to, but not including that. We'll take the rest of this code here, just indent it. (keyboard clicking) And then I'm going to change this max depth here to depth. We'll get our scores here, we'll get the mean score. (keyboard clicking) So that's going to be cv_scores.mean. And then you're going to say if the mean accuracy is greater than the best accuracy, then the best depth is equal to depth and the best accuracy is equal to the mean accuracy. Okay, and…

Contents