import pandas as pd
import numpy as np
from GM11 import GM11 # 引入自己编写的灰色预测函数
data = pd.read_csv('D:\软件\python\《Python数据分析与挖掘实战(张良均等)》中文PDF+源代码\《Python数据分析与挖掘实战(张良均等)》中文PDF+源代码\数据及代码\chapter13\test\data\data1.csv',engine='python')
data.index = range(1994,2014)
data
data.loc[2014] = None
data.loc[2015] = None
h = ['x1', 'x2', 'x3', 'x4', 'x5', 'x7']
P = []
C = []
for i in h:
for j in range(1994, 2014):
t = []
t.append(data[i][j])
if len(t) >= 2:
t = t.as_matrix()
gm = GM11(t)
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(2) # 保留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)
data[h + ['y']].to_excel('D:\软件\python\《Python数据分析与挖掘实战(张良均等)》中文PDF+源代码\《Python数据分析与挖掘实战(张良均等)》中文PDF+源代码\数据及代码\chapter13\test\data\2_1_2_1greyPredict.xlsx')
请问这个问题TypeError: '<' not supported between instances of 'list' and 'float'如何解决
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- zzccaaron 2019-12-07 14:09关注
a = 1.0 # floats
b = 1.0a >= b # True
x = [1.0] # list containing a single (float) number,
y = 1.0x >= b # TypeError: '>=' not supported between instances of 'list' and 'float'
因此,这里有一些代码突出了这个问题。 Python告诉您,它不知道如何检查列表是否大于或等于某个数字。
你可以看下你把那些浮点数和列表进行了运算。
data[i][2014] = f(len(data)-1)
data[i][2015] = f(len(data))解决 无用评论 打赏 举报