speaking style trait scores

This commit is contained in:
2026-01-23 12:39:12 +01:00
parent 84a0f8052e
commit 0f5ecf5ac7
2 changed files with 33 additions and 65 deletions

View File

@@ -73,7 +73,6 @@ def _(check_progress, data_all, duration_validation, mo):
{duration_validation(data_all)} {duration_validation(data_all)}
""") """)
return return
@@ -263,23 +262,14 @@ def _(mo, plot_most_ranked_1, top3_voices):
def _(mo): def _(mo):
mo.md(r""" mo.md(r"""
## Voice Speaking Style - Perception Traits ## Voice Speaking Style - Perception Traits
""")
return
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)
@app.cell(hide_code=True)
def _(mo):
mo.md(r"""
How does each voice score for each “speaking style labeled trait”? 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)
- There are 4 speaking styles: Green, Blue, Orange, Red.
- There are 16 traits distributed across the 4 speaking styles.
""") """)
return return
@app.cell @app.cell
def _(data, survey): def _(data, survey, utl):
ss_or, choice_map_or = survey.get_ss_orange_red(data) ss_or, choice_map_or = survey.get_ss_orange_red(data)
ss_gb, choice_map_gb = survey.get_ss_green_blue(data) ss_gb, choice_map_gb = survey.get_ss_green_blue(data)
@@ -289,43 +279,26 @@ def _(data, survey):
choice_map = {**choice_map_or, **choice_map_gb} choice_map = {**choice_map_or, **choice_map_gb}
# print(_d.head()) # print(_d.head())
print(choice_map) # print(choice_map)
return choice_map, ss_all
@app.cell
def _(choice_map, ss_all, utl):
ss_long = utl.process_speaking_style_data(ss_all, choice_map) ss_long = utl.process_speaking_style_data(ss_all, choice_map)
ss_long
return (ss_long,) return (ss_long,)
@app.cell @app.cell
def _(pl, ss_long): def _(mo, pl, plts, ss_long):
target_trait = "Indifferent | Unfocussed | Detached:Attentive | Helpful | Caring | Deliberate" content = """### How does each voice score for each “speaking style labeled trait”?"""
trait_data = ss_long.filter(pl.col("Description") == target_trait)
trait_data
return target_trait, trait_data
for i, trait in enumerate(ss_long.select("Description").unique().to_series().to_list()):
trait_d = ss_long.filter(pl.col("Description") == trait)
@app.cell content += f"""
def _(plts, target_trait, trait_data): ### {i+1}) {trait.replace(":", "")}
plts.plot_speaking_style_trait_scores(
trait_data,
title=target_trait.replace(":", ""),
# trait_description="Attentive vs Indifferent", # simplified title
)
return
{mo.ui.plotly(plts.plot_speaking_style_trait_scores(trait_d, title=trait.replace(":", ""), height=550))}
app._unparsable_cell(
""" """
for trait in ss_long.select(\"Description\").unique().to_series().to_list():
trait_data = ss_long.filter(pl.col(\"Description\") == trait) mo.md(content)
mo.md(f\"\"\" return
""",
name="_"
)
@app.cell(hide_code=True) @app.cell(hide_code=True)
@@ -343,21 +316,13 @@ def _(data, mo, plot_average_scores_with_counts, survey):
mo.md(f""" mo.md(f"""
How does each voice score on a scale from 1-10? ### How does each voice score on a scale from 1-10?
{mo.ui.plotly(plot_average_scores_with_counts(vscales, x_label='Voice', width=1000))} {mo.ui.plotly(plot_average_scores_with_counts(vscales, x_label='Voice', width=1000))}
""") """)
return return
@app.cell
def _(mo):
mo.md(r"""
""")
return
@app.cell(hide_code=True) @app.cell(hide_code=True)
def _(mo): def _(mo):
mo.md(r""" mo.md(r"""

View File

@@ -768,7 +768,7 @@ def plot_speaking_style_trait_scores(
pl.col("score").mean().alias("mean_score"), pl.col("score").mean().alias("mean_score"),
pl.col("score").count().alias("count") pl.col("score").count().alias("count")
]) ])
.sort("mean_score", descending=True) # Descending for Left-to-Right .sort("mean_score", descending=False) # Ascending for display bottom-to-top
) )
# Attempt to extract anchors from DF if not provided # Attempt to extract anchors from DF if not provided
@@ -795,33 +795,36 @@ def plot_speaking_style_trait_scores(
fig = go.Figure() fig = go.Figure()
fig.add_trace(go.Bar( fig.add_trace(go.Bar(
x=stats["Voice"], # X is Voice y=stats["Voice"], # Y is Voice
y=stats["mean_score"], # Y is Score x=stats["mean_score"], # X is Score
orientation='h',
text=stats["count"], text=stats["count"],
textposition='inside', textposition='inside',
textangle=0,
textfont=dict(size=16, color='white'),
texttemplate='%{text}', # Count on bar texttemplate='%{text}', # Count on bar
marker_color=ColorPalette.PRIMARY, marker_color=ColorPalette.PRIMARY,
hovertemplate='<b>%{x}</b><br>Average: %{y:.2f}<br>Count: %{text}<extra></extra>' hovertemplate='<b>%{y}</b><br>Average: %{x:.2f}<br>Count: %{text}<extra></extra>'
)) ))
# Add annotations for anchors # Add annotations for anchors
annotations = [] annotations = []
# Place anchors on the right side # Place anchors at the bottom
if left_anchor: if left_anchor:
annotations.append(dict( annotations.append(dict(
xref='paper', yref='y', xref='x', yref='paper',
x=1.01, y=1, x=1, y=-0.2, # Below axis
xanchor='left', yanchor='middle', xanchor='left', yanchor='top',
text=f"<b>1: {left_anchor.split('|')[0]}</b>", text=f"<b>1: {left_anchor.split('|')[0]}</b>",
showarrow=False, showarrow=False,
font=dict(size=10, color='gray') font=dict(size=10, color='gray')
)) ))
if right_anchor: if right_anchor:
annotations.append(dict( annotations.append(dict(
xref='paper', yref='y', xref='x', yref='paper',
x=1.01, y=5, x=5, y=-0.2, # Below axis
xanchor='left', yanchor='middle', xanchor='right', yanchor='top',
text=f"<b>5: {right_anchor.split('|')[0]}</b>", text=f"<b>5: {right_anchor.split('|')[0]}</b>",
showarrow=False, showarrow=False,
font=dict(size=10, color='gray') font=dict(size=10, color='gray')
@@ -832,21 +835,21 @@ def plot_speaking_style_trait_scores(
text=f"{title}<br><sub>{trait_description}</sub><br><sub>(Numbers on bars indicate respondent count)</sub>", text=f"{title}<br><sub>{trait_description}</sub><br><sub>(Numbers on bars indicate respondent count)</sub>",
y=0.92 y=0.92
), ),
xaxis_title="Voice", xaxis_title="Average Score (1-5)",
yaxis_title="Average Score (1-5)", yaxis_title="Voice",
height=height, height=height,
width=width, width=width,
plot_bgcolor=ColorPalette.BACKGROUND, plot_bgcolor=ColorPalette.BACKGROUND,
yaxis=dict( xaxis=dict(
range=[1, 5], range=[1, 5],
showgrid=True, showgrid=True,
gridcolor=ColorPalette.GRID, gridcolor=ColorPalette.GRID,
zeroline=False zeroline=False
), ),
xaxis=dict( yaxis=dict(
showgrid=False showgrid=False
), ),
margin=dict(r=150), margin=dict(b=120),
annotations=annotations, annotations=annotations,
font=dict(size=11) font=dict(size=11)
) )