SHARE
TWEET

Untitled

a guest Oct 16th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2.  
  3. def geo_mean(iterable):
  4.     a = np.array(iterable)
  5.     return a.prod()**(1.0/len(a))
  6.  
  7. def get_vector(A):
  8.     W = []
  9.     norm = 0
  10.     for i in range(A[0].size):
  11.         W.append(geo_mean(A[i]))
  12.         norm += W[i]
  13.     return W/norm
  14.    
  15.  
  16.  
  17. #1
  18. cena = np.array([[1,1/7,1/5],
  19.                 [7,1,3],
  20.                 [5,1/3,1]])
  21. #2
  22. rozmiar_domu = np.array([[1,5,9],
  23.                 [1/5,1,4],
  24.                 [1/9,1/4,1]])
  25. #3
  26. dostep = np.array([[1,4,1/5],
  27.                 [1/4,1,1/9],
  28.                 [5,9,1]])
  29. #4
  30. dzielnica = np.array([[1,9,4],
  31.                 [1/9,1,1/4],
  32.                 [1/4,4,1]])
  33. #5
  34. wiek = np.array([[1,1,1],
  35.                 [1,1,1],
  36.                 [1,1,1]])
  37. #6
  38. rozmiar_ogrodka = np.array([[1,6,4],
  39.                 [1/6,1,1/3],
  40.                 [1/4,3,1]])
  41. #7
  42. wyposazenie = np.array([[1,9,6],
  43.                 [1/9,1,1/3],
  44.                 [1/6,3,1]])
  45. #8
  46. stan = np.array([[1,1/2,1/2],
  47.                 [2,1,1],
  48.                 [2,1,1]])
  49.  
  50.  
  51. parametry = np.array([[1,4,7,5,8,6,6,2],
  52.                        [1/4,1,5,3,7,6,6,1/3],
  53.                        [1/7,1/5,1,1/3,5,3,3,1/5],
  54.                        [1/5,1/3,3,1,6,3,4,1/2],
  55.                        [1/8,1/7,1/5,1/6,1,1/3,1/4,1/7],
  56.                        [1/6,1/6,1/3,1/3,3,1,1/2,1/5],
  57.                        [1/6,1/6,1/3,1/4,4,2,1,1/5],
  58.                        [1/2,3,5,2,7,5,5,1]])
  59.  
  60. ranking = get_vector(parametry)
  61. print(ranking)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top