Skip to content Skip to sidebar Skip to footer

Clustering On Python And Bokeh; Select Widget Which Allows User To Change Clustering Algorithm

I am trying to build a feature in a Bokeh dashboard which allows the user to cluster data. I am using the following example as a template, here is the link:- Clustering in Bokeh ex

Solution 1:

I don't know sklearn but comparing both your examples I can see the following:

  1. the Select is a Bokeh model which has value attribute of type string. So select.value is a string
  2. the dbscan is an algorithm function

So when you do algorithm = dbscan you assign an algorithm function to your algorithm variable and when you do algorithm = select.value in your second example you assign just a string to it so it won't work because string doesn't have the fit() function. You should do something like this:

algorithm = Noneif select.value == 'DBSCAN':
    algorithm = dbscan # use dbscan algorithm functionelif select.value == 'Birch':
      algorithm = birch  # use birch algorithm functionelif select.value == 'MiniBatchKmeans':
      algorithm = means  # use means algorithm function
etc...

if algorithm isnotNone:
    plots =[]
    for dataset in (noisy_circles, noisy_moons, blobs1, blobs2):
        ...
else:
   print('Please select an algorithm first')

Post a Comment for "Clustering On Python And Bokeh; Select Widget Which Allows User To Change Clustering Algorithm"