评价类模型数据预处理(定量指标值的无量纲化处理)
一、整体概括
二、代码
import numpy as np
import pandas as pd
a = np.loadtxt('data14_1_1.txt')
b = np.linalg.norm(a,axis=0)
m1 = a.max(axis=0)
m2 = a.min(axis=0)
R1 = a / b
R2 = a / m1
R3 = (a-m2) / (m1-m2) R1[:,3] = 1 - a[:,3] / b[3]
R2[:,3] = m2[3] / a[:,3]
R3[:,3] = (m1[3]-a[:,3]) / (m1[3]-m2[3])
np.savetxt('data14_1_2.txt', R1, fmt='%.4f')
f = pd.ExcelWriter('data14_1_3.xlsx')
pd.DataFrame(R1).to_excel(f, index=None)
pd.DataFrame(R2).to_excel(f, 'Sheet2', index=None)
pd.DataFrame(R3).to_excel(f, 'Sheet3', index=None); f.close()
三、“data14_1_1.txt”中的数据
2.0 1500 20000 5500000 0.5 1
2.5 2700 18000 6500000 0.3 0.5
1.8 2000 21000 4500000 0.7 0.7
2.2 1800 20000 5000000 0.5 0.5
五、结果(excel文件不再展示)