From 97c4b07208ba88e1c95d8a597323d3555fd4bc33 Mon Sep 17 00:00:00 2001 From: Luigi Maiorano Date: Mon, 2 Feb 2026 23:32:10 +0100 Subject: [PATCH] added filter disabled broken cells and starting spoken voice generic results --- 03_quant_report.py | 250 +++++++++++++-------------------------------- 1 file changed, 69 insertions(+), 181 deletions(-) diff --git a/03_quant_report.py b/03_quant_report.py index ddb91cc..e74c297 100644 --- a/03_quant_report.py +++ b/03_quant_report.py @@ -154,10 +154,48 @@ def _(): return +@app.cell +def _(S): + filter_form = mo.md(''' + + + + {age} + + {gender} + + {ethnicity} + + {income} + + {consumer} + ''' + ).batch( + age=mo.ui.multiselect(options=S.options_age, value=S.options_age, label="Select Age Group(s):"), + gender=mo.ui.multiselect(options=S.options_gender, value=S.options_gender, label="Select Gender(s):"), + ethnicity=mo.ui.multiselect(options=S.options_ethnicity, value=S.options_ethnicity, label="Select Ethnicities:"), + income=mo.ui.multiselect(options=S.options_income, value=S.options_income, label="Select Income Group(s):"), + consumer=mo.ui.multiselect(options=S.options_consumer, value=S.options_consumer, label="Select Consumer Groups:") + ).form() + mo.md(f''' + --- + + # Data Filter + + {filter_form} + ''') + return + + @app.cell def _(data_validated): - # drop rows where 'consumer' is null - # data = data_validated.filter(pl.col('Consumer').is_not_null()) + # mo.stop(filter_form.value is None, mo.md("**Please submit filter above to proceed**")) + # _d = S.filter_data(data_validated, age=filter_form.value['age'], gender=filter_form.value['gender'], income=filter_form.value['income'], ethnicity=filter_form.value['ethnicity'], consumer=filter_form.value['consumer']) + + # # Stop execution and prevent other cells from running if no data is selected + # mo.stop(len(_d.collect()) == 0, mo.md("**No Data available for current filter combination**")) + # data = _d + data = data_validated data.collect() return (data,) @@ -222,7 +260,7 @@ def _(): return -@app.cell +@app.cell(disabled=True) def _(): mo.md(r""" ## Best performing: Original vs Refined frankenstein @@ -230,7 +268,7 @@ def _(): return -@app.cell +@app.cell(disabled=True) def _(S, data): char_refine_rank = S.get_character_refine(data)[0] # print(char_rank.collect().head()) @@ -273,7 +311,7 @@ def _(S, char_rank): return -@app.cell +@app.cell(disabled=True) def _(): mo.md(r""" ### Statistical Significance Character Ranking @@ -281,7 +319,7 @@ def _(): return -@app.cell +@app.cell(disabled=True) def _(S, char_rank): _pairwise_df, _meta = S.compute_ranking_significance(char_rank) @@ -385,10 +423,10 @@ def _(S, char_df): """ mo.md(_content) - return character_colors, consistent_sort_order + return -@app.cell +@app.cell(disabled=True) def _(): mo.md(r""" ## Statistical significance best characters @@ -400,176 +438,6 @@ def _(): return -# @app.cell(hide_code=True) -# def _(): -# mo.md(r""" -# # BC per Consumer -# """) -# return - - -# @app.cell -# def _(): -# split_group = 'Consumer' -# return (split_group,) - - -# @app.cell -# def _(split_group): -# mo.md(rf""" -# ## Character Ranking Points (per {split_group} segment) -# """) -# return - - -# @app.cell -# def _(S, data): -# _content = "" -# for _consumer_group, _consumer_df in utils.split_consumer_groups(data).items(): - -# _char_rank = S.get_character_ranking(_consumer_df)[0] -# _char_rank_weighted = calculate_weighted_ranking_scores(_char_rank) - -# _plot = S.plot_weighted_ranking_score( -# _char_rank_weighted, -# title=f'Most Popular Character - Weighted Popularity Score - CONSUMER: "{_consumer_group.replace("_", " ").replace("Woth", 'Worth')}"
(1st=3pts, 2nd=2pts, 3rd=1pt)', -# x_label='Voice' -# ) - -# _content += f""" -# {mo.ui.altair_chart(_plot)} - -# """ - -# mo.md(_content) -# return - - -# @app.cell -# def _(split_group): -# mo.md(rf""" -# ## Character Ranking Place 1-2-3 in one (per {split_group}) -# """) -# return - - -# @app.cell -# def _(S, data): -# _content = "" -# for _consumer_group, _consumer_df in utils.split_consumer_groups(data).items(): - -# _char_rank = S.get_character_ranking(_consumer_df)[0] - - -# _plot = S.plot_top3_ranking_distribution(_char_rank, x_label='Character Personality', title='Character Personality: Rankings Top 3 - CONSUMER: "'+_consumer_group.replace("_", " ").replace("Woth", 'Worth')+'"') - -# _content += f""" -# {mo.ui.altair_chart(_plot)} - -# """ - -# mo.md(_content) -# return - - -# @app.cell -# def _(split_group): -# mo.md(rf""" -# ## Character Ranking times 1st place (per {split_group}) -# """) -# return - - -# @app.cell -# def _(S, data): -# _content = "" -# for _consumer_group, _consumer_df in utils.split_consumer_groups(data).items(): - -# _char_rank = S.get_character_ranking(_consumer_df)[0] - -# _plot = S.plot_most_ranked_1(_char_rank, title=f'Most Popular Character - CONSUMER: "{_consumer_group.replace("_", " ").replace("Woth", 'Worth')}"
(Number of Times Ranked 1st)', x_label='Character Personality') - -# _content += f""" -# {mo.ui.altair_chart(_plot)} - -# """ - -# mo.md(_content) -# return - - -# @app.cell -# def _(split_group): -# mo.md(rf""" -# ## Predefined personality traits WordClouds per {split_group} -# """) -# return - - -# @app.cell -# def _(S, data): -# _content = "" -# for _consumer_group, _consumer_df in utils.split_consumer_groups(data).items(): -# _top8_traits = S.get_top_8_traits(_consumer_df)[0] - -# _plot = S.plot_traits_wordcloud( -# data=_top8_traits, -# column='Top_8_Traits', -# title=f'Most Prominent Personality Traits - CONSUMER: "{_consumer_group.replace("_", " ").replace("Woth", "Worth")}"', -# ) - -# _content += f""" -# {_plot} - -# """ - -# mo.md(_content) -# return - - -# @app.cell -# def _(split_group): -# mo.md(rf""" -# ## Frequency traits chosen - per {split_group} segment -# """) -# return - - -# @app.cell -# def _(S, character_colors, consistent_sort_order, data): -# top_char = "The Coach" - -# _content = "" -# for _consumer_group, _consumer_df in utils.split_consumer_groups(data).items(): - -# _char_df = S.get_character_refine(_consumer_df)[0] - -# _freq_df, _ = S.transform_character_trait_frequency(_char_df, top_char) -# _main_color, _highlight_color = character_colors[top_char] -# _chart = S.plot_single_character_trait_frequency( -# data=_freq_df, -# character_name=top_char, -# bar_color=_main_color, -# highlight_color=_highlight_color, -# trait_sort_order=consistent_sort_order, -# title=f"""Top Personality Traits for '{top_char}' - CONSUMER: "{_consumer_group.replace('_', ' ').replace("Woth", "Worth")}""" -# ) -# _content += f""" -# {mo.ui.altair_chart(_chart)} - -# """ -# mo.md(_content) -# return - - -# @app.cell -# def _(): -# mo.md(r""" -# # BC per Gender -# """) -# return - - @app.cell def _(): return @@ -590,11 +458,24 @@ def _(): return +@app.cell +def _(): + mo.md(r""" + ## 8 Most Chosen + """) + return + + @app.cell def _(S, data): - top3_voices = S.get_top_3_voices(data)[0] - top3_voices_weighted = calculate_weighted_ranking_scores(top3_voices) - return top3_voices, top3_voices_weighted + v_18_8_3 = S.get_18_8_3(data)[0].collect() + return (v_18_8_3,) + + +@app.cell +def _(S, v_18_8_3): + S.plot_voice_selection_counts(v_18_8_3) + return @app.cell(hide_code=True) @@ -607,6 +488,13 @@ def _(): return +@app.cell +def _(S, data): + top3_voices = S.get_top_3_voices(data)[0] + top3_voices_weighted = calculate_weighted_ranking_scores(top3_voices) + return top3_voices, top3_voices_weighted + + @app.cell def _(S, top3_voices): _plot = S.plot_ranking_distribution(top3_voices, x_label='Voice')