forked from Echo9573/DataAnalysisbyPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2_2_2greyPredict.py
More file actions
55 lines (35 loc) · 1.21 KB
/
2_2_2greyPredict.py
File metadata and controls
55 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# coding: utf-8
# In[1]:
import pandas as pd
import numpy as np
from GM11 import GM11 # 引入自己编写的灰色预测函数
inputfile1 = 'data2.csv'
data = pd.read_csv(inputfile1)
data.index = range(1999,2014)
data
# In[2]:
data.loc[2014] = None
data.loc[2015] = None
h = ['x1', 'x3', 'x5']
for i in h:
gm = GM11(data[i][range(1999, 2014)].as_matrix())
f = gm[0] ##获得灰色预测函数
P = gm[-1] # 获得小残差概率
C = gm[-2] # 获得后验比差值
data[i][2014] = f(len(data)-1)
data[i][2015] = f(len(data))
data[i] = data[i].round(6) # 保留2位小数
if (C < 0.35 and P > 0.95): # 评测后验差判别
print '对于模型%s,该模型精度为---好' % i
elif (C < 0.5 and P > 0.8):
print '对于模型%s,该模型精度为---合格' % i
elif (C < 0.65 and P > 0.7):
print '对于模型%s,该模型精度为---勉强合格' % i
else:
print '对于模型%s,该模型精度为---不合格' % i
# In[3]:
#保存的表名命名格式为“2_2_2_k此表功能名称”,是此小节生成的第1张表格,功能为greyPredict:灰色预测
data[h+['y']].to_excel('2_2_2_1greyPredict.xlsx')
# In[4]:
data
# In[ ]: