How to return value using interact_manual python

278 views Asked by At

I have the following function, which plots UMAP, based on the number of clusters I've chosen, and returns series 'labels'.

def UMAPplot_building(file_name, num_clusters):
   logr_file = pd.read_csv(file_name, sep='\t')

   projector = umap.UMAP(metric='euclidean', random_state=42, verbose=True)
   logr_projection = projector.fit_transform(logr_file.T)
   logr_projection = pd.DataFrame(logr_projection,
                                 index=logr_file.columns,
                                 columns=['v1', 'v2'])

   clustermap_result = clustermap_wp(logr_projection.T, xl=[], yl=[])

   labels = cut_clustermap_tree(clustermap_result, num_clusters)
   umap_plot(logr_projection, labels)
   labels.index = [index.replace('.', '-') for index in labels.index]
   return labels

To choose the amount of clusters I use interact_manual:

interact_manual(UMAPplot_building, num_clusters = widgets.IntSlider(min=1, max=20), 
file_name=fixed(my_file, sep='\t'))

The problem is that I need to return 'labels' to use it further in my script. I know that for interactive we can use .result and it returns the value, but I cannot find how to do it using interact_manual. Thank you in advance.

0

There are 0 answers