Spaces:
Build error
Build error
File size: 9,821 Bytes
e9a9656 c866f3f 147ecf0 e9a9656 3b50463 e9a9656 70fe654 c4d8a93 4cf2fc4 c33c88e 4cf2fc4 e34a4d3 39eb3a0 e34a4d3 11280d3 5ee5985 16cec68 5ee5985 16cec68 5ee5985 16cec68 | 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | import streamlit as st
import pandas as pd
import numpy as np
from functools import reduce
st.markdown("""
<style>
/* Set a soft background color */
body {
background-color: #eef2f7;
}
/* Style for main title */
h1 {
color: #00FFFF;
font-family: 'Roboto', sans-serif;
font-weight: 700;
text-align: center;
margin-bottom: 25px;
}
/* Style for headers */
h2 {
color: #FFFACD;
font-family: 'Roboto', sans-serif;
font-weight: 600;
margin-top: 30px;
}
/* Style for subheaders */
h3 {
color: #ba95b0;
font-family: 'Roboto', sans-serif;
font-weight: 500;
margin-top: 20px;
}
.custom-subheader {
color: #00FFFF;
font-family: 'Roboto', sans-serif;
font-weight: 600;
margin-bottom: 15px;
}
/* Paragraph styling */
p {
font-family: 'Georgia', serif;
line-height: 1.8;
color: #FFFFFF; /* Darker text color for better visibility */
margin-bottom: 20px;
}
/* List styling with checkmark bullets */
.icon-bullet {
list-style-type: none;
padding-left: 20px;
}
.icon-bullet li {
font-family: 'Georgia', serif;
font-size: 1.1em;
margin-bottom: 10px;
color: #FFFFF0; /* Darker text color for better visibility */
}
.icon-bullet li::before {
content: "✔️";
padding-right: 10px;
color: #17a2b8;
}
/* Sidebar styling */
.sidebar .sidebar-content {
background-color: #ffffff;
border-radius: 10px;
padding: 15px;
}
.sidebar h2 {
color: #495057;
}
/* Mobile specific styles */
@media only screen and (max-width: 600px) {
.stApp {
background-color: #070109;
}
h1, h2 {
font-size: 18px; /* Adjust font size for mobile devices */
}
}
</style>
""", unsafe_allow_html=True)
st.title("Measure Of Central Tendency")
st.markdown("""The measure of central tendency is used to find the central average value of the data.The central tendency can be computed by
useing three ways
<ul class=icon-bullet>
<li> Mode </li>
<li> Median </li>
<li> Mean </li>
</ul>
""",unsafe_allow_html=True)
st.subheader("MODE")
st.markdown("""Mode will be giving the centeral tendency based on most frequently occuring data.The major drawback of mode is its frequecy baised it
mostly focus on the data which is occuring most times.Here in this mode we might come across some situation's like """,unsafe_allow_html=True)
st.markdown(''':violet[No_Mode] \n Let's understand why this situation raises for example let's take list of numbers [1,2,3,4,5] here we don't have
frequency of numbers repeating in this senario we will come accross No_Mode situaton.
''',unsafe_allow_html=True)
st.markdown(''':violet[Uni_Mode] \n Let's understand why this situation raises for example let's take list of numbers [1,1,1,2,3,4,5]. here by
checking the list it will tend to know that the frequency of number 1 is more and it returns the value 1 as output.
''',unsafe_allow_html=True)
st.markdown(''':violet[Bi_Mode] \n Let's understand why this situation raises for example let's take list of numbers [1,1,2,2,3,4,5]. here by
checking the frequency in list we come across a situtaion where we will find two maximun frequecy repeated value hence the output will be Bi_Mode.
''',unsafe_allow_html=True)
st.markdown(''':violet[Tri_Mode] \n Let's understand why this situation raises for example let's take list of numbers [1,1,2,2,3,3,4,5]. here by
checking the frequency in list we come across a situtaion where we will find three maximun frequecy repeated value hence the output will be Tri_Mode.
''',unsafe_allow_html=True)
st.markdown(''':violet[Multi_Mode] \n Let's understand why this situation raises for example let's take list of numbers [1,1,2,2,3,3,4,4,5]. here by
checking the frequency in list we come across a situtaion where we will find more than three maximun frequecy repeated value hence the output will be Multi_Mode.
''',unsafe_allow_html=True)
st.title("Calculate Mode")
def mode(*args):
list1 = list(args)
dict1 = {}
dict2 = {}
set1 = set(list1)
for j in set1:
dict1[j] = list1.count(j)
max_value = max(dict1.values())
count = [key for key, value in dict1.items() if value == max_value]
if max_value == 1:
return 'no mode'
elif len(count) == len(set1):
return 'no mode'
elif len(count) == 1:
dict2[count[0]] = dict1.get(count[0])
return dict2
elif len(count) == 2:
return 'bi mode'
elif len(count) == 3:
return 'tri mode'
else:
return 'multimode'
numbers_input = st.text_input("Enter a list of numbers separated by commas (e.g., 1, 2, 2, 3, 4):")
if numbers_input:
try:
list1 = list(map(int, numbers_input.split(',')))
result = mode(*list1)
st.write("Mode result:", result)
except ValueError:
st.write("Please enter a valid list of numbers separated by commas.")
st.subheader("Median")
st.markdown("""Median will also be giving the central tendency.But the major drawback of median is it prior foucus will be on the central value.
In order to find the mean first we have to sort the give list and based on the length of the list the formula are changed""",unsafe_allow_html=True)
st.subheader("Median Formula for Odd Number of Observations")
st.latex(r'''
\text{Median} = X_{\left(\frac{n+1}{2}\right)}
''')
st.subheader("Median Formula for Even Number of Observations")
st.latex(r'''
\text{Median} = \frac{X_{\left(\frac{n}{2}\right)} + X_{\left(\frac{n}{2}+1\right)}}{2}
''')
def median(numbers):
numbers.sort()
length = len(numbers)
if length % 2 == 0:
mid1 = length // 2 - 1
mid2 = length // 2
return (numbers[mid1] + numbers[mid2]) / 2
else:
mid = length // 2
return numbers[mid]
st.title("Calculate Median")
range_values = st.slider('Select a range of values', 0, 100, (25, 75))
numbers_input = list(range(range_values[0], range_values[1] + 1))
if numbers_input:
result = median(numbers_input)
st.write("Median result:", result)
else:
st.write("No valid numbers provided.")
st.subheader("Mean")
st.markdown("""
Mean is one of the beautiful measurement of central tendency it invovles all the data present in it.The only drawback of mean is it is
effected by outliers.Based on the data we will compute the mean in three types""",unsafe_allow_html=True)
st.subheader("Arthmetic Mean")
st.markdown("""Arthmetic Mean is used on data which have
<ul class=icon-bullet>
<li>Interval and Ratio Data </li>
<li>Symmetric Distributions </li>
<li>Data Without Outliers</li>
</ul>
""",unsafe_allow_html=True)
st.subheader("Arthmetic Mean for Population")
st.latex(r'''
\mu = \frac{1}{N} \sum_{i=1}^{N} x_i
''')
st.subheader("Arthmetic Mean for Sample")
st.latex(r'''
\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i
''')
def arthamatic_mean(list1):
sum=reduce(lambda x,y: x+y,list1)
return sum/len(list1)
st.title("Calculate Arthmetic_Mean")
numbers_input_2 = st.text_input("Enter a list of numbers separated by commas (e.g., 1, 2, 3, 4, 5):", key="numbers_input_2")
if numbers_input_2:
parts=numbers_input_2.split(",")
list1=[]
for i in parts:
i = i.strip()
if i.isdigit():
list1.append(int(i))
if list1:
result=arthamatic_mean(list1)
st.write("Arthmetic_Mean",result)
else:
st.write("No valid numbers provided.")
st.subheader("Geometric Mean")
st.markdown("""Geometric Mean is used on data which have
<ul class=icon-bullet>
<li>Multiplicative Data</li>
<li>Percentages and Rates</li>
<li>Normalized Data</li>
</ul>
""",unsafe_allow_html=True)
st.subheader("Geometric Mean for Population")
st.latex(r'''
\text{GM}_{\text{population}} = \left( \prod_{i=1}^{N} x_i \right)^{\frac{1}{N}}
''')
st.subheader("Geometric Mean for Sample")
st.latex(r'''
\text{GM}_{\text{sample}} = \left( \prod_{i=1}^{n} x_i \right)^{\frac{1}{n}}
''')
def geometric_mean(list1):
mul=reduce(lambda x,y: x*y,list1)
return round(mul**(1/len(list1)),2)
st.title("Calculate Geometric_Mean")
numbers_input_3 = st.text_input("Enter a list of numbers separated by commas (e.g., 1, 2, 3, 4, 5):", key="numbers_input_3")
if numbers_input_3:
parts=numbers_input_3.split(",")
list1=[]
for i in parts:
i = i.strip()
if i.isdigit():
list1.append(int(i))
if list1:
result=geometric_mean(list1)
st.write("Geometric_Mean",result)
else:
st.write("No valid numbers provided.")
st.subheader("Harmonic Mean")
st.markdown("""Harmonic Mean is used on data which have
<ul class=icon-bullet>
<li>Rates and Ratios</li>
<li>Data with Reciprocal Relationships</li>
</ul>
""",unsafe_allow_html=True)
st.subheader("Harmonic Mean for Population")
st.latex(r'''
\text{HM}_{\text{population}} = \frac{N}{\sum_{i=1}^{N} \frac{1}{x_i}}
''')
st.subheader("Harmonic Mean for Sample")
st.latex(r'''
\text{HM}_{\text{sample}} = \frac{n}{\sum_{i=1}^{n} \frac{1}{x_i}}
''')
def harmonic_mean(list1):
sum=reduce(lambda x,y: x+1/y,list1)
return round(len(list1)/sum,2)
st.title("Calculate Harmonic_Mean")
numbers_input_4 = st.text_input("Enter a list of numbers separated by commas (e.g., 1, 2, 3, 4, 5):", key="numbers_input_4")
if numbers_input_4:
parts=numbers_input_4.split(",")
list1=[]
for i in parts:
i = i.strip()
if i.isdigit():
list1.append(int(i))
if list1:
result=harmonic_mean(list1)
st.write("Geometric_Mean",result)
else:
st.write("No valid numbers provided.")
|