Ejemplo n.º 1
0
def naiveRecommendFromCluster(x, cluster):
    N, D = cluster.shape
    assert(x.shape == (D,))
    m = 0
    min_diff = 100000
    for i in range(N):
        diff = ml.euclideanDistance(x, cluster[i])
        if diff < min_diff:
            min_diff = diff
            m = i
    a = recommendFromElement(x, cluster[m])
    return a
Ejemplo n.º 2
0
import config

amount=config.amount
ranks, website_names, X = data.getBandHistograms(amount=amount, cut=config.cut, big=config.big)

N, D = X.shape
print "Each feature vector has dimension %d" % D
print "Training on %d samples" % N



# Similarities matrix
S = np.zeros((N, N))
for i in xrange(N):
    for j in xrange(N):
        S[i, j] = -ml.euclideanDistance(X[i], X[j])

# Preference i p(i) = S(i,i)
# This is the a priori suitability of point i to serve as an exemplar
# We initialize all of them to the median
median = np.median(S)
for i in xrange(N):
	S[i, i] = median
print S
# Responsabilities matrix
R = np.zeros((N, N))

# Availability matrix
A = np.zeros((N, N))

C = np.array(xrange(N))