OPEN-SOURCE SCRIPT
Updated

Function K-Means Clustering

9 617
Description:
A Function that returns cluster centers for given data (X,Y) vector points.

Inputs:
_X: Array containing x data points.¹
_Y: Array containing y data points.¹
_number_of_clusters: number of clusters.

Note:
¹: _X and _Y size must match.

Outputs:
_centers_x: Array containing x data points.
_centers_y: Array containing y data points.

Resources:
rosettacode.org/wiki/K-means++_clustering
en.wikipedia.org/wiki/K-means_clustering
Release Notes
Update to V5 and fixed a a few errors in the code. -_-*

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.