Skip to content

Commit 26419cf

Browse files
committed
Added iterations input
1 parent 8cff2bc commit 26419cf

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

app/streamlit_app.py

+31-25
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171

7272
VD_SEED = 42
7373

74+
VD_ITERATIONS = 50
75+
7476
V_AGGREGATION_MEAN = 'Mean'
7577

7678
V_AGGREGATION_STD = 'Std'
@@ -440,7 +442,7 @@ def mapper_clustering_input_section():
440442

441443
@st.cache_data(
442444
hash_funcs={'tdamapper.learn.MapperAlgorithm': MapperAlgorithm.__repr__},
443-
show_spinner='Compuring Mapper',
445+
show_spinner='Computing Mapper',
444446
)
445447
def compute_mapper(mapper, X, y):
446448
mapper_graph = mapper.fit_transform(X, y)
@@ -540,38 +542,42 @@ def plot_color_input_section(df_X, df_y):
540542
return df_y[col_feat].to_numpy(), col_feat
541543

542544

543-
def plot_seed_input_section():
544-
seed = st.number_input(
545-
'Seed',
546-
value=VD_SEED,
547-
help='Changing this value alters the shape',
548-
)
549-
return seed
550-
551-
552-
def plot_dim_input_section():
553-
toggle_3d = st.toggle(
554-
'3D',
555-
value=True,
556-
)
557-
dim = 3 if toggle_3d else 2
558-
return dim
559-
560-
561545
@st.cache_data(
562546
hash_funcs={'networkx.classes.graph.Graph': lambda g: _encode_graph(_get_graph_no_attribs(g))},
563-
show_spinner='Generating Mapper Embedding',
547+
show_spinner='Generating Mapper Layout',
564548
)
565-
def compute_mapper_plot(mapper_graph, dim, seed):
566-
mapper_plot = MapperPlot(mapper_graph, dim, seed=seed)
549+
def compute_mapper_plot(mapper_graph, dim, seed, iterations):
550+
mapper_plot = MapperPlot(
551+
mapper_graph,
552+
dim,
553+
seed=seed,
554+
iterations=iterations,
555+
)
567556
return mapper_plot
568557

569558

570559
def mapper_plot_section(mapper_graph):
571560
st.header('🗺️ Layout')
572-
dim = plot_dim_input_section()
573-
seed = plot_seed_input_section()
574-
mapper_plot = compute_mapper_plot(mapper_graph, dim, seed)
561+
toggle_3d = st.toggle(
562+
'3D',
563+
value=True,
564+
)
565+
dim = 3 if toggle_3d else 2
566+
seed = st.number_input(
567+
'Seed',
568+
value=VD_SEED,
569+
)
570+
iterations = st.number_input(
571+
'Iterations',
572+
value=VD_ITERATIONS,
573+
min_value=1,
574+
)
575+
mapper_plot = compute_mapper_plot(
576+
mapper_graph,
577+
dim,
578+
seed=seed,
579+
iterations=iterations,
580+
)
575581
return mapper_plot
576582

577583

0 commit comments

Comments
 (0)