Beispiel #1
0
def main():
    points = CIRCLE.random_uniform(n_samples=N_POINTS, bound=None)

    centers, weights, clusters, n_iterations = METRIC.optimal_quantization(
        points=points,
        n_centers=N_CENTERS,
        n_repetitions=N_REPETITIONS,
        tolerance=TOLERANCE)

    plt.figure(0)
    visualization.plot(points=centers, space='S1', color='red')

    plt.figure(1)
    circle = visualization.Circle()
    circle.draw()
    for i in range(N_CENTERS):
        circle.draw_points(points=clusters[i])
def main():
    circle = Hypersphere(dimension=1)

    data = circle.random_uniform(n_samples=1000)

    n_clusters = 5
    clustering = OnlineKMeans(metric=circle.metric, n_clusters=n_clusters)
    clustering = clustering.fit(data)

    plt.figure(0)
    visualization.plot(points=clustering.cluster_centers_, space='S1',
                       color='red')
    plt.show()

    plt.figure(1)
    ax = plt.axes()
    circle_plot = visualization.Circle()
    circle_plot.draw(ax=ax)
    for i in range(n_clusters):
        cluster = data[clustering.labels_ == i, :]
        circle_plot.draw_points(ax=ax, points=cluster)
    plt.show()