机械学习预估未来GDP

13 篇文章 0 订阅
#!/usr/bin/python
#encoding:utf-8
import numpy
import matplotlib.pyplot as plt
print("本程序中使用机械学习的方法来预估未来值,预测准确性取决于数据和拟合度,未考虑特殊因素")
y=[2719450,
3567320,
4863750,
6133990,
7181360,
7971500,
8519550,
9056440,
10028010,
11086310,
12171740,
13742200,
16184020,
18731890,
21943850,
27009230,
31924460,
34851770,
41211930,
48794020,
53858000,
59296320,
64356310,
68885820,
74639510,
83203590,
91928110,
99086510
]
x=list(range(len(y)))
mymodel = numpy.poly1d(numpy.polyfit(x, y, 3))
myline = numpy.linspace(1, len(y))
plt.scatter(x, y)
plt.plot(myline, mymodel(myline))

from sklearn.metrics import r2_score
print("图像拟合度为:")
print(r2_score(y, mymodel(x)))
wen=int(input("你想预测哪一年的,请输入int类型的数字"))
wen=int(wen-1991)
speed = mymodel(wen)
print("预测值")
print(speed)
plt.savefig('./Drawing of mechanical learning.jpg')
plt.show()
while  True:
   wen=int(input("你想预测哪一年的,请输入int类型的数字"))
   wen=int(wen-1991)
   speed = mymodel(wen)
   print("预测值")
   print(speed)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值