Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import matplotlib.pyplot as plt
|
| 4 |
+
|
| 5 |
+
x = st.slider('Select a value')
|
| 6 |
+
st.write(x, 'squared is', x * x)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
df = pd.read_csv('playing_cards/cards.csv').sort_values('class index')
|
| 10 |
+
df_test = df[df['data set']=='test']
|
| 11 |
+
df_train = df[df['data set']=='train']
|
| 12 |
+
df_validate = df[df['data set']=='validate']
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
### HORIZONTAL BAR ###
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Get the value counts of the 'labels' column
|
| 20 |
+
value_counts = df.groupby('labels')['class index'].count().iloc[::-1]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
fig, ax = plt.subplots(figsize=(10,10))
|
| 24 |
+
|
| 25 |
+
# Create a bar chart of the value counts
|
| 26 |
+
ax = value_counts.plot.barh()
|
| 27 |
+
# Set the chart title and axis labels
|
| 28 |
+
ax.set_title('Value Counts of Labels')
|
| 29 |
+
ax.set_xlabel('Label')
|
| 30 |
+
ax.set_ylabel('Count')
|
| 31 |
+
|
| 32 |
+
# Show the chart
|
| 33 |
+
st.pyplot(fig)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
### PIE CHART ###
|
| 37 |
+
|
| 38 |
+
# Get the value counts of the 'labels' column
|
| 39 |
+
value_counts = df.groupby('data set')['class index'].count().iloc[::-1]
|
| 40 |
+
|
| 41 |
+
value_counts =df['data set'].value_counts()
|
| 42 |
+
|
| 43 |
+
fig, ax = plt.subplots(figsize=(5,5)
|
| 44 |
+
)
|
| 45 |
+
# Create a bar chart of the value counts
|
| 46 |
+
ax = value_counts.plot.pie(autopct='%1.1f%%')
|
| 47 |
+
|
| 48 |
+
# Set the chart title and axis labels
|
| 49 |
+
ax.set_title('Train, Validate, Test Distribution')
|
| 50 |
+
# Show the chart
|
| 51 |
+
st.pyplot(fig)
|