Skip to main content

kmedsecting

Bisecting K-Medoids yang ditulis murni dengan numpy. Tidak ada dependensi lain sehingga aman dipasang bersama paket apa pun.

Cluster dibelah menjadi dua secara berulang sampai jumlah kluster tercapai. Setiap pembelahan memakai satu dari empat metode K-Medoids dan satu dari tujuh metrik jarak.

Instalasi

pip install kmedsecting

Contoh Pemakaian

import numpy as np
from kmedsecting import BisectingKMedoids

X = np.random.rand(300, 4)

model = BisectingKMedoids(
    n_clusters=5,
    metric="manhattan",
    method="pam",
    split_selection="cost",
    split_init="farthest",
    random_state=0,
)
label = model.fit_predict(X)

print(model.medoid_indices_)
print(model.cluster_centers_)
print(model.inertia_)
print(model.predict(X[:10]))

Hyperparameter

Nama Pilihan Keterangan
n_clusters bilangan bulat Jumlah kluster akhir
metric euclidean manhattan cosine correlation mahalanobis gower jensen-shannon Ukuran jarak
method alternate pam clara gmask Cara menyelesaikan setiap pembelahan
init random heuristic k-medoids++ build farthest density density_farthest Pemilihan medoid awal pada tahap prototipe antara metode gmask
split_selection largest cost Kluster yang dibelah berikutnya. largest memilih anggota terbanyak dan cost memilih total jarak ke medoid terbesar
split_init random farthest density density_farthest Cara memilih dua medoid awal saat membelah
max_iter bilangan bulat Iterasi maksimum tiap penyelesaian
random_state bilangan bulat atau None Pengendali keacakan
clara_samples bilangan bulat Jumlah sampel untuk clara
clara_size bilangan bulat atau None Ukuran sampel untuk clara
gmask_size bilangan bulat Ukuran grup pada tingkat bawah gmask
gmask_ratio bilangan bulat Rasio peringkasan grup menjadi prototipe pada gmask
density_alpha 0 sampai 1 Bobot kepadatan pada density_farthest
categorical daftar indeks kolom atau None Kolom kategorik untuk gower

Catatan Metrik

  • cosine dan correlation memakai jarak satu dikurangi kemiripan.
  • mahalanobis memakai kovarian seluruh data latih.
  • gower menerima data campuran. Kolom teks dikenali otomatis sebagai kategorik.
  • jensen-shannon mengharuskan nilai tidak negatif. Setiap baris dinormalkan menjadi distribusi dan jaraknya berupa akar divergensi berbasis dua.

Catatan Metode

  • alternate dan pam membangun matriks jarak satu kluster penuh sehingga cocok untuk data kecil sampai menengah.
  • clara memakai sampel sehingga lebih hemat memori untuk data besar.
  • gmask mengikuti makalah Garcia-Morato dkk. berjudul Using k-medoids for distributed approximate similarity search with arbitrary distances. Data diringkas bertingkat menjadi prototipe lalu dua medoid dipilih dari prototipe teratas.

Atribut Hasil

  • labels_ label tiap sampel
  • medoid_indices_ indeks baris medoid
  • cluster_centers_ baris data yang menjadi medoid
  • inertia_ total jarak seluruh sampel ke medoidnya
  • n_clusters_ jumlah kluster yang benar terbentuk

Lisensi

MIT

Metadata

Release files for kmedsecting 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kmedsecting 0.1.0
File Size Uploaded Provenance Actions
kmedsecting-0.1.0.tar.gz 11.6 kB Without provenance Details for kmedsecting-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kmedsecting 0.1.0
File Interpreter ABI Platform Actions
kmedsecting-0.1.0-py3-none-any.whl Python 3 none any Details for kmedsecting-0.1.0-py3-none-any.whl

Total release size: 22.7 kB

Release files / kmedsecting-0.1.0.tar.gz

Download URL kmedsecting-0.1.0.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9cad46c819736f9b758b11ab3586f01044e99fffe6ea302d336a76f99245d66c
BLAKE2b-256 checksum
How to use checksums
47f36555664c23054129a7bd22fd68e0d761e684fa73f0cf092d85b8de13d11d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Release files / kmedsecting-0.1.0-py3-none-any.whl

Download URL kmedsecting-0.1.0-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
591229fc4255e6a8c4c6aa0844becf2557c1e1c9c940f190295a487d64b2294a
BLAKE2b-256 checksum
How to use checksums
adb7aa33156897019027fcdad897303f17bda32f9f769402cedfda0faa65bad9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Security for kmedsecting 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page