mars-project / mars-project/mars
[PROPOSAL] Unsupervised Algorithm Implementation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.7k
- Forks
- 325
- PR merge metrics
- No merged PRs in 30d
Description
Background
Currently, the traditional clustering algorithm KMeans has been implemented in Mars.
However, for a scientific computing library, there are few clustering algorithms implemented in Mars, and there is a lack of unsupervised clustering algorithms for optimizing large-scale data.
Mini-batch KMeans
Mini-batch KMeans is an improvement of KMeans algorithm specifically for processing large scale data.
Reference:
Sculley, David. "Web-scale k-means clustering." Proceedings of the 19th international conference on World wide web. 2010.
See https://www.eecs.tufts.edu/~dsculley/papers/fastkmeans.pdf.
implement proposal
- Implement the main algorithm class
MiniBatchKMeans. InheritKMeansclass so that I can resuse_check_param,_check_test_dataand other functions. - Implement the function
mini_batch_k_means. - Implement the main function
_mini_batch_stepseparately. This function serves as the core part of each iteration of the Mini-batch KMeans algorithms. - The
_init_centroidsfunction in_kmeans.pyhas support for batch and can be reused directly.
API definition
Use the same API design as Sklearn for now, but may change later due to the need for distributed optimization.
- n_clusters: The number of clusters to form as well as the number of centroids to generate.
- init: {'k-means++', 'random', 'k-means||'}, Method for initialization.
- max_iter: Maximum number of iterations over the complete dataset before stopping independently of any early stopping criterion heuristics.
- batch_size: Size of the mini batches.
- verbose: Verbosity mode.
- compute_labels: Compute label assignment and inertia for the complete dataset once the minibatch optimization has converged in fit.
- random_state: Determines random number generation for centroid initialization and random reassignment. Use an int to make the randomness deterministic.
- tol: Control early stopping based on the relative center changes as measured by a smoothed, variance-normalized of the mean center squared position changes. This early stopping heuristics is closer to the one used for the batch variant of the algorithms but induces a slight computational and memory overhead over the inertia heuristic. To disable convergence detection based on normalized center change, set tol to 0.0 (default).
- max_no_improvement: Control early stopping based on the consecutive number of mini batches that does not yield an improvement on the smoothed inertia. To disable convergence detection based on inertia, set max_no_improvement to None.
- init_size: Number of samples to randomly sample for speeding up the initialization (sometimes at the expense of accuracy): the only algorithm is initialized by running a batch KMeans on a random subset of the data. This needs to be larger than n_clusters.
- n_init: Number of random initializations that are tried. In contrast to KMeans, the algorithm is only run once, using the best of the
n_initinitializations as measured by inertia. - reassignment_ratio: Control the fraction of the maximum number of counts for a center to be reassigned. A higher value means that low count centers are more easily reassigned, which means that the model will take longer to converge, but should converge in a better clustering.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing KMeans implementation, especially _kmeans.py and its _init_centroids, _check_param, and _check_test_data helpers. Use the linked Sculley paper and the sklearn API list to define MiniBatchKMeans, mini_batch_k_means, and _mini_batch_step. Done means the proposed mini-batch algorithm and listed parameters are implemented while reusing the existing KMeans pieces.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, scikit-learn
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100