towardsinnovationlab commited on
Commit
1a3d435
·
verified ·
1 Parent(s): b06ea1d

Update pages/3_Summary_Statistics.py

Browse files
Files changed (1) hide show
  1. pages/3_Summary_Statistics.py +109 -109
pages/3_Summary_Statistics.py CHANGED
@@ -1,109 +1,109 @@
1
- import numpy as np
2
- import pandas as pd
3
- import streamlit as st
4
-
5
-
6
- import warnings
7
- warnings.simplefilter(action='ignore', category=UserWarning)
8
- warnings.simplefilter(action='ignore', category=FutureWarning)
9
-
10
-
11
- import numpy as np
12
- import pandas as pd
13
- import streamlit as st
14
-
15
- import warnings
16
- warnings.simplefilter(action='ignore', category=UserWarning)
17
- warnings.simplefilter(action='ignore', category=FutureWarning)
18
-
19
- # Load datasets
20
- df1 = pd.read_csv('../dataset/ausprivauto0405.csv')
21
- df2 = pd.read_csv('../dataset/swmotorcycle.csv')
22
-
23
- st.title("Summary Statistics")
24
-
25
- # ---------------------- DATASET 1 ------------------------
26
- st.header("Dataset 1: ausprivauto0405")
27
-
28
- if st.checkbox("Show raw data (Dataset 1)"):
29
- st.subheader("Raw Data")
30
- st.write(df1)
31
-
32
- if st.checkbox("Show summary statistics (Dataset 1)"):
33
- st.subheader('Categorical Variables')
34
- obj_cols = df1.select_dtypes(include='object')
35
- st.write(obj_cols.describe().T)
36
-
37
- st.subheader('Numerical Variables')
38
- num_cols = df1.select_dtypes(exclude='object')
39
- st.write(num_cols.describe().T)
40
-
41
- st.markdown("""
42
- ## ausprivauto0405
43
- is a data frame of 9 columns and 67,856 rows:
44
-
45
- -Exposure: The number of policy years.
46
-
47
- -VehValue: The vehicle value in thousand of AUD.
48
-
49
- -VehAge: The vehicle age group.
50
-
51
- -VehBody: The vehicle body group.
52
-
53
- -Gender: The gender of the policyholder.
54
-
55
- -DrivAge: The age of the policyholder.
56
-
57
- -ClaimOcc: Indicates occurence of a claim.
58
-
59
- -ClaimNb: The number of claims.
60
-
61
- -ClaimAmount: The sum of claim payments.
62
- """)
63
-
64
-
65
- # ---------------------- DATASET 2 ------------------------
66
- st.header("Dataset 2: swmotorcycle")
67
-
68
- if st.checkbox("Show raw data (Dataset 2)"):
69
- st.subheader("Raw Data")
70
- st.write(df2)
71
-
72
- if st.checkbox("Show summary statistics (Dataset 2)"):
73
- st.subheader('Categorical Variables')
74
- obj_cols2 = df2.select_dtypes(include='object')
75
- st.write(obj_cols2.describe().T)
76
-
77
- st.subheader('Numerical Variables')
78
- num_cols2 = df2.select_dtypes(exclude='object')
79
- st.write(num_cols2.describe().T)
80
-
81
-
82
- st.markdown("""
83
- ## swmotorcycle
84
- is a data frame of 9 columns and 64,548 rows:
85
-
86
- -OwnerAge: The owner age.
87
-
88
- -Gender: The gender.
89
-
90
- -Area: The type of area.
91
-
92
- -RiskClass: The motorcycle class, a classification by the so called EV ratio, defined as (Engine
93
- power in kW x 100) / (Vehicle weight in kg + 75), rounded to the nearest lower integer. The
94
- 75 kg represent the average driver weight. The EV ratios are divided into seven classes.
95
-
96
- -VehAge: The Vehicle age, between 0 and 99.
97
-
98
- -BonusClass: The bonusclass, taking values from 1 to 7. A new driver starts with bonus class 1;
99
- for each claim-free year the bonus class is increased by 1. After the first claim the bonus is
100
- decreased by 2; the driver can not return to class 7 with less than 6 consecutive claim free
101
- years.
102
-
103
- -Exposure: The number of policy years.
104
-
105
- -ClaimNb: The number of claims.
106
-
107
- -ClaimAmount: The sum of claim payments.
108
- """)
109
-
 
