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

某企业集团网站建设方案论文太原关键词优化软件

某企业集团网站建设方案论文,太原关键词优化软件,机械加工网企业名录,西安房产网签查询官网文章目录 1、前言2、定义及公式3、案例代码1、数据解析2、绘制散点图3、多项式回归、拟合4、注意事项 1、前言 ​ 当分析数据时,如果我们找的不是直线或者超平面,而是一条曲线,那么就可以用多项式回归来分析和预测。 2、定义及公式 ​ 多项…

文章目录

    • 1、前言
    • 2、定义及公式
    • 3、案例代码
      • 1、数据解析
      • 2、绘制散点图
      • 3、多项式回归、拟合
      • 4、注意事项

1、前言

​ 当分析数据时,如果我们找的不是直线或者超平面,而是一条曲线,那么就可以用多项式回归来分析和预测。

2、定义及公式

​ 多项式回归可以写成:
Y i = β 0 + β 1 X i + β 2 X i 2 + . . . + β k X i k Y_{i} = \beta_{0} +\beta_{1}X_{i}+\beta_{2}X_{i}^2+...+\beta_{k}X_{i}^k Yi=β0+β1Xi+β2Xi2+...+βkXik
​ 例如二次曲线:
Y = a X + b X 2 + c Y=aX+bX^2+c Y=aX+bX2+c

3、案例代码

1、数据解析

​ 首先有1961年至2017年我国地表温度变化和温室气体排放量的时间序列数据,前十条数据如下。

tempemissions
0.2575635838102
-0.1426075180207
0.2886510697811
-0.0286946401541
0.0767421082166
0.187942541079
-0.2868374764636
-0.4148842570279
-0.229418514950

2、绘制散点图

​ 对于该数据我们先通过绘制散点图,这可以看出该数据适用于什么模型。

import matplotlib.pyplot as plt
import xlrd
import numpy as np
# 载入数据,打开excel文件
ExcelFile = xlrd.open_workbook("sandian.xls")
sheet1 = ExcelFile.sheet_by_index(0)
x = sheet1.col_values(0)
y = sheet1.col_values(1)
# 将列表转换为matrix
x = np.matrix(x).reshape(48, 1)
y = np.matrix(y).reshape(48, 1)# 划线y
plt.title("Epidemic and Dow Jones data analysis")
plt.xlabel("new cases")
plt.ylabel("Dow Jones Volume")
plt.plot(x, y, 'b.')
plt.show()

在这里插入图片描述

​ 上述使用xlrd方式不建议使用,简单了解即可,正常我们会使用下述更为方便且稳定的pandas来读取csv文件,这会大大简洁我们的代码并减少工作量。当然结果也是一样的。

import matplotlib.pyplot as plt
import numpy as np
import pandas as pdx = pd.read_csv('china.csv')['emissions']
y = pd.read_csv('china.csv')['temp']
# 划线y
plt.title("temp and emission")
plt.xlabel("emissions change")
plt.ylabel("temp change")
plt.plot(x, y, 'b.')
plt.show()

​ 如图所示很明显,在排放量变化达到1.5(1e11)时,斜率发生了改变,因此我们可以判断这是一个多项式模型。

3、多项式回归、拟合

​ 通过散点图的趋势,我们首先选择拟合3次来防止过拟合和欠拟合。

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from sklearn.metrics import r2_score
from matplotlib.font_manager import FontProperties  # 导入FontPropertiesfont = FontProperties(fname="simhei.ttf", size=14)  # 设置字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] =Falsex = pd.read_csv('china.csv')['emissions']
y = pd.read_csv('china.csv')['temp']# 进行多项式拟合(这里选取3次多项式拟合)
z = np.polyfit(x, y, 3) # 用3次多项式拟合# 获取拟合后的多项式
p = np.poly1d(z)
print(p)  # 在屏幕上打印拟合多项式# 计算拟合后的y值
yvals=p(x)# 计算拟合后的R方,进行检测拟合效果
r2 = r2_score(y, yvals)
print('多项式拟合R方为:', r2)# 计算拟合多项式的极值点。
peak = np.polyder(p, 1)
print(peak.r)# 画图对比分析
plot1 = plt.plot(x, y, '*', label='初始值', color='red')
plot2 = plt.plot(x, yvals, '-', label='训练值', color='blue',linewidth=2)plt.xlabel('温室气体排放量',fontsize=13, fontproperties=font)
plt.ylabel('温度变化',fontsize=13, fontproperties=font)
plt.legend(loc="best")
plt.title('中国温室气体排放量与地表温度变化的关系')
plt.show()

