Python 层次分析决定权重

https://wenku.baidu.com/view/ea612a7c31b765ce05081473.html?qq-pf-to=pcqq.group

Python 层次分析决定权重_第1张图片

Python 层次分析决定权重_第2张图片
# -*- coding: utf-8 -*-
# 2

# 

#A1 温度上升 #A2 耕地面积减少 #A3 自然灾害
#A1 0.471
#A2 0.088
#A3 0.439
A = np.array([[1,6,0.5],
              [0.166,1,0.25],
              [2,4,1]])

# 

SUMR = []
for i in range(0,3):
    tempsum=0
    for j in range(0,3):
        tempsum+=A[j][i]
    SUMR.append(tempsum)

# 

A=np.row_stack((A,SUMR))

# 

A

# 

SUMC = []
for i in range(0,4):
    tempsum=0
    for j in range(0,3):
        tempsum+=A[i][j]
    SUMC.append(tempsum)

# 

A=np.column_stack((A,SUMC))

# 

A

# 

W=[]
total=0
for i in range(0,3):
    total+=A[i][3]
    
for i in range(0,3):
    W.append(A[i][3]/total)

# 

W.append(1)

# 

A1=np.column_stack((A1,W))

# 

A1

# 


# 


```![)2]@Z(6W_JK4ZHADTSANA_L.png](http://upload-images.jianshu.io/upload_images/6927087-39711a0a4cbfb662.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

你可能感兴趣的:(Python 层次分析决定权重)