Home /
Expert Answers /
Computer Science /
need-to-do-the-to-do-parts-in-python-code-please-try-not-to-modify-the-existing-code-this-is-for-a-pa655
(Solved): Need to do the To-Do parts in Python code. Please try not to modify the existing code. This is for A ...
Need to do the To-Do parts in Python code. Please try not to modify the existing code. This is for AHP
import numpy as \( \mathrm{np} \) from numpy import linalg as \( L A \) # Compute normalized weights based on Geometric Mean method def getweightGM(pwMat): colsum \( =n \) p.tile \( (\mathrm{np} \cdot \operatorname{sum}( \) pwMat, \( \theta),[ \) pwMat. shape \( [\theta], 1]) \) nmat \( = \) np.divide(pwMat, colsum) gmweight \( =n p \cdot p r o d(n m a t, 1)^{* *}(1.0 / \) pwMat. shape[1] return gmweight/np. sum(gmweight) # Compute normalized weights based on Eigen method - return both # the maximum eigenvalue and the normalized weight vector def getweightEigen(pwMat): # TODO: Fix the calculation of eigL and eigV I eigh \( =0 \) eigV \( =n p \cdot \operatorname{array}([1,1]) \) \( w, v=\operatorname{eig}( \) eigv) return (eigL, eigV/np.sum(eigV)) # compute consistency index and consistency ratio based on # outputs from getweightEigen def getcicr(eigL, eigv): # ToDo: Fix the calculation of \( C I \) and \( C R \) \( C I=\theta \) \( C R=0 \) return \( (C I, C R) \)
import numpy as np from numpy import linalg as LA # Compute normalized weights based on Geometric Mean method def getweightGM(pwMat): colsum = np.tile(np.sum(pwMat, 0), [pwMat.shape[0],1]) nmat = np.divide (pwMat,colsum) gmweight = np.prod (nmat, 1)*