Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,34 +2,37 @@ import streamlit as st
|
|
2 |
import pandas as pd
|
3 |
import random
|
4 |
|
|
|
|
|
|
|
|
|
|
|
5 |
# Magic commands
|
6 |
st.set_page_config(page_title='Streamlit Super Power Cheat Sheet - Gamified')
|
7 |
-
|
8 |
|
9 |
-
#
|
10 |
-
player1 = [
|
11 |
-
|
12 |
-
|
|
|
|
|
13 |
|
14 |
-
player2 = [
|
15 |
-
|
16 |
-
|
|
|
|
|
17 |
|
18 |
-
# Create dataframes for each player card
|
19 |
df_player1 = pd.DataFrame(player1)
|
20 |
df_player2 = pd.DataFrame(player2)
|
21 |
-
|
22 |
-
# Merge the dataframes on word matches
|
23 |
df_matches = pd.merge(df_player1, df_player2, on='Word')
|
24 |
|
25 |
-
# Display the merged dataframe
|
26 |
st.dataframe(df_matches)
|
27 |
|
28 |
-
# Display the word match count
|
29 |
match_count = df_matches.shape[0]
|
30 |
st.write(f'Number of word matches: {match_count}')
|
31 |
|
32 |
-
# Display a random word match
|
33 |
if match_count > 0:
|
34 |
random_match = df_matches.iloc[random.randint(0, match_count-1)]
|
35 |
st.write(f'Random match: {random_match["Word"]}')
|
@@ -38,15 +41,7 @@ if match_count > 0:
|
|
38 |
else:
|
39 |
st.write('No word matches')
|
40 |
|
41 |
-
#
|
42 |
-
AI = 'π€'
|
43 |
-
DATA = 'π'
|
44 |
-
EMOJIS = ['π€£', 'π', 'π', 'π€ͺ', 'π', 'π€']
|
45 |
-
|
46 |
-
# strategy data
|
47 |
-
import pandas as pd
|
48 |
-
|
49 |
-
# Define the strategy classifications and their definitions
|
50 |
strategy_data = [
|
51 |
{'Classification': 'Economic', 'Definition': 'π° The branch of knowledge concerned with the production, consumption, and transfer of wealth.'},
|
52 |
{'Classification': 'Industry', 'Definition': 'π Economic activity concerned with the processing of raw materials and manufacture of goods in factories.'},
|
@@ -58,31 +53,15 @@ strategy_data = [
|
|
58 |
{'Classification': 'Network', 'Definition': 'π A group of interconnected people, companies, or devices that share information or resources.'},
|
59 |
]
|
60 |
|
61 |
-
st.markdown("""
|
62 |
-
Classification Definition
|
63 |
-
0 Economic π° The branch of knowledge concerned with the p...
|
64 |
-
1 Industry π Economic activity concerned with the process...
|
65 |
-
2 Manufacturing π The making of articles on a large scale usin...
|
66 |
-
3 Development ποΈ The process of growth, progress, or realiz...
|
67 |
-
4 Transport π The movement of people, goods, or materials ...
|
68 |
-
5 Income πΈ The money received by a person, company, or ...
|
69 |
-
6 Market π A regular gathering of people for the purcha...
|
70 |
-
7 Network π A group of interconnected people, companies,...
|
71 |
-
""")
|
72 |
-
|
73 |
-
# Create a dataframe from the strategy data
|
74 |
df_strategy = pd.DataFrame(strategy_data)
|
|
|
75 |
|
76 |
-
#
|
77 |
-
print(df_strategy)
|
78 |
-
|
79 |
-
|
80 |
-
# Example AI data
|
81 |
ai_data = {'accuracy': 0.89, 'precision': 0.72, 'recall': 0.64, 'f1': 0.68}
|
82 |
-
|
83 |
-
# One-liner functions
|
84 |
st.write(f"{AI} I'm sorry Dave, I'm afraid I can't do that.")
|
85 |
st.dataframe(pd.DataFrame(ai_data, index=['Model']))
|
|
|
|
|
86 |
st.table(pd.DataFrame(ai_data, index=['Model']))
|
87 |
st.json({'foo':'bar', 'fu':'ba', 'ai_data': ai_data})
|
88 |
st.metric(label="Model Accuracy", value=ai_data['accuracy'], delta=0.02)
|
|
|
2 |
import pandas as pd
|
3 |
import random
|
4 |
|
5 |
+
# Constants
|
6 |
+
AI = 'π€'
|
7 |
+
DATA = 'π'
|
8 |
+
EMOJIS = ['π€£', 'π', 'π', 'π€ͺ', 'π', 'π€']
|
9 |
+
|
10 |
# Magic commands
|
11 |
st.set_page_config(page_title='Streamlit Super Power Cheat Sheet - Gamified')
|
12 |
+
st.set_option('deprecation.showfileUploaderEncoding', False)
|
13 |
|
14 |
+
# ------------------------- PLAYER CARDS -------------------------
|
15 |
+
player1 = [
|
16 |
+
{'Word': 'Strategy', 'Definition': 'A plan of action designed to achieve a long-term or overall aim.'},
|
17 |
+
{'Word': 'Economics', 'Definition': 'The branch of knowledge concerned with the production, consumption, and transfer of wealth.'},
|
18 |
+
{'Word': 'Industry', 'Definition': 'Economic activity concerned with the processing of raw materials and manufacture of goods in factories.'}
|
19 |
+
]
|
20 |
|
21 |
+
player2 = [
|
22 |
+
{'Word': 'Manufacturing', 'Definition': 'The making of articles on a large scale using machinery.'},
|
23 |
+
{'Word': 'Transportation', 'Definition': 'The action of transporting someone or something or the process of being transported.'},
|
24 |
+
{'Word': 'Community', 'Definition': 'A group of people living in the same place or having a particular characteristic in common.'}
|
25 |
+
]
|
26 |
|
|
|
27 |
df_player1 = pd.DataFrame(player1)
|
28 |
df_player2 = pd.DataFrame(player2)
|
|
|
|
|
29 |
df_matches = pd.merge(df_player1, df_player2, on='Word')
|
30 |
|
|
|
31 |
st.dataframe(df_matches)
|
32 |
|
|
|
33 |
match_count = df_matches.shape[0]
|
34 |
st.write(f'Number of word matches: {match_count}')
|
35 |
|
|
|
36 |
if match_count > 0:
|
37 |
random_match = df_matches.iloc[random.randint(0, match_count-1)]
|
38 |
st.write(f'Random match: {random_match["Word"]}')
|
|
|
41 |
else:
|
42 |
st.write('No word matches')
|
43 |
|
44 |
+
# ------------------------- STRATEGY DATA -------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
strategy_data = [
|
46 |
{'Classification': 'Economic', 'Definition': 'π° The branch of knowledge concerned with the production, consumption, and transfer of wealth.'},
|
47 |
{'Classification': 'Industry', 'Definition': 'π Economic activity concerned with the processing of raw materials and manufacture of goods in factories.'},
|
|
|
53 |
{'Classification': 'Network', 'Definition': 'π A group of interconnected people, companies, or devices that share information or resources.'},
|
54 |
]
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
df_strategy = pd.DataFrame(strategy_data)
|
57 |
+
st.dataframe(df_strategy)
|
58 |
|
59 |
+
# ------------------------- AI DATA -------------------------
|
|
|
|
|
|
|
|
|
60 |
ai_data = {'accuracy': 0.89, 'precision': 0.72, 'recall': 0.64, 'f1': 0.68}
|
|
|
|
|
61 |
st.write(f"{AI} I'm sorry Dave, I'm afraid I can't do that.")
|
62 |
st.dataframe(pd.DataFrame(ai_data, index=['Model']))
|
63 |
+
|
64 |
+
# ------------------------- ONE-LINER FUNCTIONS -------------------------
|
65 |
st.table(pd.DataFrame(ai_data, index=['Model']))
|
66 |
st.json({'foo':'bar', 'fu':'ba', 'ai_data': ai_data})
|
67 |
st.metric(label="Model Accuracy", value=ai_data['accuracy'], delta=0.02)
|