-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstreamlit.py
99 lines (75 loc) · 1.95 KB
/
streamlit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# coding: utf-8
from pydoc import describe
import streamlit as st
from PIL import Image
import altair as alt
from app import sc
st.set_page_config(
page_title="Home",
page_icon="🏠",
)
st.image(Image.open(r'.streamlit/logo_citadel.png'))
st.markdown(
"""
CITADEL SUMMER SCHOOL 2022 -
THEME: ANALYSE DE LA SITUATION SECURITAURE DU BURKINA FASO AVEC L'IA
"""
)
# sidebar
st.sidebar.header('Features')
feature = st.sidebar.selectbox(
'select feature',
['describe dataset', 'show dataset distribution', 'explore dataset']
)
def description():
st.markdown(
"""
#### Description
"""
)
describe = list(sc.describe_dataset().items())
col1, col2, col3 = st.columns(3)
col1.metric(describe[0][0], describe[0][1])
col2.metric(describe[1][0], describe[1][1])
col3.metric(describe[2][0], describe[2][1])
col1, col2, col3 = st.columns(3)
col1.metric(describe[3][0], describe[3][1])
col2.metric(describe[4][0], describe[4][1])
col3.metric(describe[5][0], describe[5][1])
def comments_distribution():
st.markdown(
"""
#### Distribution des commentaires par article
"""
)
# distrubtion
source = sc.get_dataset()['comments_number']
st.bar_chart(source)
def explore_dataset():
# show json
st.markdown(
"""
#### Visualisation contenu
"""
)
samples = sc.get_samples()
articles = {}
i = 0
for sample in samples:
i = i + 1
title = sample['article_title']
key = f'{i} - {title}'
value = sample
articles[key] = value
article_select = st.selectbox(
'choisir un article',
list(articles.keys())
)
st.json(articles.get(article_select))
#### RUN
call = {
'describe dataset': description,
'show dataset distribution': comments_distribution,
'explore dataset': explore_dataset,
}
call.get(feature)()