.. _f-kmeansconstraint: module ``mlmodel._kmeans_constraint_`` ====================================== Short summary +++++++++++++ module ``mlinsights.mlmodel._kmeans_constraint_`` Implémente la classe :class:`ConstraintKMeans`. :githublink:`%|py|6` Functions +++++++++ +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | function | truncated documentation | +====================================================================================================================+=====================================================================================================================================================================+ | :func:`_adjust_weights ` | Changes *weights* mapped to every cluster. *weights < 1* are used for big clusters, *weights > 1* are used for small ... | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_compute_balance ` | Computes weights difference. | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_compute_strategy_coefficient ` | Creates a matrix | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_constraint_association ` | Completes the constraint :epkg:`k-means`. | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_constraint_association_distance ` | Completes the constraint *k-means*, the function sorts points by distance to the closest cluster and associates ... | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_constraint_association_gain ` | Completes the constraint *k-means*. Follows the method described in `Same-size k-Means Variation `_. ... | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_constraint_association_weights ` | Associates points to clusters. | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_constraint_kmeans_weights ` | Runs KMeans iterator but weights cluster among them. | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_inertia ` | Computes total weighted inertia. | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_labels_inertia_weights ` | Computes weighted inertia. It also adds a fraction of the whole inertia depending on how balanced the clusters are. ... | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_randomize_index ` | Randomizes index depending on the value. Swap indexes. Modifies *index*. | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`_switch_clusters ` | Tries to switch clusters. Modifies *labels* inplace. | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`constraint_kmeans ` | Completes the constraint :epkg:`k-means`. | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`constraint_predictions ` | Computes the predictions but tries to associates the same numbers of points in each cluster. | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :func:`linearize_matrix ` | Linearizes a matrix into a new one with 3 columns value, row, column. The output format is similar to :epkg:`csr_matrix` ... | +--------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Documentation +++++++++++++ .. automodule:: mlinsights.mlmodel._kmeans_constraint_ :members: :special-members: __init__ :show-inheritance: