awacke1 commited on
Commit
d2e761a
1 Parent(s): f9d83bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -2
app.py CHANGED
@@ -9,9 +9,70 @@ st.markdown("""
9
  4. Keras: Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano. It is designed to be easy to use and supports both convolutional and recurrent neural networks.
10
  5. MXNet: MXNet is a deep learning framework that is known for its speed and scalability. It supports multiple programming languages and is used by several large companies for machine learning tasks.
11
 
12
-
13
  """)
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  st.markdown("""
16
  # Health Related Examples:
17
  1. Health Conditions By State: https://huggingface.co/spaces/awacke1/HealthConditionsTest
@@ -19,7 +80,6 @@ st.markdown("""
19
  3. Health Care and AI Datasets: https://huggingface.co/spaces/awacke1/Health-Care-AI-and-Datasets
20
  4. Zero Shot Classifier Facebook: https://huggingface.co/spaces/awacke1/Zero-shot-classification-facebook-bart-large-mnli
21
  5. Zero Shot Classifier Valhalla: https://huggingface.co/spaces/awacke1/Zero-Shot-Classification-valhalla-distilbart-mnli-12-1
22
- 6.
23
 
24
  """)
25
 
 
9
  4. Keras: Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano. It is designed to be easy to use and supports both convolutional and recurrent neural networks.
10
  5. MXNet: MXNet is a deep learning framework that is known for its speed and scalability. It supports multiple programming languages and is used by several large companies for machine learning tasks.
11
 
12
+ # Pytorch demo with knowledge trees
13
  """)
14
 
15
+ import matplotlib.pyplot as plt
16
+ from mpl_toolkits.mplot3d import Axes3D
17
+ import torch
18
+ def plot_knowledge_trees(knowledge_trees):
19
+ fig = plt.figure()
20
+ ax = fig.add_subplot(111, projection='3d')
21
+
22
+ xs = torch.arange(len(knowledge_trees))
23
+ ys = torch.arange(len(knowledge_trees[0]))
24
+ xs, ys = torch.meshgrid(xs, ys)
25
+
26
+ zs = []
27
+ for i in range(len(knowledge_trees)):
28
+ zs.append([kt[i] for kt in knowledge_trees])
29
+
30
+ zs = torch.tensor(zs)
31
+ ax.plot_surface(xs.numpy(), ys.numpy(), zs.numpy(), cmap='coolwarm')
32
+
33
+ ax.set_xlabel('States')
34
+ ax.set_ylabel('Knowledge Trees')
35
+ ax.set_zlabel('Number of Nodes')
36
+
37
+ return fig
38
+
39
+ def plot_population(states, populations):
40
+ fig, ax = plt.subplots()
41
+ ax.bar(states, populations)
42
+
43
+ ax.set_xlabel('States')
44
+ ax.set_ylabel('Population')
45
+
46
+ return fig
47
+
48
+
49
+ def main():
50
+ st.title('State Populations and Knowledge Trees')
51
+
52
+ # Define the state populations
53
+ states = ['California', 'Texas', 'Florida', 'New York']
54
+ populations = [39538223, 29145505, 21538187, 19849399]
55
+
56
+ # Define the knowledge trees for each state
57
+ knowledge_trees = [
58
+ [100, 200, 300, 400],
59
+ [150, 250, 350, 450],
60
+ [120, 220, 320, 420],
61
+ [130, 230, 330, 430]
62
+ ]
63
+
64
+ # Generate the plots
65
+ st.write('## State Populations')
66
+ fig_population = plot_population(states, populations)
67
+ st.pyplot(fig_population)
68
+
69
+ st.write('## Descending Order Lists of Knowledge Trees')
70
+ fig_knowledge_trees = plot_knowledge_trees(knowledge_trees)
71
+ st.pyplot(fig_knowledge_trees)
72
+
73
+ if __name__ == '__main__':
74
+ main()
75
+
76
  st.markdown("""
77
  # Health Related Examples:
78
  1. Health Conditions By State: https://huggingface.co/spaces/awacke1/HealthConditionsTest
 
80
  3. Health Care and AI Datasets: https://huggingface.co/spaces/awacke1/Health-Care-AI-and-Datasets
81
  4. Zero Shot Classifier Facebook: https://huggingface.co/spaces/awacke1/Zero-shot-classification-facebook-bart-large-mnli
82
  5. Zero Shot Classifier Valhalla: https://huggingface.co/spaces/awacke1/Zero-Shot-Classification-valhalla-distilbart-mnli-12-1
 
83
 
84
  """)
85