Skip to content

Commit

Permalink
Remove largest distance computation
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliabaldini committed Jul 22, 2024
1 parent a6bb5e0 commit 40470fc
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions exact_kmeans/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import gurobipy as gp
import numpy as np
from scipy.spatial.distance import cdist

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -97,18 +96,6 @@ def print_variable(var_name: str, indices: List[str], value: float) -> Optional[
return f"Unknown variable {var_name} with indices {indices}"


# TODO: Smarter way to do this?
def compute_largest_distance(X: np.ndarray) -> Any:
distances = cdist(X, X, metric="sqeuclidean")
p1, p2 = np.unravel_index(distances.argmax(), distances.shape)

logger.info(
f"The largest distance is between {X[p1]} and {X[p2]} with distance {distances[p1, p2]}"
)

return distances.max()


def get_distance(x: np.ndarray, y: np.ndarray) -> Any:
return sum((x - y) ** 2)

Expand Down

0 comments on commit 40470fc

Please sign in to comment.