Yara Kyrychenko
commited on
Commit
·
11f9c2b
1
Parent(s):
6a9c1bb
init
Browse files- .DS_Store +0 -0
- .streamlit/config.toml +8 -0
- README.md +3 -3
- app.py +89 -0
- mist_stats.csv +0 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
.streamlit/config.toml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[server]
|
2 |
+
port = 8501
|
3 |
+
|
4 |
+
[browser]
|
5 |
+
gatherUsageStats = false
|
6 |
+
|
7 |
+
[theme]
|
8 |
+
base="light"
|
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title: Stats
|
3 |
-
emoji:
|
4 |
colorFrom: purple
|
5 |
colorTo: indigo
|
6 |
sdk: streamlit
|
@@ -10,4 +10,4 @@ pinned: false
|
|
10 |
short_description: MIST Statistics
|
11 |
---
|
12 |
|
13 |
-
|
|
|
1 |
---
|
2 |
+
title: MIST Stats
|
3 |
+
emoji:
|
4 |
colorFrom: purple
|
5 |
colorTo: indigo
|
6 |
sdk: streamlit
|
|
|
10 |
short_description: MIST Statistics
|
11 |
---
|
12 |
|
13 |
+
# MIST Statistics
|
app.py
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import altair as alt
|
4 |
+
import plotly.express as px
|
5 |
+
|
6 |
+
df = pd.read_csv('mist_stats.csv')
|
7 |
+
|
8 |
+
st.header("Misinformation Susceptibility Test Statistics")
|
9 |
+
st.subheader("Explore misinformation susceptibility profiles across 24 countries!")
|
10 |
+
|
11 |
+
st.markdown("Data from yourmist.streamlit.app between June 19, 2023, and July 10, 2024, from individuals who completed the MIST and chose to share their score and all sociodemographic data with the researchers. Only countries with more than 250 complete submissions at the time of data collection are included.")
|
12 |
+
|
13 |
+
countries = ["All countries"] + list(df["Country"].unique())
|
14 |
+
|
15 |
+
selected_country = st.selectbox("Select a country (or All countries):", countries)
|
16 |
+
|
17 |
+
categorical_vars = ['Generation', 'Education', 'Political Leaning', 'Gender', 'Perceived Misinfo Discernment Ability']
|
18 |
+
selected_var = st.selectbox("Select a variable to visualize:", categorical_vars)
|
19 |
+
|
20 |
+
ordering_dict = {
|
21 |
+
'Gender': ["Male", "Female", "Non-binary/Third"],
|
22 |
+
'Generation': ["Generation Z", "Millennials", "Generation X", "Baby Boomers"] ,
|
23 |
+
'Education': ["High School or Less",
|
24 |
+
"Some University but no degree",
|
25 |
+
"University Bachelors Degree",
|
26 |
+
"Graduate or professional degree (e.g., MA, PhD, MD)"],
|
27 |
+
'Political Leaning': ["Extremely liberal",
|
28 |
+
"Liberal", "Slightly liberal", "Moderate",
|
29 |
+
"Slightly conservative", "Conservative", "Extremely conservative"],
|
30 |
+
'Perceived Misinfo Discernment Ability': [ "Very poor", "Poor", "Average", "Good", "Very good"]
|
31 |
+
}
|
32 |
+
|
33 |
+
df[selected_var] = pd.Categorical(df[selected_var], categories=ordering_dict[selected_var], ordered=True)
|
34 |
+
|
35 |
+
filtered_df = df if selected_country == "All countries" else df[df["Country"] == selected_country]
|
36 |
+
|
37 |
+
num_obs = filtered_df.shape[0]
|
38 |
+
mean_score = filtered_df['Score'].mean().round(2)
|
39 |
+
std_dev = filtered_df['Score'].std().round(2)
|
40 |
+
|
41 |
+
plot_df = filtered_df.groupby([selected_var]).agg(avg_score=('Score', 'mean')).reset_index()
|
42 |
+
plot_df['avg_score'] = plot_df['avg_score'].round(2)
|
43 |
+
plot_df = plot_df.sort_values(by=selected_var)
|
44 |
+
|
45 |
+
subtitle_text = f'In {selected_country} by {selected_var.capitalize()}. N={num_obs}, Mean={mean_score}, SD={std_dev}'
|
46 |
+
|
47 |
+
color_scale = alt.Scale(domain=ordering_dict[selected_var])
|
48 |
+
|
49 |
+
chart = alt.Chart(plot_df).mark_bar().encode(
|
50 |
+
x=alt.X('avg_score', title='Average MIST Score',scale=alt.Scale(domain=[0, 20])),
|
51 |
+
y=alt.Y(selected_var, title=selected_var, sort=ordering_dict[selected_var]),
|
52 |
+
color=alt.Color(selected_var, scale=color_scale, legend=None)
|
53 |
+
).properties(
|
54 |
+
width=800,
|
55 |
+
height=600,
|
56 |
+
title={
|
57 |
+
"text": f'Average Misinformation Susceptibility Test (MIST) Score',
|
58 |
+
"subtitle": subtitle_text,
|
59 |
+
"subtitleFontSize": 16,
|
60 |
+
"anchor": "start" ,
|
61 |
+
"limit": 1000,
|
62 |
+
}
|
63 |
+
)
|
64 |
+
|
65 |
+
st.altair_chart(chart)
|
66 |
+
|
67 |
+
filtered_df[selected_var] = pd.Categorical(filtered_df[selected_var],
|
68 |
+
categories=ordering_dict[selected_var],
|
69 |
+
ordered=True)
|
70 |
+
filtered_df = filtered_df.sort_values(by=selected_var)
|
71 |
+
|
72 |
+
histogram = alt.Chart(filtered_df).mark_bar().encode(
|
73 |
+
x=alt.X('Score:O', title='MIST Score', sort=list(range(1, 21)),axis=alt.Axis(labelAngle=0),
|
74 |
+
scale=alt.Scale(domain=list(range(0, 21)))),
|
75 |
+
y=alt.Y('count()', title='Count'),
|
76 |
+
color=alt.Color(selected_var, scale=color_scale, legend=alt.Legend(title=selected_var, orient="top-left", titleLimit=1000, labelLimit=500, columns=1,padding=10))
|
77 |
+
).properties(
|
78 |
+
width=800,
|
79 |
+
height=600,
|
80 |
+
title={
|
81 |
+
"text": f'Distribution of MIST Scores',
|
82 |
+
"subtitle": subtitle_text,
|
83 |
+
"subtitleFontSize": 16,
|
84 |
+
"anchor": "start" ,
|
85 |
+
"limit": 1500
|
86 |
+
}
|
87 |
+
)
|
88 |
+
|
89 |
+
st.altair_chart(histogram)
|
mist_stats.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|