best_k¶
In [ ]:
best_k(input_relation: (str, vDataFrame),
X: list = [],
n_cluster: (tuple, list) = (1, 100),
init: (str, list) = "kmeanspp",
max_iter: int = 50,
tol: float = 1e-4,
elbow_score_stop: float = 0.8)
Finds the k-means k based on a score.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
input_relation | str / vDataFrame | ❌ | Relation to use to train the model. |
X | list | ✓ | List of the predictor columns. If empty, all the numerical columns will be used. |
n_cluster | tuple / list | ✓ | Tuple representing the number of cluster to start with and to end with. It can also be customized list with the different K to test. |
init | str / list | ✓ | The method to use to find the initial cluster centers.
|
max_iter | int | ✓ | The maximum number of iterations the algorithm performs. |
tol | float | ✓ | Determines whether the algorithm has converged. The algorithm is considered converged after no center has moved more than a distance of 'tol' from the previous iteration. |
elbow_score_stop | float | ✓ | Stops the Parameters Search when this Elbow score is reached. |
Returns¶
int : the k-means k.
Example¶
In [3]:
from verticapy.learn.model_selection import best_k
best_k(input_relation = "public.iris",
X = ["PetalLengthCm", "PetalWidthCm"],
elbow_score_stop = 0.9)
Out[3]:
