# visualise scomplex_isoForest_pca color_values = isoForest_pca - isoForest_pca. FigureWidget ( data = plotly_graph_data, layout = layout ) fw_hist = node_hist_fig ( colorf_distribution, bgcolor = bgcolor, y_gridcolor = y_gridcolor ) fw_summary = summary_fig ( mapper_summary, height = 300 ) dashboard = hovering_widgets ( kmgraph, fw_graph, ctooltips = True, # ctooltips = True, because we assigned a label to each #cluster member bgcolor = bgcolor, y_gridcolor = y_gridcolor, member_textbox_width = 600 ) #Update the fw_graph colorbar, setting its title: fw_graph. min () my_colorscale = pl_brewer kmgraph, mapper_summary, colorf_distribution = get_mapper_graph ( scomplex_isoForest, color_values, color_function_name = 'Distance to x-min', colorscale = my_colorscale ) # assign to node the node label (0 for benign, 1 for malignant) for node in kmgraph : node = y ]] bgcolor = 'rgba(10,10,10, 0.9)' y_gridcolor = 'rgb(150,150,150)' # on a black background the gridlines are set on grey plotly_graph_data = plotly_graph ( kmgraph, graph_layout = 'fr', colorscale = my_colorscale, factor_size = 2.5, edge_linewidth = 0.5 ) layout = plot_layout ( title = 'Topological network representing the breast cancer dataset', width = 620, height = 570, annotation_text = get_kmgraph_meta ( mapper_summary ), bgcolor = bgcolor ) fw_graph = go. # visualise scomplex_isoForest color_values = lens1 - lens1. Plot the dashboard consisting in the two figures: title = "Nodes are colored according to the proportion of malignant members" showscale = False # remove the colorbar fw1. annotations = None # remove the mapper_summary from the second plot fw1.
#Input mapper 2.0 features update
color = 'rgb(125,125,125)' # update the graph edge color fw1. color = new_color # update node colors fw1. FigureWidget ( fwn_graph ) # define a new figure from the fwn_graph that will be colored by the new color function with fw1. r = 45 # decrease the right margin from 60px (default val) to 45 pixels fw1 = go. width = 550 # change the figure size in order to plot two "parallel" copies fwn_graph. x = - 0.14 # place toolbar at the figure left side fwn_graph. text = tooltips # add the new tooltips fwn_graph. batch_update (): # make updates for the new figure fwn_graph. FigureWidget ( fw_graph ) # copy the initial FigureWidget with fwn_graph. append ( 1.0 * label_counts / n_members ) #multiply by 1 for python 2.7.+ for m in range ( len ( label_counts )): tooltips += '' + str ( label_type ) + ': ' + str ( label_counts ) # append how many benign/malign # members exist in each node fwn_graph = go. shape = 1 : if label_type = 'benign' : new_color. unique ( member_labels, return_counts = True ) n_members = label_counts. text ) # we perform this conversion because fw.data.text is a tuple and we want to update # the tooltips new_color = for j, node in enumerate ( kmgraph ): member_label_ids = y ]] member_labels = for id in member_label_ids ] label_type, label_counts = np. Here we use the brewer colorscale with hex color codes.īreastc_dict = tooltips = list ( fw_graph. KMeans ( n_clusters = 2, random_state = 3471 ))įirst we visualize the resulting graph via a color_function that associates to lens data their x-coordinate distance to min, and colormap these coordinates to a given Plotly colorscale. Cover ( n_cubes = 15, perc_overlap = 0.7 ), clusterer = sklearn. c_ # Define the simplicial complex scomplex = mapper. fit_transform ( X, projection = "l2norm" ) # Combine lenses pairwise to get a 2-D lens i.e. KeplerMapper ( verbose = 0 ) lens2 = mapper. shape, 1 )) # Create another 1-D lens with L2-norm mapper = km. IsolationForest ( random_state = 1729 ) model. array ( df ) # Create a custom 1-D lens with Isolation Forest model = ensemble. apply ( lambda x : 1 if x = "M" else 0 ) X = np. read_csv ( path ) feature_names = ] df = df. # Data - the Wisconsin Breast Cancer Dataset # path = 'input/breast-cancer.csv' df = pd.