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
Built Distribution
File details
Details for the file py4k_means-0.0.1.tar.gz
.
File metadata
- Download URL: py4k_means-0.0.1.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 968802cf62e81700178a4f912a6d399b32963d437ce5b07c8feaf3705eaf9401 |
|
MD5 | 02de41114e4f7ad8ec0f61900976d87c |
|
BLAKE2b-256 | b0f68c19c19c91ee722549eeb14996e966240b3f9dea2d7e3495b2da78af0bcc |
File details
Details for the file py4k_means-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: py4k_means-0.0.1-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac1c72b5a61c255c29c889d06a7d41af566b33c09cb994accb45cbd07e36b892 |
|
MD5 | 586df0f600efd9745e0c76a136f7dfe0 |
|
BLAKE2b-256 | 8e55dabd47d363185ae15e51d569a38345d1909e20474f06feb96e8ffc42666e |