Last active
March 5, 2019 16:01
-
-
Save DFoly/eb40ed58a2e378e180865e06fbb74879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _initialise_parameters(self, X): | |
"""Implement k-means to find starting | |
parameter values. | |
Parameters: | |
------------ | |
X: numpy array of data points | |
Returns: | |
---------- | |
tuple containing initial means and covariance | |
_initial_means: numpy array: (C*d) | |
_initial_cov: numpy array: (C,d*d) | |
""" | |
n_clusters = self.C | |
kmeans = KMeans(n_clusters= n_clusters, init="k-means++", max_iter=500, algorithm = 'auto') | |
fitted = kmeans.fit(X) | |
prediction = kmeans.predict(X) | |
self._initial_means, self._initial_cov, self._initial_pi = self.calculate_mean_covariance(X, prediction) | |
return (self._initial_means, self._initial_cov, self._initial_pi) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment