DOMMETI commited on
Commit
33249e4
Β·
verified Β·
1 Parent(s): eac9b92

Update pages/Measurement_of_disperssion.py

Browse files
Files changed (1) hide show
  1. pages/Measurement_of_disperssion.py +165 -204
pages/Measurement_of_disperssion.py CHANGED
@@ -1,206 +1,167 @@
1
  import streamlit as st
2
- import math
3
- from functools import reduce
4
  import numpy as np
5
- st.subheader("Measure Of Disperssion ",divider=True)
6
- st.markdown("""Measure Of Disperssion will give spread of our collected data around the central value.It's classifed into two types
7
- """)
8
- st.markdown(''':violet[Absolute Measure] \n absolute will give the spread of data in one unit.for example if the given data is in 'cm'
9
- the output will be in cm''')
10
- st.markdown(''':violet[Relative Measure] \n Relative will be free from unit's''')
11
- st.header("**Absolute Measure**")
12
- st.subheader("Range",divider=True)
13
- st.subheader("Quartile Deviation",divider=True)
14
- st.subheader("Varience",divider=True)
15
- st.subheader("Standard Deviation",divider=True)
16
- st.header("**Relative Measure**")
17
- st.subheader("Coefficent Of Range",divider=True)
18
- st.subheader("Coefficent Of Quartile Deviation",divider=True)
19
- st.subheader("Coefficent Of Varience",divider=True)
20
- st.subheader("Coefficent Of Standard Deviation",divider=True)
21
- st.markdown(''':orange[**Range**] is one of the measure to find the disperssion.But is not at all mostly used beause it don't focus on the entire data.
22
- ''')
23
- st.subheader("Absolute Range")
24
- st.latex(r'''
25
- \text{Absolute Range} = \text{Maximum Value} - \text{Minimum Value}
26
- ''')
27
- st.subheader("Relative Range")
28
- st.latex(r'''
29
- \text{Relative Range} = \frac{\text{Absolute Range}}{\text{Mean}} \times 100
30
- ''')
31
- def absolute_range(list1):
32
- max_val = np.max(list1)
33
- min_val = np.min(list1)
34
- return max_val - min_val
35
- st.title("Calculate Absolute Range")
36
- num_input = st.text_input("Enter the values separated by commas (e.g., 1,2,3,4)", key="num_input")
37
- list1 = []
38
- value = num_input.split(",")
39
- for i in value:
40
- if i.isdigit():
41
- list1.append(int(i))
42
- if list1:
43
- result = absolute_range(list1)
44
- st.write("Absolute Range:", result)
45
- else:
46
- st.write("Please enter valid numbers.")
47
- def relative_range(list1):
48
- max=np.max(list1)
49
- min=np.min(list1)
50
- return round((max-min)/(max+min)*100,2)
51
- st.title("Calculate Relative Range")
52
- num_input1=st.text_input("Enter the values separated by commas (e.g., 1,2,3,4)", key="num_input1")
53
- value=num_input1.split(",")
54
- list1=[]
55
- for i in value:
56
- if i.isdigit():
57
- list1.append(int(i))
58
- else:
59
- pass
60
- if list1:
61
- result=relative_range(list1)
62
- st.write("Relative Range",result)
63
- else:
64
- st.write("Please enter valid numbers.")
65
- st.markdown(''':orange[**Quartile Deviation**] is one of the measure to find the disperssion.In this type the data is divided into 4 equal parts.
66
- It will mostly focus on the central data.
67
- ''')
68
- st.subheader("Absolute Quartile Deviation")
69
- st.latex(r'''
70
- QD = \frac{Q3 - Q1}{2}
71
- ''')
72
- st.subheader("Relative Quartile Deviation")
73
- st.latex(r'''
74
- \text{Relative QD} = \frac{Q3 - Q1}{Q3 + Q1} \times 100
75
- ''')
76
- def abs_quartile_dev(list1):
77
- q1=np.percentile(list1,25)
78
- q3=np.percentile(list1,75)
79
- return round((q3-q1)/2,2)
80
- st.title("Caluculate Absolute Quartile Deviation")
81
- num_input2=st.text_input("Enter the values separated by commas (e.g., 1,2,3,4)", key="num_input2")
82
- value=num_input2.split(",")
83
- list1=[]
84
- for i in value:
85
- if i.isdigit():
86
- list1.append(int(i))
87
- else:
88
- pass
89
- if list1:
90
- result=abs_quartile_dev(list1)
91
- st.write("Absolute Quartile Deviation",result)
92
- else:
93
- st.write("Please enter valid numbers.")
94
- def rel_quartile_dev(list1):
95
- q1=np.percentile(list1,25)
96
- q3=np.percentile(list1,75)
97
- return round(((q3-q1)/(q3+q1))*100,2)
98
- st.title("Caluculate Relative Quartile Deviation")
99
- num_input3=st.text_input("Enter the values separated by commas (e.g., 1,2,3,4)", key="num_input3")
100
- value=num_input3.split(",")
101
- list1=[]
102
- for i in value:
103
- if i.isdigit():
104
- list1.append(int(i))
105
- else:
106
- pass
107
- if list1:
108
- result=rel_quartile_dev(list1)
109
- st.write("Relative Quartile Deviation",result)
110
- else:
111
- st.write("Please enter valid numbers.")
112
- st.markdown(''':orange[**Varience**] is one of the measure to find the disperssion.It is one of the best measure to find the disperssion.The only
113
- drawback is when in Varience is in order to overcome negitive value we square them thus the distance is doubled
114
- ''')
115
- st.subheader("Absolute Variance")
116
- st.latex(r'''
117
- \text{Var} = \frac{1}{N} \sum_{i=1}^{N} (x_i - \bar{x})^2
118
- ''')
119
- st.subheader("Relative Variance")
120
- st.latex(r'''
121
- \text{Relative Var} = \frac{\text{Var}}{\bar{x}} \times 100
122
- ''')
123
- def absolute_varience(list1):
124
- return np.var(list1)
125
- st.title("Caluculate Absolute varience")
126
- num_input4=st.text_input("Enter the values separated by commas (e.g., 1,2,3,4)", key="num_input4")
127
- value=num_input4.split(",")
128
- list1=[]
129
- for i in value:
130
- if i.isdigit():
131
- list1.append(int(i))
132
- else:
133
- pass
134
- if list1:
135
- result=absolute_varience(list1)
136
- st.write("Absolute Varience",result)
137
- else:
138
- st.write("Please enter valid numbers.")
139
- def relative_varience(list1):
140
- mean=round(np.mean(list1),2)
141
- std_dev=np.std(list1,ddof=1)
142
- return round((std_dev/mean)*100,2)
143
- st.title("Caluculate Relative Varience")
144
- num_input5=st.text_input("Enter the values separated by commas (e.g., 1,2,3,4)", key="num_input5")
145
- value=num_input5.split(",")
146
- list1=[]
147
- for i in value:
148
- if i.isdigit():
149
- list1.append(int(i))
150
- else:
151
- pass
152
- if list1:
153
- result=relative_varience(list1)
154
- st.write("Relative Varience",result)
155
- else:
156
- st.write("Please enter valid numbers.")
157
- st.markdown(''':orange[**Standard Deviation**] is one of the measure to find the disperssion.It is one of the best measure to find the disperssion.It over comes the
158
- disadvantage occured in varience by square rooting it.
159
- ''')
160
- st.subheader("Absolute Standard Deviation")
161
- st.latex(r'''
162
- \sigma = \sqrt{\frac{1}{N} \sum_{i=1}^{N} (x_i - \bar{x})^2}
163
- ''')
164
- st.subheader("Relative Standard Deviation")
165
- st.latex(r'''
166
- \text{Relative SD} = \frac{\sigma}{\bar{x}}
167
- ''')
168
- def absolute_std(list1):
169
- return round(np.std(list1),2)
170
- st.title("Caluculate Absolute Standard Deviation")
171
- num_input6=st.text_input("Enter the values separated by commas (e.g., 1,2,3,4)", key="num_input6")
172
- value=num_input6.split(",")
173
- list1=[]
174
- for i in value:
175
- if i.isdigit():
176
- list1.append(int(i))
177
- else:
178
- pass
179
- if list1:
180
- result=absolute_std(list1)
181
- st.write("Absolute Standard Deviation",result)
182
- else:
183
- st.write("Please enter valid numbers.")
184
- def relative_std(list1):
185
- mean=round(np.mean(list1),2)
186
- std_dev=np.std(list1,ddof=1)
187
- return round((std_dev/mean),2)
188
- st.title("Caluculate Relative Standard Deviation")
189
- num_input7=st.text_input("Enter the values separated by commas (e.g., 1,2,3,4)", key="num_input7")
190
- value=num_input7.split(",")
191
- list1=[]
192
- for i in value:
193
- if i.isdigit():
194
- list1.append(int(i))
195
- else:
196
- pass
197
- if list1:
198
- result=relative_std(list1)
199
- st.write("Relative Standard Deviation",result)
200
- else:
201
- st.write("Please enter valid numbers.")
202
- st.subheader("Distribution",divider=True)
203
- st.markdown(''':blue[**Distribution**] is a measure will will tell how the shape of data or in which shape the data is spread.It will help in
204
- analysis.There are few types of distribution \n * Normal Distribution \n * Uniform Distribution \n * Binomial Distribution \n * Poisson Distribution
205
- \n * Exponential Distribution \n * Chi-Square Distribution \n * T-Distribution
206
- ''')
 
