All Projects → bdelespierre → php-kmeans

bdelespierre / php-kmeans

Licence: MIT license
PHP K-Means

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to php-kmeans

Free Ai Resources
🚀 FREE AI Resources - 🎓 Courses, 👷 Jobs, 📝 Blogs, 🔬 AI Research, and many more - for everyone!
Stars: ✭ 192 (+137.04%)
Mutual labels:  machine-learning-algorithms
Machine Learning Notebooks
Machine Learning notebooks for refreshing concepts.
Stars: ✭ 222 (+174.07%)
Mutual labels:  machine-learning-algorithms
Watermark Remover
Remove watermark automatically(Just can use for fixed position watermark till now). 自动水印消除算法的实现(目前只支持固定水印位置)。
Stars: ✭ 236 (+191.36%)
Mutual labels:  machine-learning-algorithms
Meta Learning Papers
A classified list of meta learning papers based on realm.
Stars: ✭ 193 (+138.27%)
Mutual labels:  machine-learning-algorithms
Face Identification Tpe
Face identification with CNN + TPE using Keras
Stars: ✭ 208 (+156.79%)
Mutual labels:  machine-learning-algorithms
Color Accessibility Neural Network Deeplearnjs
🍃 Using a Neural Network to improve web accessibility in JavaScript.
Stars: ✭ 230 (+183.95%)
Mutual labels:  machine-learning-algorithms
Modeltime
Modeltime unlocks time series forecast models and machine learning in one framework
Stars: ✭ 189 (+133.33%)
Mutual labels:  machine-learning-algorithms
Suod
(MLSys' 21) An Acceleration System for Large-scare Unsupervised Heterogeneous Outlier Detection (Anomaly Detection)
Stars: ✭ 245 (+202.47%)
Mutual labels:  machine-learning-algorithms
Machine Learning Interview Enlightener
This repo is meant to serve as a guide for Machine Learning/AI technical interviews.
Stars: ✭ 207 (+155.56%)
Mutual labels:  machine-learning-algorithms
Aleph star
Reinforcement learning with A* and a deep heuristic
Stars: ✭ 235 (+190.12%)
Mutual labels:  machine-learning-algorithms
Dynaml
Scala Library/REPL for Machine Learning Research
Stars: ✭ 195 (+140.74%)
Mutual labels:  machine-learning-algorithms
Awesome Deep Learning And Machine Learning Questions
【不定期更新】收集整理的一些网站中(如知乎、Quora、Reddit、Stack Exchange等)与深度学习、机器学习、强化学习、数据科学相关的有价值的问题
Stars: ✭ 203 (+150.62%)
Mutual labels:  machine-learning-algorithms
Learn Statistical Learning Method
Implementation of Statistical Learning Method, Second Edition.《统计学习方法》第二版,算法实现。
Stars: ✭ 228 (+181.48%)
Mutual labels:  machine-learning-algorithms
Pyss3
A Python package implementing a new machine learning model for text classification with visualization tools for Explainable AI
Stars: ✭ 191 (+135.8%)
Mutual labels:  machine-learning-algorithms
Learningx
Deep & Classical Reinforcement Learning + Machine Learning Examples in Python
Stars: ✭ 241 (+197.53%)
Mutual labels:  machine-learning-algorithms
Bet On Sibyl
Machine Learning Model for Sport Predictions (Football, Basketball, Baseball, Hockey, Soccer & Tennis)
Stars: ✭ 190 (+134.57%)
Mutual labels:  machine-learning-algorithms
Self Attention Cv
Implementation of various self-attention mechanisms focused on computer vision. Ongoing repository.
Stars: ✭ 209 (+158.02%)
Mutual labels:  machine-learning-algorithms
Pretty Print Confusion Matrix
Confusion Matrix in Python: plot a pretty confusion matrix (like Matlab) in python using seaborn and matplotlib
Stars: ✭ 244 (+201.23%)
Mutual labels:  machine-learning-algorithms
Igel
a delightful machine learning tool that allows you to train, test, and use models without writing code
Stars: ✭ 2,956 (+3549.38%)
Mutual labels:  machine-learning-algorithms
Echotorch
A Python toolkit for Reservoir Computing and Echo State Network experimentation based on pyTorch. EchoTorch is the only Python module available to easily create Deep Reservoir Computing models.
Stars: ✭ 231 (+185.19%)
Mutual labels:  machine-learning-algorithms

PHP Kmean

Latest Version on Packagist Build Status Quality Score Total Downloads

K-mean clustering algorithm implementation in PHP.

Please also see the FAQ

Installation

You can install the package via composer:

composer require bdelespierre/php-kmeans

Usage

require "vendor/autoload.php";

// prepare 50 points of 2D space to be clustered
$points = [
    [80,55],[86,59],[19,85],[41,47],[57,58],
    [76,22],[94,60],[13,93],[90,48],[52,54],
    [62,46],[88,44],[85,24],[63,14],[51,40],
    [75,31],[86,62],[81,95],[47,22],[43,95],
    [71,19],[17,65],[69,21],[59,60],[59,12],
    [15,22],[49,93],[56,35],[18,20],[39,59],
    [50,15],[81,36],[67,62],[32,15],[75,65],
    [10,47],[75,18],[13,45],[30,62],[95,79],
    [64,11],[92,14],[94,49],[39,13],[60,68],
    [62,10],[74,44],[37,42],[97,60],[47,73],
];

// create a 2-dimentions space
$space = new KMeans\Space(2);

// add points to space
foreach ($points as $i => $coordinates) {
    $space->addPoint($coordinates);
}

// cluster these 50 points in 3 clusters
$clusters = $space->solve(3);

// display the cluster centers and attached points
foreach ($clusters as $num => $cluster) {
    $coordinates = $cluster->getCoordinates();
    printf(
        "Cluster %s [%d,%d]: %d points\n",
        $num,
        $coordinates[0],
        $coordinates[1],
        count($cluster)
    );
}

Note: the example is given with points of a 2D space but it will work with any dimention >1.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

Lesser General Public License (LGPL). Please see License File for more information.

FAQ

How to get coordinates of a point/cluster:

$x = $point[0];
$y = $point[1];

// or

list($x,$y) = $point->getCoordinates();

List all points of a space/cluster:

foreach ($cluster as $point) {
    printf('[%d,%d]', $point[0], $point[1]);
}

Attach data to a point:

$point = $space->addPoint([$x, $y, $z], "user #123");

Retrieve point data:

$data = $space[$point]; // e.g. "user #123"

Watch the algorithm run

Each iteration step can be monitored using a callback function passed to Kmeans\Space::solve:

$clusters = $space->solve(3, function($space, $clusters) {
    static $iterations = 0;

    printf("Iteration: %d\n", ++$iterations);

    foreach ($clusters as $i => $cluster) {
        printf("Cluster %d [%d,%d]: %d points\n", $i, $cluster[0], $cluster[1], count($cluster));
    }
});
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].