verticapy.machine_learning.memmodel.cluster.NearestCentroid.transform#
- NearestCentroid.transform(X: list | ndarray) ndarray #
Transforms and returns the distance to each cluster.
Parameters#
- X: ArrayLike
The data on which to make the transformation.
Returns#
- numpy.array
Transformed values.
Examples#
Import the required module.
from verticapy.machine_learning.memmodel.cluster import KMeans
We will use the following attributes:
clusters = [[0.5, 0.6], [1, 2], [100, 200]] p = 2
Let’s create a model.
model_km = KMeans(clusters, p)
Create a dataset.
data = [[2, 3]]
Transform the data.
model_km.transform(data)[0] Out[55]: array([ 2.83019434, 1.41421356, 220.02954347])
Important
For this example, a specific model is utilized, and it may not correspond exactly to the model you are working with. To see a comprehensive example specific to your class of interest, please refer to that particular class.