修改后,反归一没有实现 :def FNormalizeMultUseData(data,normalize): data = np.array(data) listlow = normalize[-1, 0] listhigh = normalize[-1, 1] delta = listhigh - listlow if delta != 0: for j in range(0,data.shape[0]): data[j,-1] = (data[j,-1] - listlow)/delta data[j,-1] = data[j,-1]*(normalize[-1,1]-normalize[-1,0])+normalize[-1,0] for i in range(0, data.shape[1]-1): listlow = normalize[i, 0] listhigh = normalize[i, 1] delta = listhigh - listlow if delta != 0: for j in range(0,data.shape[0]): data[j,i] = (data[j,i] - listlow)/delta return data
时间: 2024-03-27 12:35:23 浏览: 40
normalize-package-data:标准化包元数据,通常在package.json文件中找到
根据你提供的代码来看,确实没有实现反归一化。可以对该函数进行修改,加入反归一化的实现,如下所示:
```
def FNormalizeMultUseData(data, normalize):
data = np.array(data)
for i in range(data.shape[1] - 1):
listlow = normalize[i, 0]
listhigh = normalize[i, 1]
delta = listhigh - listlow
if delta != 0:
for j in range(data.shape[0]):
data[j, i] = (data[j, i] - listlow) / delta
listlow = normalize[-1, 0]
listhigh = normalize[-1, 1]
delta = listhigh - listlow
if delta != 0:
for j in range(data.shape[0]):
data[j, -1] = (data[j, -1] - listlow) / delta
# 反归一化
for i in range(data.shape[1] - 1):
listlow = normalize[i, 0]
listhigh = normalize[i, 1]
delta = listhigh - listlow
if delta != 0:
for j in range(data.shape[0]):
data[j, i] = data[j, i] * delta + listlow
listlow = normalize[-1, 0]
listhigh = normalize[-1, 1]
delta = listhigh - listlow
if delta != 0:
for j in range(data.shape[0]):
data[j, -1] = data[j, -1] * delta + listlow
return data
```
这里的反归一化代码与归一化代码类似,只是将归一化的计算过程反过来进行计算。对于每一列数据,先计算出归一化时的差值delta,然后按照相应的比例进行反归一化处理。最后返回反归一化后的数据即可。
阅读全文