Loading...

verticapy.machine_learning.memmodel.cluster.BisectingKMeans.predict#

BisectingKMeans.predict(X: list | ndarray) ndarray#

Predicts using the BisectingKMeans model.

Parameters#

X: ArrayLike

The data on which to make the prediction.

Returns#

numpy.array

Predicted values.

Examples#

Import the required module.

from verticapy.machine_learning.memmodel.cluster import BisectingKMeans

We will use the following attributes:

clusters = [
    [0.5, 0.6],
    [1, 2],
    [100, 200],
    [10, 700],
    [-100, -200],
]


children_left = [1, 3, None, None, None]

children_right = [2, 4, None, None, None]

Let’s create a model.

model_bkm = BisectingKMeans(clusters, children_left, children_right)

Create a dataset.

data = [[2, 3]]

Compute the predictions.

model_bkm.predict(data)[0]
Out[7]: 4

Note

Refer to BisectingKMeans for more information about the different methods and usages.