Spaces:
Sleeping
Sleeping
root
commited on
Commit
·
dfaf959
1
Parent(s):
b89f1f1
auto push
Browse files- push.sh +3 -0
- wlb_index.py +66 -0
push.sh
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
git add .
|
2 |
+
git commit -m "auto push"
|
3 |
+
git pust
|
wlb_index.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# coding: utf-8
|
3 |
+
|
4 |
+
# In[6]:
|
5 |
+
|
6 |
+
|
7 |
+
physical_health = 4
|
8 |
+
mental_health = 3
|
9 |
+
social_life = 3
|
10 |
+
academic = 10
|
11 |
+
relationship = 5
|
12 |
+
perseverance = 5
|
13 |
+
financial_support = 7
|
14 |
+
|
15 |
+
# the index is calculated by the average of the 7 factors divided by the stdev of the 7 values
|
16 |
+
import math
|
17 |
+
|
18 |
+
average = (physical_health + mental_health + social_life + academic + relationship + perseverance + financial_support) / 7
|
19 |
+
stdev = math.sqrt((math.pow(physical_health - average, 2) + math.pow(mental_health - average, 2) + math.pow(social_life - average, 2) + math.pow(academic - average, 2) + math.pow(relationship - average, 2) + math.pow(perseverance - average, 2) + math.pow(financial_support - average, 2)) / 7)
|
20 |
+
index = average / stdev
|
21 |
+
print("The wlb index is: " + str(index))
|
22 |
+
|
23 |
+
|
24 |
+
# In[7]:
|
25 |
+
|
26 |
+
|
27 |
+
# use sns to draw a figure consists of 7 horizontal bars with different colors
|
28 |
+
import seaborn as sns
|
29 |
+
import matplotlib.pyplot as plt
|
30 |
+
sns.set(style="whitegrid")
|
31 |
+
fig, ax = plt.subplots(figsize=(10, 5), dpi=200)
|
32 |
+
ax = sns.barplot(x=[physical_health, mental_health, social_life, academic, relationship, perseverance, financial_support], y=["Physical Health", "Mental Health", "Social Life", "Academic", "Relationship", "Perseverance", "Financial Support"], palette="Blues_d")
|
33 |
+
ax.set(xlim=(0, 10), ylabel="", xlabel="Ability Level")
|
34 |
+
plt.title("Master WLB Index of Jack: " + str(round(index, 2)))
|
35 |
+
plt.show()
|
36 |
+
|
37 |
+
|
38 |
+
# In[13]:
|
39 |
+
|
40 |
+
|
41 |
+
# create a gradio app as interface
|
42 |
+
# display the sns figure in the interface using gradio.Plot
|
43 |
+
import gradio as gr
|
44 |
+
|
45 |
+
def wlb_index(physical_health, mental_health, social_life, academic, relationship, perseverance, financial_support):
|
46 |
+
average = (physical_health + mental_health + social_life + academic + relationship + perseverance + financial_support) / 7
|
47 |
+
stdev = math.sqrt((math.pow(physical_health - average, 2) + math.pow(mental_health - average, 2) + math.pow(social_life - average, 2) + math.pow(academic - average, 2) + math.pow(relationship - average, 2) + math.pow(perseverance - average, 2) + math.pow(financial_support - average, 2)) / 7)
|
48 |
+
index = average / stdev
|
49 |
+
sns.set(style="whitegrid")
|
50 |
+
fig, ax = plt.subplots(figsize=(10, 5), dpi=200)
|
51 |
+
ax = sns.barplot(x=[physical_health, mental_health, social_life, academic, relationship, perseverance, financial_support], y=["Physical Health", "Mental Health", "Social Life", "Academic", "Relationship", "Perseverance", "Financial Support"], palette="Blues_d")
|
52 |
+
ax.set(xlim=(0, 10), ylabel="", xlabel="Ability Level")
|
53 |
+
plt.title("Master WLB Index of Jack: " + str(round(index, 2)))
|
54 |
+
return plt
|
55 |
+
|
56 |
+
iface = gr.Interface(fn=wlb_index, inputs=["number", "number", "number", "number", "number", "number", "number"], outputs="plot")
|
57 |
+
|
58 |
+
iface.launch()
|
59 |
+
|
60 |
+
|
61 |
+
|
62 |
+
# In[ ]:
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
|