pkiage commited on
Commit
9823ef6
1 Parent(s): ce47c0c

feat: enhance summary plots

Browse files

Box plot show data on point hover
Add distplot (histogram and violin plot)

Files changed (3) hide show
  1. src/app.py +13 -4
  2. src/data/utils.py +4 -1
  3. src/visualization/visualize.py +9 -11
src/app.py CHANGED
@@ -19,9 +19,17 @@ def main():
19
  sample_data_selected = st.selectbox(
20
  'Select sample data:', data_set_options)
21
 
22
- data = import_sample_data(sample_data_selected, data_set_options)
 
23
 
24
- display_input_data(data)
 
 
 
 
 
 
 
25
 
26
  st.title("Time Series Autocorrelation")
27
 
@@ -81,8 +89,9 @@ def main():
81
 
82
  st.header("Partial Auto-Correlation Function (PACF)")
83
 
84
- st.write("""Unlike ACF, PACF controls for other lags.\n
85
- PACF represents how significant adding lag n is when you already have lag n-1.""")
 
86
 
87
  pacf_type = st.radio(
88
  'Default PACF:', ('True', 'False'), key='pacf_type')
 
19
  sample_data_selected = st.selectbox(
20
  'Select sample data:', data_set_options)
21
 
22
+ data, graph_data = import_sample_data(
23
+ sample_data_selected, data_set_options)
24
 
25
+ with st.expander("Line Plot:"):
26
+ time_series_line_plot(data)
27
+
28
+ with st.expander("Box Plot:"):
29
+ time_series_box_plot(graph_data)
30
+
31
+ with st.expander("Dist Plot (histogram and violin plot):"):
32
+ time_series_violin_and_box_plot(data)
33
 
34
  st.title("Time Series Autocorrelation")
35
 
 
89
 
90
  st.header("Partial Auto-Correlation Function (PACF)")
91
 
92
+ st.write("Unlike ACF, PACF controls for other lags.")
93
+ st.write(
94
+ "PACF represents how significant adding lag n is when you already have lag n-1.")
95
 
96
  pacf_type = st.radio(
97
  'Default PACF:', ('True', 'False'), key='pacf_type')
src/data/utils.py CHANGED
@@ -21,4 +21,7 @@ def import_sample_data(sample_data_selected, data_set_options):
21
  dta.index = pd.Index(sm.tsa.datetools.dates_from_range('1700', '2008'))
22
  del dta["YEAR"]
23
  data = dta
24
- return data
 
 
 
 
21
  dta.index = pd.Index(sm.tsa.datetools.dates_from_range('1700', '2008'))
22
  del dta["YEAR"]
23
  data = dta
24
+
25
+ graph_data = data.reset_index()
26
+ graph_data.columns.values[0] = 'Date'
27
+ return data, graph_data
src/visualization/visualize.py CHANGED
@@ -49,7 +49,13 @@ def time_series_scatter_plot(data):
49
 
50
 
51
  def time_series_box_plot(data):
52
- fig = px.box(data, points="all")
 
 
 
 
 
 
53
  st.plotly_chart(fig, use_container_width=True)
54
 
55
 
@@ -59,6 +65,8 @@ def streamlit_chart_setting_height_width(
59
  default_heightvalue: int,
60
  widthkey: str,
61
  heightkey: str,
 
 
62
  ):
63
  with st.expander(title):
64
 
@@ -109,16 +117,6 @@ def streamlit_autocorrelation_plot_settings():
109
  zero_include_selected]
110
 
111
 
112
- def display_input_data(data):
113
- show_inputted_dataframe(data)
114
-
115
- with st.expander("Box plot"):
116
- time_series_box_plot(data)
117
-
118
- with st.expander("Line Plot"):
119
- time_series_line_plot(data)
120
-
121
-
122
  def streamlit_acf_plot_settings():
123
  fft_compute_selected = st.radio(
124
  label="Compute the ACF via FFT:",
 
49
 
50
 
51
  def time_series_box_plot(data):
52
+ fig = px.box(data, hover_data=['Date'], points="all")
53
+ st.plotly_chart(fig, use_container_width=True)
54
+
55
+
56
+ def time_series_violin_and_box_plot(graph_data):
57
+ fig = px.histogram(graph_data,
58
+ marginal="violin")
59
  st.plotly_chart(fig, use_container_width=True)
60
 
61
 
 
65
  default_heightvalue: int,
66
  widthkey: str,
67
  heightkey: str,
68
+
69
+
70
  ):
71
  with st.expander(title):
72
 
 
117
  zero_include_selected]
118
 
119
 
 
 
 
 
 
 
 
 
 
 
120
  def streamlit_acf_plot_settings():
121
  fft_compute_selected = st.radio(
122
  label="Compute the ACF via FFT:",