
Title:
Extracting Information from sklearn  Intro to Machine Learning

Description:

Before we move on from this coding example I want to show you just

a couple more things that help make your regression as useful as it can be.

The first thing is you might want to be able to make a prediction with it.

And of course this is something that shouldn't be that difficult.

For that you can just call the prediction function on your regression.

But here's one little catch, it's going to be expecting a list of values.

So even if you only have one value that you want to be predicting.

You still need to put it in a list.

You might also be wondering what the coefficients and

the intercept of the regression are.

And you can access these using reg.coef_ and

reg.intercept_ like you can see here.

Don't forget this little underscore here.

Otherwise it won't know what you're talking about.

Just remember the slope we expected to be pretty close to 6.25.

But maybe not exact.

And the intercept should be close to zero, but

again, we wouldn't expect it to be exactly right,

because there's a little bit of noise in our, in our training data.

There are a few more lines here about the r squared score.

Let me come back to that in just a second.

But I want to show you what the prediction, the coefficients, and

the intercept are right away.

So these three lines are the ones we were just talking about.

I can predict my net worth, based on the regression.

It's about 160, based on my age.

We can also print out the slope and the intercepts.

Remember we thought the slope would be about 6.25.

It's close, but not exact.

Similarly for the intercept, it's not quite zero.

In the next few videos we're going to talk a lot about the types of errors that

you can get on regressions.

Because they're fundamentally different from the types of

errors that you get in classification.

And where we're eventually going,

is we're going to be computing something called the r squared.

Now, the next few lines give you some output about the performance of

your regression.

So one way you can evaluate a regression, that we'll be talking about

much more in the videos to come is a metric called the R squared.

There's also the sum of the errors, we'll be talking about all of these.

But let me show you just what it looks like now.

So you have some reason to understand why it's important.

The way that you access these performance metrics is using

something called the score function performed on your regression.

And you always want to be looking at the score on your testing data.

Because of course you're fitting your regression using your training data.

So if there's any over fitting going on that'll show up in

having a lower score when you look at your testing data.