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.
قبل أن نترك هذه التعليمة البرمجية المثال أريد أن أوضح لكم
بضعة أمور إضافية لمساعدتكم في تحقيق أقصى منفعة من الانحدار.
الأمر الأول هو أنكم قد ترغبون في أن تكونوا قادرين على استخدامه في القيام بتنبؤ.
وهذا بالطبع لن يكون صعبًا جدًا.
يمكنكم طلب دالة التنبؤ للانحدار.
ولكن توجد صعوبة بسيطة هنا، وهي أنها ستنتظر قائمة بالقيم.
لذا حتى إذا كان لديكم قيمة واحدة فقط لإجراء التوقع بشأنها،
فسيتعين عليكم وضعها في قائمة.
قد تتساءلون أيضًا عن قيمتي المعاملات
والتقاطع للانحدار.
ويمكنكم الوصول إليهما باستخدام reg.coef
وreg.intercept_ كما ترون هنا.
ولا تنسوا وضع الشرطة السفلية الصغيرة هذه.
وإلا لن يفهم ما تريدون.
تذكروا فحسب أننا توقعنا أن تكون قيمة الميل قريبة جدًا من 6.25.
لكن قد لا تكون مساوية تمامًا.
ويجب أن تكون قيمة التقاطع قريبة من الصفر، ولكن
مجددًا، لا نتوقع أن تكون مساوية تمامًا،
لأنه يوجد بعض التشويش في بيانات التدريب الخاصة بنا.
كما يوجد بعض الأسطر هنا حول نتيجة r تربيع.
سوف أعود إلى هذا بعد ثوانٍ.
ولكنني أريد أن أريكم مباشرة هو قيم التنبؤ والمعاملات
والتقاطع.
هذه الأسطر الثلاثة هي التي كنا نتحدث عنها للتو.
أستطيع التنبؤ بصافي القيمة الخاص بي بناءً على الانحدار.
وهو يبلغ 160 تقريبًا، وفقًا لعمري.
كما يمكننا أيضًا طباعة الميل والتقاطعات.
تذكروا أننا افترضنا أن قيمة الميل ستكون قريبة من 6.25.
وهي قريبة ولكنها ليست مساوية تمامًا.
وبالمثل بالنسبة للتقاطع، فقيمته ليست صفرًا بالضبط.
وفي مقاطع الفيديو القليلة التالية سنتحدث مطولاً عن أنواع الأخطاء التي
قد تحدث في الانحدارات.
لأنها في الأساس تختلف عن أنواع الأخطاء التي
تحدث في التصنيف.
وفي آخر الأمر، سنتجه إلى
حساب شيء يطلق عليه اسم r تربيع.
الآن، تعطيكم الأسطر القليلة التالية بعض المخرجات تتعلق بأداء
الانحدار.
وبالتالي، تعد إحدى الطرق التي يمكنكم من خلالها تقييم الانحدار، وسوف نتحدث عنها
أكثر في مقاطع الفيديو القادمة، هي قياس يسمى R تربيع.
ويوجد أيضًا طريقة أخرى وهي مجموع الأخطاء، وسوف نتحدث عن جميع هذه الطرق.
ولكن دعوني أريكم فقط الآن كيف تبدو.
كي تفهموا السبب وراء كونها هامة.
طريقة الوصول إلى قياسات الأداء هذه تكون باستخدام
ما يسمى بدالة النتيجة التي يتم تنفيذها على الانحدار.
ويجب دائمًا أن تنظروا إلى النتيجة الموجودة في بيانات الاختبار.
لأنكم بالطبع تستخدمون بيانات التدريب الخاصة بكم لملاءمة الانحدار.
لذا إن كانت هناك أي ملاءمة زائدة تحدث، فسوف تظهر في صورة
الحصول على نتائج أقل عند النظر إلى بيانات التدريب الخاصة بكم.
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.
Antes de sair deste exemplo de codificação, quero mostrar a você apenas
algumas coisas que podem tornar sua regressão mais útil.
A primeira coisa é que talvez você precise fazer uma previsão com ela.
E, naturalmente, isso não deve ser tão difícil.
Para isso, você pode simplesmente chamar a função predict em sua regressão.
Mas aqui há uma pequena armadilha; ela esperará uma lista de valores.
Portanto, mesmo que você tenha apenas um valor que deseja prever,
ainda precisará colocá-lo em uma lista.
Pode ser que você também queira saber quais são os coeficientes e
a interceptação da regressão.
Você pode acessar esses dados usando reg.coef_ e
reg.intercept_ como pode ver aqui.
Não esqueça deste pequeno sublinhado.
Do contrário, ela não entenderá o que você está falando.
Lembre-se de que esperávamos que a inclinação fosse aproximadamente 6,25.
Mas talvez não exatamente.
E a interceptação deve estar próxima a zero. Mas,
novamente, não esperamos que isso seja exato,
porque há um pouco de ruído em nossos dados de treinamento.
Há mais algumas linhas aqui sobre a r squared score.
Voltarei a isso em breve.
Mas quero mostrar a você agora o que são a previsão, os coeficientes e a
interceptação.
Portanto, estas três linhas são as linhas sobre as quais estávamos falando.
Posso prever meu patrimônio líquido com base na regressão.
Ele é de aproximadamente 160, com base em minha idade.
Podemos exibir também a inclinação e as interceptações.
Lembre-se de que pensamos que a inclinação seria de aproximadamente 6,25.
É quase isso, mas não exatamente.
O mesmo se aplica à interceptação, que não é exatamente zero.
Nos próximos vídeos, falaremos muito sobre os tipos de erros que
você pode obter nas regressões.
Porque eles são fundamentalmente diferentes dos tipos de
erros que você obtém na classificação.
Então, acabaremos
calculando a chamada r-squared.
Agora, as próximas linhas fornecem o desempenho de
sua regressão.
Uma forma de avaliar a regressão, sobre a qual falaremos
muito mais nos próximos vídeos, é por meio de uma métrica chamada r-squared.
Existe também a soma dos erros... falaremos sobre tudo isso.
Mas, agora quero apenas mostrar como isso aparece.
Para que você entenda porque isso é importante.
Para acessar essas métricas de desempenho, você usa
a chamada função score executada em sua regressão.
Você sempre precisará analisar a pontuação dos seus dados de teste.
Porque, naturalmente, você está ajustando a regressão usando os dados de treinamento.
Se houver qualquer sobreajuste, isso será indicado
através de uma pontuação mais baixa durante a análise dos dados de teste.
在离开这个编码示例前 我希望向你展示
一些能充分发挥回归作用的代码
首先是你可能想要用来进行预测的代码
当然 它不应该那么困难
因此 你在回归上调用 predict 函数就行了
但有一个小问题 它会需要一个列表(作为参数)
所以 即使你只有一个要预测的值
仍然需要将其放入列表中
你可能还想知道回归的
系数和截距是什么
你可以使用 reg.coef_ 和
Reg.intercept_ 来获取这些信息 正如你此处所见
别忘了这里的短下划线
否则 它会弄不懂你在说什么
请记住 我们预计的斜率十分接近 6.25
但可能并不准确
截距应该接近 0
但同样 我们不期待它完全正确
因为我们的训练数据中存在一些噪声
这里还有几行关于 r 平方分数的代码
我会立刻回头介绍这些代码
但我现在希望向你介绍
什么是预测、系数和截距
这三行是我们刚刚介绍过的内容
我可以根据回归预测净值
根据我的年龄 它大约为 160
我们也可以打印出斜率和截距
记住 我们原以为斜率大约为 6.25
很接近 但不完全一样
截距也是一样 并不刚好为 0
在下面几个视频中 我们将详细介绍
回归上可能会出现的误差类型
因为它们与分类中可能出现的误差类型
有根本上的不同
最后
我们将计算所谓的 r 平方
现在 下面几行提供了一些有关
回归性能的输出
所以 我们将在后续视频中详细介绍的一种回归评估方法是
一个称为 R 平方的指标
此外还有误差和 我们会讨论所有这些内容
但现在 让我先向你展示它的外观
以便你有理由理解其重要性
你将使用在回归上执行的
分数函数来访问这些性能指标
你始终希望查看测试数据上的分数
因为你显然会使用训练数据来拟合回归
所以 如果存在任何过拟合 继续执行此操作就会
在查看测试数据时显示较低的分数