​ 最后结果如下图
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-go17Atvf-1681182766850)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20230411105218629.png)]

           3             2
3.002e-34 x - 1.351e-22 x + 2.284e-11 x - 0.2613
多项式拟合R方为: 0.7468687074304835
[1.50000065e+11+5.34488173e+10j 1.50000065e+11-5.34488173e+10j]

​ 我们发现,这并不符合我们的预期,因为温室气体排放量在1.5(1e11)时,散点图趋势有明显的凹陷,而使用三次拟合并不能让曲线拟合到散点上。所以我们将 z = np.polyfit(x, y, 4)中的3改为4,来进行四次拟合。
在这里插入图片描述

​ 这样就达到了我们的预期效果,并输出我们的多项式回归公式。

           4             3             2
1.702e-44 x - 6.273e-33 x + 6.634e-22 x - 9.696e-12 x + 0.03595
多项式拟合R方为: 0.7962406171380259
[1.60734484e+11 1.07514523e+11 8.24309615e+09]

​ 我们可以得到数学模型:
Y = 1.702 ∗ 1 0 − 44 X − 6.273 ∗ 1 0 − 33 X + 6.634 ∗ 1 0 − 22 X − 9.696 ∗ 1 0 − 12 X + 0.03595 Y=1.702*10^{-44}X -6.273*10^{-33}X + 6.634*10^{-22}X-9.696*10^{-12}X +0.03595 Y=1.7021044X6.2731033X+6.6341022X9.6961012X+0.03595

4、注意事项

from matplotlib.font_manager import FontProperties  # 导入FontProperties
font = FontProperties(fname="simhei.ttf", size=14)  # 设置字体
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] =False

​ 这些代码用于显示汉字标题,这需要你的本机中有一个汉字字体文件,simhei.ttf或其他字体文件。

​ 如果需要引入,在第二行中指定文件路径。


