def update_algorithm_or_clusters(attrname, old, new):
    global X
    algorithm = algorithm_select.value
    n_clusters = int(clusters_slider.value)
    (X, y_pred) = clustering(X, algorithm, n_clusters)
    colors = [spectral[i] for i in y_pred]
    source.data['colors'] = colors
    source.data['x'] = X[:, 0]
    source.data['y'] = X[:, 1]
    plot.title.text = algorithm
def update_algorithm_or_clusters(attrname, old, new):
    global X
    algorithm = algorithm_select.value
    n_clusters = int(clusters_slider.value)
    (X, y_pred) = clustering(X, algorithm, n_clusters)
    colors = [spectral[i] for i in y_pred]
    source.data['colors'] = colors
    source.data['x'] = X[:, 0]
    source.data['y'] = X[:, 1]
    plot.title.text = algorithm