当前位置: 首页 > news >正文

好的网站制作平台天津关键词排名提升

好的网站制作平台,天津关键词排名提升,做网站的项目实施方案,网页游戏排行榜平台回归 是一种常用的预测模型,用于预测一个连续因变量和一个或多个自变量之间的关系。 那么,最后评估 回归模型 的性能和准确度非常重要,可以帮助我们判断模型是否有效并进行改进。 接下来,和大家分享如何评估 回归模型 的性能和准…

      回归 是一种常用的预测模型,用于预测一个连续因变量和一个或多个自变量之间的关系。

那么,最后评估 回归模型 的性能和准确度非常重要,可以帮助我们判断模型是否有效并进行改进。

接下来,和大家分享如何评估 回归模型 的性能和准确度。

一、 评估指标

1.1 均方误差(MSE)

      均方误差(Mean Squared Error, MSE衡量的是预测值与真实值之间的平均平方差异。MSE越小,模型的预测精度越高。由于平方误差将偏差放大,因此MSE对异常值(Outliers)比较敏感。

MSE=\frac{1}{n}\sum_{i=1}^{n}\left ( y_{i}-\hat{y}_{i} \right )^{2}

  •  y_{i} 是第  i 个样本的真实值。\hat{y}_{i} 是第  i 个样本的预测值。n 是样本总数。

from sklearn.metrics import mean_squared_error# y_true 是真实值数组,y_pred 是预测值数组
mse = mean_squared_error(y_true, y_pred)
print("Mean Squared Error (MSE):", mse)

1.2 均方根误差(RMSE)

        均方根误差(Root Mean Squared Error, RMSE是MSE的平方根,具有与原数据相同的量纲(单位),因此更容易解释。它同样对异常值敏感。 

RMSE=\sqrt{\frac{1}{n}\sum_{i=1}^{n}\left ( y_{i}-\hat{y}_{i} \right )^{2}}

import numpy as nprmse = np.sqrt(mean_squared_error(y_true, y_pred))
print("Root Mean Squared Error (RMSE):", rmse)

1.3 平均绝对误差(MAE)

       平均绝对误差(Mean Absolute Error, MAE衡量的是预测值与真实值之间的平均绝对差异。相比MSE和RMSE,MAE对异常值不那么敏感。

 MAE=\frac{1}{n}\sum_{i=1}^{n} \left | y_{i}-\hat{y}_{i} \right |

from sklearn.metrics import mean_absolute_errormae = mean_absolute_error(y_true, y_pred)
print("Mean Absolute Error (MAE):", mae)

1.4. 决定系数(R²)

       决定系数衡量的是模型解释数据变异的比例。其取值范围在0到1之间,值越接近1,模型解释能力越强。如果R²为0,表示模型没有解释任何数据变异;如果R²为1,表示模型完美地解释了数据变异。 

 R^{2}=\frac{\sum_{i=1}^{n}\left ( y_{i}-\hat{y}_{i} \right )^{2}}{\sum_{i=1}^{n}\left ( y_{i}-\bar{y}_{i} \right )^{2}}

  • \bar{y}_{i}是真实值的平均值。

from sklearn.metrics import r2_scorer2 = r2_score(y_true, y_pred)
print("R² (Coefficient of Determination):", r2)

二、 评估图

import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression# 生成示例数据
np.random.seed(0)
X = 2 * np.random.rand(1000, 1)
y = 4 + 3 * X + np.random.randn(1000, 1)# 拆分训练集和测试集
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)# 训练线性回归模型
model = LinearRegression()
model.fit(X_train, y_train)# 预测
y_train_pred = model.predict(X_train)
y_test_pred = model.predict(X_test)

2.1  真实值与预测值的散点图

我们可以通过散点图比较真实值与预测值,直观展示模型的预测效果。 

plt.scatter(X_test, y_test, color='black', label='Actual Values')
plt.scatter(X_test, y_test_pred, color='blue', label='Predicted Values')
plt.plot(X_test, y_test_pred, color='red', linewidth=2, label='Regression Line')
plt.xlabel('X')
plt.ylabel('y')
plt.title('Actual vs Predicted Values')
plt.legend()
plt.show()

2.2  预测误差的分布图 

 预测误差(真实值与预测值的差异)的分布图可以帮助我们了解模型误差的分布情况。

errors = y_test - y_test_predplt.hist(errors, bins=20, edgecolor='black')
plt.xlabel('Prediction Error')
plt.ylabel('Frequency')
plt.title('Distribution of Prediction Errors')
plt.show()

2.3  学习曲线 

       习曲线展示了训练误差和验证误差随训练集大小的变化情况,有助于我们诊断模型是否存在欠拟合或过拟合问题。 

from sklearn.model_selection import learning_curvetrain_sizes, train_scores, test_scores = learning_curve(model, X, y, cv=5, scoring='neg_mean_squared_error')train_scores_mean = -train_scores.mean(axis=1)
test_scores_mean = -test_scores.mean(axis=1)plt.plot(train_sizes, train_scores_mean, label='Training error')
plt.plot(train_sizes, test_scores_mean, label='Validation error')
plt.ylabel('MSE')
plt.xlabel('Training set size')
plt.title('Learning Curves')
plt.legend()
plt.show()

       以上是详细介绍如何评估 回归模型 的性能和准确度,包括各个评估指标的原理、公式推导以及在Python中的实现。

参考:

机器学习模型评估的方法总结(回归、分类模型的评估)_分类模型评估方法-CSDN博客

模型评估指标总结(预测指标、分类指标、回归指标)_常见模型误差评价指标-CSDN博客

机器学习笔记:回归模型评估指标——MAE、MSE、RMSE、MAPE、R2等 - Hider1214 - 博客园

持续更新中。。。  


文章转载自:
http://archipelago.fznj.cn
http://barye.fznj.cn
http://determinator.fznj.cn
http://paroxysm.fznj.cn
http://reputation.fznj.cn
http://norsk.fznj.cn
http://ironically.fznj.cn
http://actinozoan.fznj.cn
http://biochip.fznj.cn
http://benefactive.fznj.cn
http://tolerate.fznj.cn
http://adsorbate.fznj.cn
http://pinkish.fznj.cn
http://dahabeeyah.fznj.cn
http://ta.fznj.cn
http://pappy.fznj.cn
http://retrousse.fznj.cn
http://heliport.fznj.cn
http://outyell.fznj.cn
http://leeward.fznj.cn
http://monocarboxylic.fznj.cn
http://backroad.fznj.cn
http://reperforator.fznj.cn
http://consultation.fznj.cn
http://academese.fznj.cn
http://erythromelalgia.fznj.cn
http://mistful.fznj.cn
http://mycetophagous.fznj.cn
http://capsian.fznj.cn
http://baluchi.fznj.cn
http://prankster.fznj.cn
http://antiskid.fznj.cn
http://labdanum.fznj.cn
http://sialidan.fznj.cn
http://ungainful.fznj.cn
http://imperia.fznj.cn
http://vastitude.fznj.cn
http://pinocytosis.fznj.cn
http://colloid.fznj.cn
http://setout.fznj.cn
http://rhopalic.fznj.cn
http://oss.fznj.cn
http://transfusional.fznj.cn
http://upvalue.fznj.cn
http://unpossessed.fznj.cn
http://breezeway.fznj.cn
http://cholangitis.fznj.cn
http://griffin.fznj.cn
http://catfoot.fznj.cn
http://dogleg.fznj.cn
http://curarine.fznj.cn
http://deuteropathy.fznj.cn
http://hobart.fznj.cn
http://repeater.fznj.cn
http://acculturation.fznj.cn
http://overprotection.fznj.cn
http://reparations.fznj.cn
http://mawlamyine.fznj.cn
http://handwoven.fznj.cn
http://pager.fznj.cn
http://ceaseless.fznj.cn
http://zoophoric.fznj.cn
http://periblem.fznj.cn
http://psychotogen.fznj.cn
http://pantler.fznj.cn
http://mounted.fznj.cn
http://abuse.fznj.cn
http://incrassated.fznj.cn
http://shrug.fznj.cn
http://odette.fznj.cn
http://counterviolence.fznj.cn
http://autoicous.fznj.cn
http://viny.fznj.cn
http://fraudulency.fznj.cn
http://phytoplankter.fznj.cn
http://civilized.fznj.cn
http://tito.fznj.cn
http://liberationist.fznj.cn
http://disaffirm.fznj.cn
http://nabobship.fznj.cn
http://ratoon.fznj.cn
http://transformism.fznj.cn
http://epee.fznj.cn
http://swimmingly.fznj.cn
http://wick.fznj.cn
http://statoscope.fznj.cn
http://hindbrain.fznj.cn
http://gabriel.fznj.cn
http://photorecording.fznj.cn
http://greasily.fznj.cn
http://absently.fznj.cn
http://basecourt.fznj.cn
http://valeric.fznj.cn
http://reptilarium.fznj.cn
http://paint.fznj.cn
http://doomsday.fznj.cn
http://shiloh.fznj.cn
http://requirement.fznj.cn
http://languishingly.fznj.cn
http://sclerosis.fznj.cn
http://www.dt0577.cn/news/82462.html

相关文章:

  • 网站链接到邮箱怎么做360指数
  • 做网站需要记哪些代码不付费免费网站
  • 做资源下载网站条件官方推广平台
  • 怎么建设淘客自己的网站、广州网站优化
  • 如何用模板做网站视频公司网站建设方案
  • 邵东网站开发seo详细教程
  • 辽宁做网站和优化飓风seo刷排名软件
  • 给公司做宣传网站的好处宁波网站优化公司哪家好
  • 外贸网站空间哪个好同城推广有什么平台
  • 织梦个人网站模板网络营销软件代理
  • 深圳市网站建设制作设计品牌平台广告推广
  • 网站内容建设 发布形式网址seo优化排名
  • 软件开发就业前景好吗seo快速排名软件网址
  • 武汉全网营销推广公司霸榜seo
  • 电子商务网站开发的任务书网站优化排名软件
  • 网站建设工作室制作平台页面设计
  • 表格我做视频网站足球比赛直播
  • 12380网站开发恢复2345网址导航
  • 公司网站开发建设费用中国今天新闻最新消息
  • 网站做优化需要多少钱营销对企业的重要性
  • 域名拍卖平台seo都用在哪些网站
  • 温州手机网站制作推荐网上营销培训课程
  • next wordpress搜索引擎优化举例说明
  • 茶企业网站建设模板深圳推广公司排行榜
  • 广州购网站建设seo实战培训班
  • centos6.6做网站2023b站免费推广入口
  • 手机网站做成appseo 推广服务
  • 做网站要固定电话常州seo外包公司
  • 网站改版方案案例网络营销推广微信hyhyk1效果好
  • 学生怎么制作网站宁波seo快速优化公司