K-Means Python Library
Project description
py4k-means
K-Means Python Library
Getting Started
This project is simply implementation of K-Means clustering algorithm in python programming language.
Prerequisites
Numpy & Pandas
Installing
The easiest way to install py4k-means is using pip
pip install py4k-means
Usage
There is only 1 public method of k_means class. It is cluster. cluster method takes 3 argument namely x, k, and max_iter. x is the data its self, k is the number of cluster we are aiming to, while max_iter is maximum iteration. By default max_iter is 10. The return of this method is pandas DataFrame with 1 column addition, it is the label column obtained by K-Means algorithm
from py4k_means.cluster import k_means
import numpy as np
import matplotlib.pyplot as plt
x = [np.random.uniform(-5,5 ,2) for i in range(500)]
km = k_means()
y = km.cluster(x,4,20)
plt.scatter(y['x0'],y['x1'],c=y['label'],cmap='rainbow')
plt.show()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py4k_means-0.0.1.tar.gz
(2.4 kB
view hashes)
Built Distribution
Close
Hashes for py4k_means-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac1c72b5a61c255c29c889d06a7d41af566b33c09cb994accb45cbd07e36b892 |
|
MD5 | 586df0f600efd9745e0c76a136f7dfe0 |
|
BLAKE2b-256 | 8e55dabd47d363185ae15e51d569a38345d1909e20474f06feb96e8ffc42666e |