eagle0504 commited on
Commit
a14e5d3
·
verified ·
1 Parent(s): 0752a49

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -68,14 +68,14 @@ st.pyplot(fig_corr)
68
  st.header("4. Impact of Categorical Variables on Average Score")
69
 
70
  def plot_and_analyze_categorical(dataframe, category_col, score_col='average_score'):
71
- # Corrected line with single quotes for replace arguments
72
  st.subheader(f"4.{plot_and_analyze_categorical.counter}. {category_col.replace('_', ' ').title()}")
73
  plot_and_analyze_categorical.counter += 1
74
 
75
  # Violin Plot
76
  fig_violin, ax_violin = plt.subplots(figsize=(10, 6))
77
  sns.violinplot(x=category_col, y=score_col, data=dataframe, ax=ax_violin)
78
- ax_violin.set_title(f'{score_col.replace("_", " ").title()} by {category_col.replace("_", " ").title()}')
 
79
  ax_violin.tick_params(axis='x', rotation=45, ha='right')
80
  st.pyplot(fig_violin)
81
 
@@ -85,7 +85,6 @@ def plot_and_analyze_categorical(dataframe, category_col, score_col='average_sco
85
  group1 = dataframe[dataframe[category_col] == dataframe[category_col].unique()[0]][score_col]
86
  group2 = dataframe[dataframe[category_col] == dataframe[category_col].unique()[1]][score_col]
87
  t_stat, p_val = stats.ttest_ind(group1, group2)
88
- # Corrected line with single quotes for replace arguments
89
  st.write(f"Independent t-test between **{dataframe[category_col].unique()[0]}** and **{dataframe[category_col].unique()[1]}** for {score_col.replace('_', ' ')}:")
90
  st.write(f" t-statistic = {t_stat:.3f}, p-value = {p_val:.3f}")
91
  if p_val < 0.05:
@@ -95,7 +94,8 @@ def plot_and_analyze_categorical(dataframe, category_col, score_col='average_sco
95
  else:
96
  model = ols(f'{score_col} ~ C({category_col})', data=dataframe).fit()
97
  anova_table = sm.stats.anova_lm(model, typ=2)
98
- st.write(f"ANOVA for {category_col} on {score_col.replace("_", " ")}:")
 
99
  st.dataframe(anova_table)
100
  if anova_table['PR(>F)'][0] < 0.05:
101
  st.success(" **Conclusion: Statistically significant differences between group means (p < 0.05).**")
 
68
  st.header("4. Impact of Categorical Variables on Average Score")
69
 
70
  def plot_and_analyze_categorical(dataframe, category_col, score_col='average_score'):
 
71
  st.subheader(f"4.{plot_and_analyze_categorical.counter}. {category_col.replace('_', ' ').title()}")
72
  plot_and_analyze_categorical.counter += 1
73
 
74
  # Violin Plot
75
  fig_violin, ax_violin = plt.subplots(figsize=(10, 6))
76
  sns.violinplot(x=category_col, y=score_col, data=dataframe, ax=ax_violin)
77
+ # This line was also causing an issue, correcting here too
78
+ ax_violin.set_title(f'{score_col.replace('_', ' ').title()} by {category_col.replace('_', ' ').title()}')
79
  ax_violin.tick_params(axis='x', rotation=45, ha='right')
80
  st.pyplot(fig_violin)
81
 
 
85
  group1 = dataframe[dataframe[category_col] == dataframe[category_col].unique()[0]][score_col]
86
  group2 = dataframe[dataframe[category_col] == dataframe[category_col].unique()[1]][score_col]
87
  t_stat, p_val = stats.ttest_ind(group1, group2)
 
88
  st.write(f"Independent t-test between **{dataframe[category_col].unique()[0]}** and **{dataframe[category_col].unique()[1]}** for {score_col.replace('_', ' ')}:")
89
  st.write(f" t-statistic = {t_stat:.3f}, p-value = {p_val:.3f}")
90
  if p_val < 0.05:
 
94
  else:
95
  model = ols(f'{score_col} ~ C({category_col})', data=dataframe).fit()
96
  anova_table = sm.stats.anova_lm(model, typ=2)
97
+ # Corrected line with single quotes for replace arguments
98
+ st.write(f"ANOVA for {category_col} on {score_col.replace('_', ' ')}:")
99
  st.dataframe(anova_table)
100
  if anova_table['PR(>F)'][0] < 0.05:
101
  st.success(" **Conclusion: Statistically significant differences between group means (p < 0.05).**")