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:
- the
Selectis a Bokeh model which hasvalueattribute of typestring. Soselect.valueis a string - the
dbscanis 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"