Skip to content

Commit

Permalink
Sphinx Docstring Update - Nearest Centroid (#782)
Browse files Browse the repository at this point in the history
* Update cluster.py

* correcting bugs and doc - Nearest Centroids

* Update cluster.py

* Update cluster.py

---------

Co-authored-by: Badr <[email protected]>
  • Loading branch information
mail4umar and oualib authored Oct 30, 2023
1 parent 41c17d6 commit f26db21
Show file tree
Hide file tree
Showing 4 changed files with 458 additions and 8 deletions.
8 changes: 4 additions & 4 deletions verticapy/machine_learning/memmodel/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(
clusters_names: Optional[ArrayLike] = None,
) -> None:
clusters_names = format_type(clusters_names, dtype=list)
self.clusters_ = np.array(clusters)
self.clusters_ = np.array(clusters).astype(float)
self.classes_ = np.array(clusters_names)
self.p_ = p

Expand Down Expand Up @@ -380,7 +380,7 @@ def object_type(self) -> Literal["KMeans"]:
# System & Special Methods.

def __init__(self, clusters: ArrayLike, p: int = 2) -> None:
self.clusters_ = np.array(clusters)
self.clusters_ = np.array(clusters).astype(float)
self.p_ = p


Expand Down Expand Up @@ -518,7 +518,7 @@ def __init__(
classes: ArrayLike,
p: int = 2,
) -> None:
self.clusters_ = np.array(clusters)
self.clusters_ = np.array(clusters).astype(float)
self.classes_ = np.array(classes)
self.p_ = p

Expand Down Expand Up @@ -720,7 +720,7 @@ def __init__(
cluster_size, cluster_score = format_type(
cluster_size, cluster_score, dtype=list
)
self.clusters_ = np.array(clusters)
self.clusters_ = np.array(clusters).astype(float)
self.children_left_ = np.array(children_left)
self.children_right_ = np.array(children_right)
self.cluster_size_ = np.array(cluster_size)
Expand Down
2 changes: 1 addition & 1 deletion verticapy/machine_learning/metrics/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _compute_final_score(
"Parameter 'pos_label' can only be used when parameter 'average' is set to 'binary' or undefined."
)
if not (isinstance(pos_label, NoneType)) and not (isinstance(labels, NoneType)):
raise ValueError("Parameters 'pos_label' and 'labels' can not be both defined.")
labels = None
if (
isinstance(pos_label, NoneType)
and isinstance(labels, NoneType)
Expand Down
2 changes: 1 addition & 1 deletion verticapy/machine_learning/vertica/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ def score(
kwargs = {}
if metric not in ("aic", "bic"):
labels = None
if isinstance(pos_label, NoneType):
if isinstance(pos_label, NoneType) or not (self._is_native):
labels = self.classes_
kwargs = {
"average": average,
Expand Down
Loading

0 comments on commit f26db21

Please sign in to comment.