Skip to content

Commit 07109ca

Browse files
committed
updated functions
1 parent aa13107 commit 07109ca

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

tpgmm/tpgmm/tpgmm.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -217,28 +217,6 @@ def silhouette_score(self, X: ndarray) -> float:
217217
weighted_sum = (weights @ scores) / (self.weights_ * X.shape[0])
218218
return weighted_sum.mean()
219219

220-
def inertia(self, X: ndarray) -> float:
221-
"""Sum of squared distances of samples to their closest cluster center.
222-
In case of multiple frames we take the mean squared distance to their closest cluster center over all frames.
223-
224-
TODO(Marco Todescato): please review if this is correct
225-
Args:
226-
X (ndarray): data in local reference frames. Shape (num_frames, num_points, num_features)
227-
228-
Returns:
229-
float: average inertia score over all frames
230-
"""
231-
probabilities = self.gauss_cdf(X)
232-
closest_cluster = np.argmax(probabilities, axis=1)
233-
# shape: (num_points, num_features, num_frames)
234-
cluster_center = np.diagonal(self.means_[:, closest_cluster], axis1=0, axis2=1)
235-
# (num_points, num_features, num_frames) -> (num_frames, num_points, num_features)
236-
cluster_center = cluster_center.transpose(2, 0, 1)
237-
# norm: (num_frames, num_points)
238-
norm = np.linalg.norm(cluster_center, axis=-1)
239-
# sum of squared distances
240-
sum_squared = np.sum(np.power(norm, 2), axis=-1)
241-
return sum_squared.mean()
242220

243221
def score(self, X: ndarray) -> float:
244222
"""calculate log likelihood score given data
@@ -269,21 +247,6 @@ def bic(self, X: ndarray) -> float:
269247
bic = -2 * ll + np.log(num_points) * self._n_components
270248
return bic
271249

272-
def davies_bouldin_score(self, X: ndarray) -> float:
273-
"""calculates the davies bouldin score for each frame and averages them
274-
275-
# TODO(Marco Todescator): is this score correct?
276-
Args:
277-
X (ndarray): data to calculate the score on. Expected shape: (num_frames, num_points, num_features)
278-
279-
Returns:
280-
float: score value
281-
"""
282-
labels = self.predict(X)
283-
scores = []
284-
for frame_data in X:
285-
scores.append(metrics.davies_bouldin_score(frame_data, labels))
286-
return np.mean(scores)
287250

288251
def _k_means(
289252
self,

0 commit comments

Comments
 (0)