Spaces:
Sleeping
Sleeping
Commit
·
cf6b007
1
Parent(s):
155f68c
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,71 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
| 4 |
-
from scipy.stats import shapiro
|
|
|
|
| 5 |
import numpy as np
|
| 6 |
import matplotlib.pyplot as plt
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
col_name = str(col_name)
|
| 10 |
st.divider()
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
st.divider()
|
| 13 |
|
| 14 |
-
if
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
stat, p_val = shapiro(data)
|
| 21 |
|
| 22 |
-
if
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
|
|
|
|
|
|
| 27 |
st.divider()
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
| 4 |
+
from scipy.stats import shapiro, kstest
|
| 5 |
+
from scipy import stats
|
| 6 |
import numpy as np
|
| 7 |
import matplotlib.pyplot as plt
|
| 8 |
+
from io import StringIO
|
| 9 |
|
| 10 |
+
st.title("Distribution Predictor")
|
|
|
|
| 11 |
st.divider()
|
| 12 |
+
st.subheader("Select the type of file needed to be Uploaded: ")
|
| 13 |
+
f_format = st.radio(
|
| 14 |
+
"Select the data format",
|
| 15 |
+
['.csv', '.txt'],
|
| 16 |
+
index=None
|
| 17 |
+
)
|
| 18 |
st.divider()
|
| 19 |
|
| 20 |
+
if f_format == '.csv':
|
| 21 |
+
col_name = st.text_input('Column to get')
|
| 22 |
+
col_name = str(col_name)
|
| 23 |
+
st.divider()
|
| 24 |
+
upload_file = st.file_uploader("Upload File")
|
| 25 |
+
st.divider()
|
|
|
|
| 26 |
|
| 27 |
+
if upload_file is not None:
|
| 28 |
+
df = pd.read_csv(upload_file)
|
| 29 |
+
data = np.array(df[col_name])
|
| 30 |
+
fig, ax = plt.subplots()
|
| 31 |
+
ax.hist(data, bins=100, density=True)
|
| 32 |
+
stat_n, p_val_n = shapiro(data)
|
| 33 |
+
stat_p, p_val_p = kstest(data, 'poisson', (5, 0))
|
| 34 |
+
|
| 35 |
+
st.divider()
|
| 36 |
+
if p_val_n > 0.1:
|
| 37 |
+
st.write("Data follows Normal Distribution")
|
| 38 |
+
else:
|
| 39 |
+
st.write("Data does not follow Normal Distribution")
|
| 40 |
+
|
| 41 |
+
st.pyplot(fig)
|
| 42 |
|
| 43 |
+
elif f_format == '.txt':
|
| 44 |
+
upload_file = st.file_uploader("Upload File")
|
| 45 |
st.divider()
|
| 46 |
+
if upload_file is not None:
|
| 47 |
+
stringio = StringIO(upload_file.getvalue().decode("utf-8"))
|
| 48 |
+
stringio = stringio.getvalue()
|
| 49 |
+
data = stringio.split(',')
|
| 50 |
+
data_f = []
|
| 51 |
+
for i in range(len(data) -1):
|
| 52 |
+
data_f.append(float(data[i]))
|
| 53 |
+
fig, ax = plt.subplots()
|
| 54 |
+
ax.hist(data_f, bins=100, density=True)
|
| 55 |
+
stat_n, p_val_n = shapiro(data_f)
|
| 56 |
+
stat_p, p_val_p = kstest(data_f, 'poisson', (5, 0))
|
| 57 |
+
st.divider()
|
| 58 |
+
if p_val_n > 0.1:
|
| 59 |
+
st.write("Data follows Normal Distribution")
|
| 60 |
+
else:
|
| 61 |
+
st.write("Data does not follow Normal Distribution")
|
| 62 |
+
|
| 63 |
+
st.pyplot(fig)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
|