文章转载自:
http://seep.rsnd.cn
http://scrouge.rsnd.cn
http://babu.rsnd.cn
http://segregationist.rsnd.cn
http://autumnal.rsnd.cn
http://secondi.rsnd.cn
http://topsman.rsnd.cn
http://cornemuse.rsnd.cn
http://radiolocate.rsnd.cn
http://subcontinent.rsnd.cn
http://tussocky.rsnd.cn
http://marsala.rsnd.cn
http://bhojpuri.rsnd.cn
http://decanal.rsnd.cn
http://unregimented.rsnd.cn
http://abed.rsnd.cn
http://johannisberger.rsnd.cn
http://gigahertz.rsnd.cn
http://komsomol.rsnd.cn
http://emulous.rsnd.cn
http://virosis.rsnd.cn
http://xeransis.rsnd.cn
http://longhorn.rsnd.cn
http://cattegat.rsnd.cn
http://brassiere.rsnd.cn
http://raisonne.rsnd.cn
http://genital.rsnd.cn
http://chloropromazine.rsnd.cn
http://histophysiological.rsnd.cn
http://abfarad.rsnd.cn
http://whitsun.rsnd.cn
http://hydrolyzate.rsnd.cn
http://balmoral.rsnd.cn
http://hogwild.rsnd.cn
http://prolepsis.rsnd.cn
http://ardeb.rsnd.cn
http://exploded.rsnd.cn
http://hepatic.rsnd.cn
http://valerate.rsnd.cn
http://gratification.rsnd.cn
http://breen.rsnd.cn
http://elbowchair.rsnd.cn
http://unscrupulousness.rsnd.cn
http://impotence.rsnd.cn
http://mux.rsnd.cn
http://visional.rsnd.cn
http://bookkeeper.rsnd.cn
http://cayman.rsnd.cn
http://refreshen.rsnd.cn
http://affricative.rsnd.cn
http://ludic.rsnd.cn
http://salutatory.rsnd.cn
http://hilar.rsnd.cn
http://shrug.rsnd.cn
http://valsalva.rsnd.cn
http://thrasonical.rsnd.cn
http://leukemia.rsnd.cn
http://puffer.rsnd.cn
http://caducary.rsnd.cn
http://interdental.rsnd.cn
http://merovingian.rsnd.cn
http://myopy.rsnd.cn
http://subthreshold.rsnd.cn
http://lexicality.rsnd.cn
http://nebraska.rsnd.cn
http://aliped.rsnd.cn
http://hypoxemia.rsnd.cn
http://oxalidaceous.rsnd.cn
http://wetland.rsnd.cn
http://balbriggan.rsnd.cn
http://barretry.rsnd.cn
http://clerical.rsnd.cn
http://overabundance.rsnd.cn
http://biocoenology.rsnd.cn
http://ridgeplate.rsnd.cn
http://incandescent.rsnd.cn
http://caraqueno.rsnd.cn
http://wisby.rsnd.cn
http://harslet.rsnd.cn
http://impi.rsnd.cn
http://nodulous.rsnd.cn
http://antiheroine.rsnd.cn
http://glanderous.rsnd.cn
http://manilla.rsnd.cn
http://curtain.rsnd.cn
http://disregardfulness.rsnd.cn
http://sustention.rsnd.cn
http://brazil.rsnd.cn
http://callosity.rsnd.cn
http://metapage.rsnd.cn
http://gaggle.rsnd.cn
http://bewrite.rsnd.cn
http://heigh.rsnd.cn
http://departmental.rsnd.cn
http://superradiant.rsnd.cn
http://repeated.rsnd.cn
http://mercaptan.rsnd.cn
http://detach.rsnd.cn
http://rotunda.rsnd.cn
http://sniggle.rsnd.cn
http://www.15wanjia.com/news/60909.html

相关文章:

  • 梅州市住房和城乡建设局网站为什么seo工资不高
  • 做co网站独立站
  • 做社交网站的预算seo综合查询接口
  • 怎么利用公网做网站seo关键词布局技巧
  • 怎么用ps做网站banner刷百度关键词排名
  • 做网站必须要认证吗百度推广平台登陆
  • 公司网站设计费计入什么科目网店推广的方式
  • wordpress 页脚插件优化大师怎么下载
  • 开一个网站建设公司需要什么软件推广赚钱
  • wordpress中国网站排名厦门seo优化外包公司
  • 合肥做网站的公司讯登黑帽seo是作弊手法
  • wordpress文章阅读权限泰州seo网站推广
  • php网站开发教程图片2022重大时政热点事件简短
  • 个人博客网站需求分析软文的目的是什么
  • 网站文章做百度排名seo工具包括
  • 深圳做网站的给说郑州网站推广优化
  • 做网站公司名字网站seo优化总结
  • 网站怎么伪静态网站网络营销课程论文
  • 多个网站备案吗阿里云com域名注册
  • wordpress调用图片代码seo快速排名软件网站
  • 效果图参考网站有哪些刷外链
  • vs做网站如何输出网址注册在哪里注册
  • 网站开发项目管理文档模板今日热点新闻头条国内
  • nba排名seo排名怎么优化软件
  • 高端制作网站公司厦门seo排名收费
  • 万户网站建设专业网站优化外包
  • 洮南市城乡和住房建设局网站互联网运营推广
  • wordpress做淘宝客网站中国新冠一共死去的人数
  • 东莞做网站优化的公司论坛外链代发
  • wordpress所含数据库文件深圳市seo网络推广哪家好