1
  import streamlit as st
2
+ import pandas as pd
 
3
  import numpy as np
4
+ import matplotlib.pyplot as plt
5
+ import random
6
+
7
+ # Custom CSS for styling
8
+ st.markdown("""
9
+ <style>
10
+ /* Set a soft background color */
11
+ body {
12
+ background-color: #eef2f7;
13
+ }
14
+ /* Style for main title */
15
+ h1 {
16
+ color: #00FFFF;
17
+ font-family: 'Roboto', sans-serif;
18
+ font-weight: 700;
19
+ text-align: center;
20
+ margin-bottom: 25px;
21
+ }
22
+ /* Style for headers */
23
+ h2 {
24
+ color: #FFFACD;
25
+ font-family: 'Roboto', sans-serif;
26
+ font-weight: 600;
27
+ margin-top: 30px;
28
+ }
29
+
30
+ /* Style for subheaders */
31
+ h3 {
32
+ color: #ba95b0;
33
+ font-family: 'Roboto', sans-serif;
34
+ font-weight: 500;
35
+ margin-top: 20px;
36
+ }
37
+ .custom-subheader {
38
+ color: #00FFFF;
39
+ font-family: 'Roboto', sans-serif;
40
+ font-weight: 600;
41
+ margin-bottom: 15px;
42
+ }
43
+ /* Paragraph styling */
44
+ p {
45
+ font-family: 'Georgia', serif;
46
+ line-height: 1.8;
47
+ color: #FFFFFF; /* Darker text color for better visibility */
48
+ margin-bottom: 20px;
49
+ }
50
+ /* List styling with checkmark bullets */
51
+ .icon-bullet {
52
+ list-style-type: none;
53
+ padding-left: 20px;
54
+ }
55
+ .icon-bullet li {
56
+ font-family: 'Georgia', serif;
57
+ font-size: 1.1em;
58
+ margin-bottom: 10px;
59
+ color: #FFFFF0; /* Darker text color for better visibility */
60
+ }
61
+ .icon-bullet li::before {
62
+ content: "βœ”οΈ";
63
+ padding-right: 10px;
64
+ color: #b3b3ff;
65
+ }
66
+ /* Sidebar styling */
67
+ .sidebar .sidebar-content {
68
+ background-color: #ffffff;
69
+ border-radius: 10px;
70
+ padding: 15px;
71
+ }
72
+ .sidebar h2 {
73
+ color: #495057;
74
+ }
75
+ </style>
76
+ """, unsafe_allow_html=True)
77
+
78
+ # Introduction section
79
+ st.markdown("""Before jumping into the context, let's understand some important words..! 🌟""", unsafe_allow_html=True)
80
+
81
+ st.header("Natural Intelligence 🧠")
82
+ st.markdown("""**Natural Intelligence** is the ability of living beings, like humans and animals, to think, learn, and solve problems using their brains or minds. 🐾""", unsafe_allow_html=True)
83
+
84
+ st.header("Artificial Intelligence πŸ€–")
85
+ st.markdown("""
86
+ The term 'Artificial' refers to **man-made**, and 'Intelligence' is the ability to learn, understand, and apply knowledge to solve problems. This can be simplified as **man-made intelligence**.
87
+ In this, machines try to **mimic/copy** natural intelligence. 🧠 ➑️ πŸ€–
88
+ """, unsafe_allow_html=True)
89
+
90
+ # Interactive section for choosing AI tools
91
+ st.markdown("""
92
+ To mimic/copy natural intelligence, we have 3 powerful tools:
93
+ <ul class="icon-bullet">
94
+ <li>πŸ–₯️ Machine Learning</li>
95
+ <li>🀿 Deep Learning</li>
96
+ <li>🎨 Generative AI</li>
97
+ </ul>
98
+ """, unsafe_allow_html=True)
99
+
100
+ # Let the user choose an AI tool to learn more about
101
+ tool = st.selectbox("Which AI tool would you like to learn more about?",
102
+ ["Machine Learning", "Deep Learning", "Generative AI"])
103
+
104
+ if tool == "Machine Learning":
105
+ st.subheader("Machine Learning πŸ–₯️")
106
+ st.markdown("""
107
+ Machine Learning is a tool that helps us mimic/copy natural intelligence 🧠 to create artificial intelligence πŸ€–.
108
+ It's like teaching machines how to learn from data and make decisions! πŸ“Š
109
+ """)
110
+ # Interactive chart for machine learning
111
+ data = np.random.randn(100)
112
+ st.line_chart(data)
113
+ st.markdown("Here is a simple data visualization related to Machine Learning. πŸ“Š")
114
+
115
+ elif tool == "Deep Learning":
116
+ st.subheader("Deep Learning 🀿")
117
+ st.markdown("""
118
+ Deep Learning is a powerful tool that mimics/copies natural intelligence 🧠 to create artificial intelligence πŸ€–.
119
+ It goes deeper by using neural networks to solve complex problems! 🌐
120
+ """)
121
+ # Interactive slider to simulate Deep Learning training
122
+ epochs = st.slider("Select the number of epochs (training cycles):", min_value=1, max_value=20, value=5)
123
+ st.markdown(f"Training for {epochs} epochs...")
124
+ # Simulate a training graph
125
+ training_data = np.linspace(0, epochs, epochs)
126
+ accuracy = np.random.rand(epochs)
127
+ st.line_chart(accuracy)
128
+ st.markdown("This is a simulated training accuracy plot.")
129
+
130
+ elif tool == "Generative AI":
131
+ st.subheader("Generative AI 🎨")
132
+ st.markdown("""
133
+ Generative AI refers to the ability of machines to create new, never-before-seen data.
134
+ It mimics the generative process of natural intelligence, but in a digital form! 🎨
135
+ """)
136
+ # Interactive input for generating text or art
137
+ user_input = st.text_input("Enter a prompt for Generative AI to create text:")
138
+ if user_input:
139
+ st.markdown(f"Generative AI is generating text for: {user_input}")
140
+ generated_text = f"This is a generated response to your input: {user_input}"
141
+ st.markdown(generated_text)
142
+ st.markdown("Imagine if this was a generated artwork instead! 🎨")
143
+
144
+ # Additional sections about AI and deep learning
145
+ st.subheader("Why ML? Why DL? Why Generative AI? πŸ€”")
146
+ st.markdown("""
147
+ Thanks to **natural intelligence**, we have two precious abilities:
148
+ <ul class="icon-bullet">
149
+ <li>πŸ“š Learn</li>
150
+ <li>✨ Generate</li>
151
+ </ul>
152
+ """, unsafe_allow_html=True)
153
+
154
+ st.subheader("Whenever machines want to adopt the learning ability 🧠")
155
+ st.markdown("""
156
+ <ul class="icon-bullet">
157
+ <li>πŸ–₯️ Machine Learning</li>
158
+ <li>🀿 Deep Learning</li>
159
+ </ul>
160
+ """, unsafe_allow_html=True)
161
+
162
+ st.subheader("Whenever machines want to adopt the generating ability ✨")
163
+ st.markdown("""
164
+ <ul class="icon-bullet">
165
+ <li>🎨 Generative AI</li>
166
+ </ul>
167
+ """, unsafe_allow_html=True)