iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >python之MSE、MAE、RMSE
  • 206
分享到

python之MSE、MAE、RMSE

MSEpythonRMSE 2023-01-31 02:01:13 206人浏览 薄情痞子

Python 官方文档:入门教程 => 点击学习

摘要

target = [1.5, 2.1, 3.3, -4.7, -2.3, 0.75] prediction = [0.5, 1.5, 2.1, -2.2, 0.1, -0.5] error = [] for i in range(le

target = [1.5, 2.1, 3.3, -4.7, -2.3, 0.75]
prediction = [0.5, 1.5, 2.1, -2.2, 0.1, -0.5]


error = []
for i in range(len(target)):
    error.append(target[i] - prediction[i])


print("Errors: ", error)
print(error)






squaredError = []
absError = []
for val in error:
    squaredError.append(val * val)#target-prediction之差平方 
    absError.append(abs(val))#误差绝对值


print("Square Error: ", squaredError)
print("Absolute Value of Error: ", absError)




print("MSE = ", sum(squaredError) / len(squaredError))#均方误差MSE




from math import sqrt
print("RMSE = ", sqrt(sum(squaredError) / len(squaredError)))#均方根误差RMSE
print("MAE = ", sum(absError) / len(absError))#平均绝对误差MAE


targetDeviation = []
targetMean = sum(target) / len(target)#target平均值
for val in target:
    targetDeviation.append((val - targetMean) * (val - targetMean))
print("Target Variance = ", sum(targetDeviation) / len(targetDeviation))#方差


print("Target Standard Deviation = ", sqrt(sum(targetDeviation) / len(targetDeviation)))#标准差

--结束END--

本文标题: python之MSE、MAE、RMSE

本文链接: https://www.lsjlt.com/news/187011.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • python之MSE、MAE、RMSE
    target = [1.5, 2.1, 3.3, -4.7, -2.3, 0.75] prediction = [0.5, 1.5, 2.1, -2.2, 0.1, -0.5] error = [] for i in range(le...
    99+
    2023-01-31
    MSE python RMSE
  • 用Python计算点估计预测评价指标(误差指标RMSE、MSE、MAE、MAPE) ,画图展示
    机器学习的回归问题常用RMSE,MSE, MAE,MAPE等评价指标,还有拟合优度R2。由于每次预测出来的预测值再去和原始数据进行误差评价指标的计算很麻烦,所以这里就直接给出他们五个指标的计算函数。把每次预测出来的值和真实值输入这个函数就可...
    99+
    2023-09-11
    python pandas 误差指标 拟合优度
  • Python之——python-nmap
    转载请注明出处:http://blog.csdn.net/l1028386804/article/details/78995578 一、python-nmap安装 # yum -y install nmap #安装nmap工具 # ...
    99+
    2023-01-31
    Python python nmap
  • Python全栈之路系列之Python
    The Python interpreter has a number of functions and types built into it that are always available. They are listed her...
    99+
    2023-01-31
    之路 系列之 Python
  • python之numpy.tile()
    格式:tile(A,reps) * A:array_like * 输入的array * reps:array_like * A沿各个维度重复的次数举例:A=[1,2] 1. tile(A,2) 结果:[1,2,1,2] 2. tile(A,...
    99+
    2023-01-31
    python numpy tile
  • python之VSCode
    1、安装python3.5(3.6版本亲测无法实现命令补全功能)2、安装VSCode(我的版本:VSCode-win32-1.7.2)3、安装Python插件安装Python插件能实现语法提示的一些功能,建议还是安装一下。打开VScode,...
    99+
    2023-01-31
    python VSCode
  • Python之MySQL
    创建连接标签(空格分隔): Python学习 mysql数据库存储数据的方式与excel类似,都是以表格的形式来存储数据。excel一般用一张表来存储少量的数据,数据库可以用多个表来存储大量的数据。 用其他方式存储数据,如果数据量少,读...
    99+
    2023-01-31
    Python MySQL
  • python之day1
      初学python会有学python2还是python3的困惑,因为现在公司的实际环境下大部分还是用2.7编写的代码,python3.X又向下不兼容2.X,我认为作为初学者更应该从python3着手:python3和python2区别不是...
    99+
    2023-01-31
    python
  • python之socket
    python之socket一、初识socket        socket 是网络连接端点,每个socket都被绑定到一个特定的IP地址和端口。IP地址是一个由4个数组成的序列,这4个数均是范围 0~255中的值(例如,220,176,36...
    99+
    2023-01-31
    python socket
  • Python 之 matplotlib
    代码: import matplotlib.pyplot as plt import numpy as np from matplotlib import animation fig, ax = plt.subplots() x = ...
    99+
    2023-01-31
    Python matplotlib
  • Python之Pool
    #!/usr/bin/env pythonfrom multiprocessing import Poolimport timedef sayHi(a):        time.sleep(5)        return a**aif ...
    99+
    2023-01-31
    Python Pool
  • python之路
    一切资源皆可用,只为学到东西!!!http://www.cnblogs.com/wupeiqi/articles/4938499.htmlhttp://www.cnblogs.com/wupeiqi/tag/Python/         ...
    99+
    2023-01-31
    之路 python
  • Python之RabbitMQ
    RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件。RabbitMQ服务器是用Erlang语言编写的,它可以为你的应用提供一个通用的消息发送和接收平台,并且保证消息在传输过程中的安全,RabbitMQ官网,RabbitM...
    99+
    2023-01-31
    Python RabbitMQ
  • python之selectors
    selectors是select模块的包装器,ptython文档建议大部分情况使用selectors而不是直接使用selectors 样例代码如下 # -*- coding: utf-8 -*- __author__ = 'fc' i...
    99+
    2023-01-30
    python selectors
  • Python 之NumPy
    NumPy的主要对象是同质的多维数组。它是一个有明确索引的相同类型的元素组成的表。在NumPy中维度称之为轴,轴数称之为列。举个例子:例一:[ 1, 2, 1 ]这是一个一维数组,因为它只有一个轴,这个轴的长度是3.列二:[[ 1., 0....
    99+
    2023-01-31
    Python NumPy
  • python之禅
    Beautiful is better than ugly.Explicit(明确的,清楚的) is better than implicit.    Simple is better than complex.Complex(复杂的;合成...
    99+
    2023-01-30
    python
  • python 之 re
    一、正则表达式    正则表达式,又称正规表示法、常规表示法(Regular Expression)二、正则表达式描述字符     在正则表达式中,直接给出字符,就是精确匹配。     用\d可以匹配一个数字,\w可以匹配一个字母或数字。如...
    99+
    2023-01-31
    python
  • Python之道
    The Zen of Python, by Tim PetersPython之道Beautiful is better than ugly.美观胜于丑陋。Explicit is better than implicit.显示胜于隐式。Sim...
    99+
    2023-01-31
    之道 Python
  • python 之 if
    #python if 用法 a = input("how old are you: ") if a > 100:     print "你死了" elif a > 60:     print "你老了" elif a>18...
    99+
    2023-01-31
    python
  • Python之路--Python初识
    python的创始人为吉多·范罗苏姆(Guido van Rossum)。1989年的圣诞节期间,吉多·范罗苏姆(中文名字:龟叔)为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC语言的一种继承。   编程语言主要分...
    99+
    2023-01-30
    之路 Python
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作