1
+ import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
+
6
+ import warnings
7
+ warnings.simplefilter(action='ignore', category=UserWarning)
8
+ warnings.simplefilter(action='ignore', category=FutureWarning)
9
+
10
+
11
+ import numpy as np
12
+ import pandas as pd
13
+ import streamlit as st
14
+
15
+ import warnings
16
+ warnings.simplefilter(action='ignore', category=UserWarning)
17
+ warnings.simplefilter(action='ignore', category=FutureWarning)
18
+
19
+ # Load datasets
20
+ df1 = pd.read_csv('./data/ausprivauto0405.csv')
21
+ df2 = pd.read_csv('./data/swmotorcycle.csv')
22
+
23
+ st.title("Summary Statistics")
24
+
25
+ # ---------------------- DATASET 1 ------------------------
26
+ st.header("Dataset 1: ausprivauto0405")
27
+
28
+ if st.checkbox("Show raw data (Dataset 1)"):
29
+ st.subheader("Raw Data")
30
+ st.write(df1)
31
+
32
+ if st.checkbox("Show summary statistics (Dataset 1)"):
33
+ st.subheader('Categorical Variables')
34
+ obj_cols = df1.select_dtypes(include='object')
35
+ st.write(obj_cols.describe().T)
36
+
37
+ st.subheader('Numerical Variables')
38
+ num_cols = df1.select_dtypes(exclude='object')
39
+ st.write(num_cols.describe().T)
40
+
41
+ st.markdown("""
42
+ ## ausprivauto0405
43
+ is a data frame of 9 columns and 67,856 rows:
44
+
45
+ -Exposure: The number of policy years.
46
+
47
+ -VehValue: The vehicle value in thousand of AUD.
48
+
49
+ -VehAge: The vehicle age group.
50
+
51
+ -VehBody: The vehicle body group.
52
+
53
+ -Gender: The gender of the policyholder.
54
+
55
+ -DrivAge: The age of the policyholder.
56
+
57
+ -ClaimOcc: Indicates occurence of a claim.
58
+
59
+ -ClaimNb: The number of claims.
60
+
61
+ -ClaimAmount: The sum of claim payments.
62
+ """)
63
+
64
+
65
+ # ---------------------- DATASET 2 ------------------------
66
+ st.header("Dataset 2: swmotorcycle")
67
+
68
+ if st.checkbox("Show raw data (Dataset 2)"):
69
+ st.subheader("Raw Data")
70
+ st.write(df2)
71
+
72
+ if st.checkbox("Show summary statistics (Dataset 2)"):
73
+ st.subheader('Categorical Variables')
74
+ obj_cols2 = df2.select_dtypes(include='object')
75
+ st.write(obj_cols2.describe().T)
76
+
77
+ st.subheader('Numerical Variables')
78
+ num_cols2 = df2.select_dtypes(exclude='object')
79
+ st.write(num_cols2.describe().T)
80
+
81
+
82
+ st.markdown("""
83
+ ## swmotorcycle
84
+ is a data frame of 9 columns and 64,548 rows:
85
+
86
+ -OwnerAge: The owner age.
87
+
88
+ -Gender: The gender.
89
+
90
+ -Area: The type of area.
91
+
92
+ -RiskClass: The motorcycle class, a classification by the so called EV ratio, defined as (Engine
93
+ power in kW x 100) / (Vehicle weight in kg + 75), rounded to the nearest lower integer. The
94
+ 75 kg represent the average driver weight. The EV ratios are divided into seven classes.
95
+
96
+ -VehAge: The Vehicle age, between 0 and 99.
97
+
98
+ -BonusClass: The bonusclass, taking values from 1 to 7. A new driver starts with bonus class 1;
99
+ for each claim-free year the bonus class is increased by 1. After the first claim the bonus is
100
+ decreased by 2; the driver can not return to class 7 with less than 6 consecutive claim free
101
+ years.
102
+
103
+ -Exposure: The number of policy years.
104
+
105
+ -ClaimNb: The number of claims.
106
+
107
+ -ClaimAmount: The sum of claim payments.
108
+ """)
109
+