Skip to content

Commit 0e532f5

Browse files
Tilak Raj LuniaTilak Raj Lunia
authored andcommitted
fix: pass 3D coordinate via zs keyword to avoid collision with s
1 parent 8579444 commit 0e532f5

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎machine_learning/k_means_clust.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@
5353
import pandas as pd
5454
from matplotlib import pyplot as plt
5555
from sklearn.metrics import pairwise_distances
56-
if TYPE_CHECKING:
57-
from mpl_toolkits.mplot3d.axes3d import Axes3D
56+
5857
warnings.filterwarnings("ignore")
5958

6059
TAG = "K-MEANS-CLUST/ "
@@ -158,10 +157,15 @@ def plot_heterogeneity(heterogeneity, k) -> None:
158157

159158

160159
def plot_kmeans(data, centroids, cluster_assignment) -> None:
161-
ax = cast("Axes3D", plt.axes(projection="3d"))
160+
ax = plt.axes(projection="3d")
162161
ax.scatter(data[:, 0], data[:, 1], data[:, 2], c=cluster_assignment, cmap="viridis")
163162
ax.scatter(
164-
centroids[:, 0], centroids[:, 1], centroids[:, 2], c="red", s=100, marker="x"
163+
centroids[:, 0],
164+
centroids[:, 1],
165+
zs=centroids[:, 2],
166+
c="red",
167+
s=100,
168+
marker="x"
165169
)
166170
ax.set_xlabel("X")
167171
ax.set_ylabel("Y")

0 commit comments

Comments
 (0)