verticapy.machine_learning.memmodel.cluster.KPrototypes.transform#
- KPrototypes.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 KPrototypes
We will use the following attributes:
clusters = [ [0.5, 'high'], [1, 'low'], [100, 'high'], ] p = 2 gamma = 1.0 is_categorical = [0, 1]
Let’s create a model.
model_kp = KPrototypes(clusters, p, gamma, is_categorical)
Create a dataset.
data = [[2, 'low']]
Transform the data.
model_kp.transform(data) Out[8]: array([[3.250e+00, 1.000e+00, 9.605e+03]])
Note
Refer to
KPrototypes
for more information about the different methods and usages.