Skip to main content

Estimate the true number of clusters for k-means clustering using the Cluster Consistency Criterion (CCC).

Project description

Estimate the true number of clusters for k-means clustering using the Cluster Consistency Criterion (CCC).

This algorithm follows the rationale that true cluster centres should be similar in random split-halves of the data. If too maby clusters are specified, the cluster centres will become driven by random sampling error.

The CCC implements this as follows. For each number of clusters, the data are split into random halves for a given number of splits (e.g., 20). For each sp0lit, a k-means cluster analysis is run on each half separately. The distances between most-similar cluster centres are summed. The similarity score is e^(-distance_sum). The mean similarity score over random splits is the score for the given number of clusters.

The best estimate of the true number of clusters is determined by where the improvement in score drops off, which occurs when the number of clusters becomes higher than the true number of clusters.

The file test.py gives an example and simulation script. Usage is:

O = teg_CCC.get_best_k_CCC(X)

where X is a 2D array of shape N_Observations x N_Variables. There is an optional argument for max_n_clusters, set to 10 by default. The output is a dictionary with the estimate of true cluster centres (best_n) as well as the similarity score per number of clusters (scores_per_n) and the associated number of clusters (n_vec).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

teg_CCC-0.0.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

teg_CCC-0.0.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file teg_CCC-0.0.2.tar.gz.

File metadata

  • Download URL: teg_CCC-0.0.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for teg_CCC-0.0.2.tar.gz
Algorithm Hash digest
SHA256 225513b0fc297d3bb91f97b460cd5e2c9e054d6a2c04f9c24653525c82078978
MD5 3bc69a176b7954dcd88365ecdbb8e90c
BLAKE2b-256 300f01fab3f3edc525ce63c878314f0e93cb99b941eb738986c41c0643eb414a

See more details on using hashes here.

File details

Details for the file teg_CCC-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: teg_CCC-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for teg_CCC-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 36dcdd5bcef4511a59b9b4eadf5dc4c0eabf33fb603691286e039fa8d9a0d76b
MD5 8bd30f312525d76ba63cf00d8fff1677
BLAKE2b-256 dfbe7b7bf47e115d50ada108e6af480b28a038962566aab1eeeda27942a5123f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page