Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n_clusters = 32
- X = X_train
- cluster = AgglomerativeClustering(n_clusters=n_clusters).fit(X)
- costMatrix = cost_matrix(cluster.labels_,y_train)
- predicted = HungarianAlgorithm(costMatrix,cluster.labels_)
- #find centers
- clusterCenters = np.zeros((n_clusters,2576))
- covs = np.zeros((n_clusters,2576))
- weights = np.zeros(n_clusters)
- for i in range(n_clusters):
- indices = findIndices(i,cluster.labels_)
- print(indices)
- faces = np.zeros((len(indices),2576))
- for ind, index in enumerate(indices):
- faces[ind] = X[index]
- clusterCenters[i] = np.mean(faces,axis = 0)
- covs[i] = 1/(np.diag(np.cov(faces.T))+1e-6)
- weights[i] = faces.shape[0]/320
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement