-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhits.py
More file actions
30 lines (24 loc) · 680 Bytes
/
Copy pathhits.py
File metadata and controls
30 lines (24 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import numpy as np
from sklearn.preprocessing import normalize
# Input web Matrix
l = np.matrix('0.0 1.0 0.0;'
'0.0 1.0 1.0;'
'0.0 0.0 0.0')
# Default matrices for calculation, do not alter
np.set_printoptions(precision=3)
lt = l.transpose()
h = np.matrix('1.0; 1.0; 1.0')
a = np.matrix('1.0; 1.0; 1.0')
# Computation for both hubiness and authority
def compute(h):
a = np.matmul(lt,h)
a *= np.matrix(1.0/a.max())
h = np.matmul(l,a)
h *= np.matrix(1.0/h.max())
return a,h
# Iterate long enough for acceptable limits
for x in range(1000):
a,h = compute(h)
# Print results
print("Hubiness:\n",h)
print("Authority:\n",a)