TradingView
RicardoSantos
6 paź 2021 09:05

SignalProcessingClusteringKMeans 

Bitcoin / U.S. dollarBitstamp

Opis

Library "SignalProcessingClusteringKMeans"
K-Means Clustering Method.

nearest(point_x, point_y, centers_x, centers_y) finds the nearest center to a point and returns its distance and center index.
Parameters:
  • point_x: float, x coordinate of point.
  • point_y: float, y coordinate of point.
  • centers_x: float array, x coordinates of cluster centers.
  • centers_y: float array, y coordinates of cluster centers.
    @ returns tuple of int, float.



bisection_search(samples, value) Bissection Search
Parameters:
  • samples: float array, weights to compare.
  • value: float array, weights to compare.

Returns: int.

label_points(points_x, points_y, centers_x, centers_y) labels each point index with cluster index and distance.
Parameters:
  • points_x: float array, x coordinates of points.
  • points_y: float array, y coordinates of points.
  • centers_x: float array, x coordinates of points.
  • centers_y: float array, y coordinates of points.

Returns: tuple with int array, float array.

kpp(points_x, points_y, n_clusters) K-Means++ Clustering adapted from Andy Allinger.
Parameters:
  • points_x: float array, x coordinates of the points.
  • points_y: float array, y coordinates of the points.
  • n_clusters: int, number of clusters.

Returns: tuple with 2 arrays, float array, int array.
Komentarze
f1l1per.
wow, just incredible. Thank you very much
Coffeehouse-Analytics
How do you get the sample result as for example seen with the bubbles in the chart here?
When I import the library into an empty indicator script and copy the code example at the end into the script (and adding the library name in front of the corresponding function calls) I get absolutely nothing?

Edit: Solved! :-)
I just had to look to the right of the last bar of the actual chart symbol.
BobAndrews
Hello Ricardo, thanks for the great work as always. Red dot 0 does not look like the cenroid of red dots. Or am I not understanding the plot output correctly?
RicardoSantos
@BobAndrews, nearest to the center, not the center :)
BobAndrews
@RicardoSantos, Thanks for the reply. You mean closest to the Centroid? I calculated 26.Aug24; 146 for the Centroid. Other points seem to be closer. I'm just saying it because it's very noticeable.
thenandopro
so im a bit confused on what this actually dose my friend.
RicardoSantos
@thenandopro, it uses Kmeans Algorithm to identify clusters in the data.
bunulu
amazing
Więcej