English (United States) subtitles

← Extracting Information from sklearn - Intro to Machine Learning

Get Embed Code
5 Languages

Showing Revision 1 created 10/10/2016 by Udacity Robot.

  1. Before we move on from this coding example I want to show you just
  2. a couple more things that help make your regression as useful as it can be.
  3. The first thing is you might want to be able to make a prediction with it.
  4. And of course this is something that shouldn't be that difficult.
  5. For that you can just call the prediction function on your regression.
  6. But here's one little catch, it's going to be expecting a list of values.
  7. So even if you only have one value that you want to be predicting.
  8. You still need to put it in a list.
  9. You might also be wondering what the coefficients and
  10. the intercept of the regression are.
  11. And you can access these using reg.coef_ and
  12. reg.intercept_ like you can see here.
  13. Don't forget this little underscore here.
  14. Otherwise it won't know what you're talking about.
  15. Just remember the slope we expected to be pretty close to 6.25.
  16. But maybe not exact.
  17. And the intercept should be close to zero, but
  18. again, we wouldn't expect it to be exactly right,
  19. because there's a little bit of noise in our, in our training data.
  20. There are a few more lines here about the r squared score.
  21. Let me come back to that in just a second.
  22. But I want to show you what the prediction, the coefficients, and
  23. the intercept are right away.
  24. So these three lines are the ones we were just talking about.
  25. I can predict my net worth, based on the regression.
  26. It's about 160, based on my age.
  27. We can also print out the slope and the intercepts.
  28. Remember we thought the slope would be about 6.25.
  29. It's close, but not exact.
  30. Similarly for the intercept, it's not quite zero.
  31. In the next few videos we're going to talk a lot about the types of errors that
  32. you can get on regressions.
  33. Because they're fundamentally different from the types of
  34. errors that you get in classification.
  35. And where we're eventually going,
  36. is we're going to be computing something called the r squared.
  37. Now, the next few lines give you some output about the performance of
  38. your regression.
  39. So one way you can evaluate a regression, that we'll be talking about
  40. much more in the videos to come is a metric called the R squared.
  41. There's also the sum of the errors, we'll be talking about all of these.
  42. But let me show you just what it looks like now.
  43. So you have some reason to understand why it's important.
  44. The way that you access these performance metrics is using
  45. something called the score function performed on your regression.
  46. And you always want to be looking at the score on your testing data.
  47. Because of course you're fitting your regression using your training data.
  48. So if there's any over fitting going on that'll show up in
  49. having a lower score when you look at your testing data.