Skip to content

Commit 57b2477

Browse files
committed
fix: type k-means 3D plotting and enable parameter-already-assigned
1 parent 35ccb2c commit 57b2477

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎machine_learning/k_means_clust.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@
4848
"""
4949

5050
import warnings
51+
from typing import cast
5152

5253
import numpy as np
5354
import pandas as pd
5455
from matplotlib import pyplot as plt
56+
from mpl_toolkits.mplot3d import Axes3D
5557
from sklearn.metrics import pairwise_distances
5658

5759
warnings.filterwarnings("ignore")
@@ -156,8 +158,12 @@ def plot_heterogeneity(heterogeneity, k) -> None:
156158
plt.show()
157159

158160

159-
def plot_kmeans(data, centroids, cluster_assignment) -> None:
160-
ax = plt.axes(projection="3d")
161+
def plot_kmeans(
162+
data: np.ndarray,
163+
centroids: np.ndarray,
164+
cluster_assignment: np.ndarray,
165+
) -> None:
166+
ax = cast(Axes3D, plt.axes(projection="3d"))
161167
ax.scatter(data[:, 0], data[:, 1], data[:, 2], c=cluster_assignment, cmap="viridis")
162168
ax.scatter(
163169
centroids[:, 0], centroids[:, 1], centroids[:, 2], c="red", s=100, marker="x"

‎pyproject.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ rules.invalid-return-type = "ignore"
323323
rules.no-matching-overload = "ignore"
324324
rules.not-iterable = "ignore"
325325
rules.not-subscriptable = "ignore"
326-
rules.parameter-already-assigned = "ignore"
327326
rules.unresolved-attribute = "ignore"
328327
rules.unresolved-import = "ignore"
329328
rules.unsupported-operator = "ignore"

0 commit comments

Comments
 (0)