From 70719702ec02967230a371569f7690caa8dcf80c Mon Sep 17 00:00:00 2001 From: Luigi Maiorano Date: Thu, 29 Jan 2026 12:16:09 +0100 Subject: [PATCH] added data selector ui element --- 02_quant_analysis.py | 151 ++++++++++++++++++++++--------------------- README.md | 5 ++ 2 files changed, 83 insertions(+), 73 deletions(-) diff --git a/02_quant_analysis.py b/02_quant_analysis.py index 19ba3e5..bd9404f 100644 --- a/02_quant_analysis.py +++ b/02_quant_analysis.py @@ -29,22 +29,45 @@ def _(): @app.cell -def _(): - RESULTS_FILE = 'data/exports/OneDrive_2026-01-21/Soft Launch Data/JPMC_Chase Brand Personality_Quant Round 1_January 21, 2026_Soft Launch_Labels.csv' +def _(mo): + file_browser = mo.ui.file_browser( + initial_path="./data/exports", multiple=False, restrict_navigation=True, filetypes=[".csv"], label="Select 'Labels' File" + ) + file_browser + return (file_browser,) + + +@app.cell +def _(Path, file_browser, mo): + mo.stop(file_browser.path(index=0) is None, mo.md("**⚠️ Please select a `_Labels.csv` file above to proceed**")) + # RESULTS_FILE = 'data/exports/OneDrive_2026-01-21/Soft Launch Data/JPMC_Chase Brand Personality_Quant Round 1_January 21, 2026_Soft Launch_Labels.csv' + RESULTS_FILE = Path(file_browser.path(index=0)) QSF_FILE = 'data/exports/OneDrive_2026-01-21/Soft Launch Data/JPMC_Chase_Brand_Personality_Quant_Round_1.qsf' + # RESULTS_FILE return QSF_FILE, RESULTS_FILE @app.cell -def _(JPMCSurvey, QSF_FILE, RESULTS_FILE): +def _(RESULTS_FILE, mo): + mo.stop(not RESULTS_FILE.name.lower().endswith('labels.csv'), mo.md("**⚠️ Make sure you select a `_Labels.csv` file above**")) + return + + +@app.cell +def _(JPMCSurvey, QSF_FILE, RESULTS_FILE, mo): S = JPMCSurvey(RESULTS_FILE, QSF_FILE) - data_all = S.load_data() + try: + data_all = S.load_data() + except NotImplementedError as e: + mo.stop(True, mo.md(f"**⚠️ {str(e)}**")) return S, data_all @app.cell(hide_code=True) def _(Path, RESULTS_FILE, data_all, mo): mo.md(f""" + --- + # Load Data **Dataset:** `{Path(RESULTS_FILE).name}` @@ -71,19 +94,7 @@ def _(check_progress, data_all, duration_validation, mo): @app.cell(hide_code=True) def _(mo): mo.md(r""" - ### ToDo: "straight-liner" detection and removal - """) - return - - -@app.cell(hide_code=True) -def _(mo): - mo.md(r""" - --- - - # Data Filter - - Use to select a subset of the data for the following analysis + ### ⚠️ ToDo: "straight-liner" detection and removal """) return @@ -91,7 +102,8 @@ def _(mo): @app.cell(hide_code=True) def _(S, mo): filter_form = mo.md(''' - # Data Filter + + {age} @@ -110,7 +122,15 @@ def _(S, mo): 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() - filter_form + mo.md(f''' + --- + + # Data Filter + + {filter_form} + ''') + + return (filter_form,) @@ -128,26 +148,15 @@ def _(S, data_all, filter_form, mo): @app.cell(hide_code=True) -def _(mo): +def _(S, data, mo): + char_rank = S.get_character_ranking(data)[0] mo.md(r""" --- # Analysis - """) - return - -@app.cell(hide_code=True) -def _(mo): - mo.md(r""" ## Character personality ranking """) - return - - -@app.cell -def _(S, data): - char_rank = S.get_character_ranking(data)[0] return (char_rank,) @@ -187,17 +196,12 @@ def _(S, calculate_weighted_ranking_scores, char_rank, mo): @app.cell(hide_code=True) -def _(mo): +def _(S, data, mo): + v_18_8_3 = S.get_18_8_3(data)[0].collect() + mo.md(r""" ## Voice Ranking """) - return - - -@app.cell -def _(S, data): - v_18_8_3 = S.get_18_8_3(data)[0].collect() - # print(v_18_8_3.head()) return (v_18_8_3,) @@ -266,18 +270,8 @@ def _(S, mo, top3_voices): return -@app.cell(hide_code=True) -def _(mo): - mo.md(r""" - ## Voice Speaking Style - Perception Traits - - Here you can find the speaking styles and traits: [Speaking Style Traits Quantitative test design.docx](https://voicebranding-my.sharepoint.com/:w:/g/personal/phoebe_voicebranding_ai/IQBfM_Z8PF98Qalz4lzIbJ3RAUCdc7waB32HZXCj7k3xfo0?e=rtFd27) - """) - return - - @app.cell -def _(S, data, utils): +def _(S, data, mo, utils): ss_or, choice_map_or = S.get_ss_orange_red(data) ss_gb, choice_map_gb = S.get_ss_green_blue(data) @@ -289,6 +283,12 @@ def _(S, data, utils): # print(_d.head()) # print(choice_map) ss_long = utils.process_speaking_style_data(ss_all, choice_map) + + mo.md(r""" + ## Voice Speaking Style - Perception Traits + + Here you can find the speaking styles and traits: [Speaking Style Traits Quantitative test design.docx](https://voicebranding-my.sharepoint.com/:w:/g/personal/phoebe_voicebranding_ai/IQBfM_Z8PF98Qalz4lzIbJ3RAUCdc7waB32HZXCj7k3xfo0?e=rtFd27) + """) return choice_map, ss_all, ss_long @@ -310,17 +310,17 @@ def _(S, mo, pl, ss_long): @app.cell(hide_code=True) -def _(mo): - mo.md(r""" - ## Voice Scale 1-10 - """) +def _(): return @app.cell -def _(S, data): +def _(S, data, mo): vscales = S.get_voice_scale_1_10(data)[0] # plot_average_scores_with_counts(vscales, x_label='Voice', width=1000) + mo.md(r""" + ## Voice Scale 1-10 + """) return (vscales,) @@ -334,10 +334,15 @@ def _(S, mo, vscales): return +@app.cell(hide_code=True) +def _(): + return + + @app.cell(hide_code=True) def _(mo): mo.md(r""" - ## Correlations Voice Speaking Styles <-> Voice Scale 1-10 + """) return @@ -345,19 +350,29 @@ def _(mo): @app.cell(hide_code=True) def _(mo): mo.md(r""" + + """) + return + + +@app.cell +def _(choice_map, mo, ss_all, utils, vscales): + df_style = utils.process_speaking_style_data(ss_all, choice_map) + df_voice_long = utils.process_voice_scale_data(vscales) + + joined_df = df_style.join(df_voice_long, on=["_recordId", "Voice"], how="inner") + # df_voice_long + + mo.md(r""" + ## Correlations Voice Speaking Styles <-> Voice Scale 1-10 + Let’s show how scoring better on these speaking styles correlates (or not) with better Voice Scale 1-10 evaluation. For each speaking style we show how the traits in these speaking styles correlate with Voice Scale 1-10 evaluation. This gives us a total of 4 correlation diagrams. Example for speaking style green: - Trait 1: Friendly | Conversational | Down-to-earth - Trait 2: Approachable | Familiar | Warm - Trait 3: Optimistic | Benevolent | Positive | Appreciative - """) - return - -@app.cell(hide_code=True) -def _(mo): - mo.md(r""" ### How to Interpret These Correlation Results Each bar represents the Pearson correlation coefficient (r) between a speaking style trait rating (1-5 scale) and the overall Voice Scale rating (1-10). @@ -369,16 +384,6 @@ def _(mo): | r < 0 (Red bars)| Negative correlation — voices rated higher on this trait tend to receive lower Voice Scale scores| | r ≈ 0| No relationship — this trait doesn't predict Voice Scale ratings| """) - return - - -@app.cell -def _(choice_map, ss_all, utils, vscales): - df_style = utils.process_speaking_style_data(ss_all, choice_map) - df_voice_long = utils.process_voice_scale_data(vscales) - - joined_df = df_style.join(df_voice_long, on=["_recordId", "Voice"], how="inner") - # df_voice_long return df_style, joined_df diff --git a/README.md b/README.md index e69de29..d025e74 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,5 @@ +Running on Ct-105 for shared access: + +``` +uv run marimo edit --headless --port 8080 --host ct-105.tail44fa00.ts.net +``` \ No newline at end of file