Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding function to calculate the activity on the surface of the map #44

Merged
merged 1 commit into from
Aug 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Python/somoclu/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,15 @@ def cluster(self, algorithm=None):
for i, c in enumerate(linear_clusters):
self.clusters[i // self._n_columns, i % self._n_columns] = c

def get_surface_state(self, data = None):
"""Return the dot product of the codebook and the data.

:param algorithm: Optional parameter to specify data, otherwise the
data used previously to train the SOM is used.
"""
if data is None:
data = self._data
return np.dot(self.codebook.reshape((self.codebook.shape[0] * self.codebook.shape[1], self.codebook.shape[2])), data.T).T

def _check_cooling_parameters(radiuscooling, scalecooling):
"""Helper function to verify the cooling parameters of the training.
Expand Down