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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import streamlit.components.v1 as components
|
| 3 |
+
import networkx as nx
|
| 4 |
+
import matplotlib.pyplot as plt
|
| 5 |
+
from pyvis.network import Network
|
| 6 |
+
import got
|
| 7 |
+
import numpy as np
|
| 8 |
+
import pandas as pd
|
| 9 |
+
import time
|
| 10 |
+
import re
|
| 11 |
+
import graphviz as graphviz
|
| 12 |
+
import pydeck as pdk
|
| 13 |
+
|
| 14 |
+
from st_click_detector import click_detector
|
| 15 |
+
|
| 16 |
+
st.graphviz_chart('''
|
| 17 |
+
digraph {
|
| 18 |
+
Income -> AbleToBuyOnlyNecessities
|
| 19 |
+
Income -> DifficultyBuyingNecessities
|
| 20 |
+
Income -> DifficultyWithMoneyManagement
|
| 21 |
+
Income -> LowNoIncome
|
| 22 |
+
Income -> UninsuredMedicalExpenses
|
| 23 |
+
}
|
| 24 |
+
''')
|
| 25 |
+
|
| 26 |
+
st.graphviz_chart('''
|
| 27 |
+
digraph {
|
| 28 |
+
Income -> Continuityof -> Care
|
| 29 |
+
Income -> Durable -> Medical -> Equipment
|
| 30 |
+
Income -> Finances
|
| 31 |
+
Income -> LegalSystem
|
| 32 |
+
Income -> Medical -> Dental -> Care
|
| 33 |
+
Income -> Medication -> Coordination -> Ordering
|
| 34 |
+
Income -> Other -> Community -> Resources
|
| 35 |
+
Income -> SocialWork -> Counseling -> Care
|
| 36 |
+
Income -> Supplies
|
| 37 |
+
}
|
| 38 |
+
''')
|
| 39 |
+
|
| 40 |
+
st.graphviz_chart('''
|
| 41 |
+
digraph {
|
| 42 |
+
MentalHealth -> Apprehension -> Undefined -> Fear -> Anxious
|
| 43 |
+
MentalHealth -> Attempts -> Suicide -> Homicide
|
| 44 |
+
MentalHealth -> Difficulty -> Managing -> Anger
|
| 45 |
+
MentalHealth -> Difficulty -> Managing -> Stress
|
| 46 |
+
MentalHealth -> Expresses -> Suicidal -> Homicidal -> Thoughts
|
| 47 |
+
MentalHealth -> False -> Beliefs -> Delusions
|
| 48 |
+
MentalHealth -> False -> Perceptions -> Hallucinations -> Illusions
|
| 49 |
+
MentalHealth -> FlatAffect -> LackofEmotion
|
| 50 |
+
MentalHealth -> Irritable -> Agitated -> Aggressive
|
| 51 |
+
MentalHealth -> LossofInterest -> Involvementin -> ActivitiesSelfCare
|
| 52 |
+
MentalHealth -> MoodSwings
|
| 53 |
+
MentalHealth -> Narrowedto -> Scattered -> Attention -> Focus
|
| 54 |
+
MentalHealth -> Purposeless -> Compulsive -> RepetitiveActivity
|
| 55 |
+
MentalHealth -> Sadness -> Hopelessness -> Decreased -> SelfEsteem
|
| 56 |
+
MentalHealth -> Somatic -> Complaints -> Fatigue
|
| 57 |
+
}
|
| 58 |
+
''')
|
| 59 |
+
|
| 60 |
+
st.graphviz_chart('''
|
| 61 |
+
digraph {
|
| 62 |
+
MentalHealth -> Anger -> Management
|
| 63 |
+
MentalHealth -> Behavioral -> Health -> Care
|
| 64 |
+
MentalHealth -> Communication
|
| 65 |
+
MentalHealth -> Continuityof -> Care
|
| 66 |
+
MentalHealth -> Coping -> Skills
|
| 67 |
+
MentalHealth -> Dietary -> Management
|
| 68 |
+
MentalHealth -> Discipline
|
| 69 |
+
MentalHealth -> EndofLife -> Care
|
| 70 |
+
MentalHealth -> Interaction
|
| 71 |
+
MentalHealth -> LegalSystem
|
| 72 |
+
MentalHealth -> Medical -> Dental -> Care
|
| 73 |
+
MentalHealth -> Medication -> ActionSideEffects
|
| 74 |
+
MentalHealth -> Medication -> Administration
|
| 75 |
+
MentalHealth -> Medication -> CoordinationOrdering
|
| 76 |
+
MentalHealth -> Nursing -> Care
|
| 77 |
+
MentalHealth -> Nutritionist -> Care
|
| 78 |
+
MentalHealth -> Other -> Community -> Resources
|
| 79 |
+
MentalHealth -> Relaxation -> Breathing -> Techniques
|
| 80 |
+
MentalHealth -> Rest -> Sleep
|
| 81 |
+
MentalHealth -> Safety
|
| 82 |
+
MentalHealth -> Screening -> Procedures
|
| 83 |
+
MentalHealth -> SignsSymptoms -> MentalEmotional
|
| 84 |
+
MentalHealth -> SignsSymptoms -> Physical
|
| 85 |
+
MentalHealth -> SocialWork -> Counseling -> Care
|
| 86 |
+
MentalHealth -> Stress -> Management
|
| 87 |
+
MentalHealth -> Support -> Group
|
| 88 |
+
MentalHealth -> Support -> System
|
| 89 |
+
MentalHealth -> Wellness
|
| 90 |
+
}
|
| 91 |
+
''')
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
st.graphviz_chart('''
|
| 95 |
+
digraph {
|
| 96 |
+
Respiration -> Abnormal -> BreathSoundsCrackles
|
| 97 |
+
Respiration -> Abnormal -> IrregularBreathPatterns
|
| 98 |
+
Respiration -> Abnormal -> RespiratoryLaboratoryResults
|
| 99 |
+
Respiration -> Abnormal -> Sputum
|
| 100 |
+
Respiration -> Cough
|
| 101 |
+
Respiration -> Noisy -> RespirationswheezingRalesRhonchi
|
| 102 |
+
Respiration -> Rhinorrhea -> NasalCongestion
|
| 103 |
+
Respiration -> UnabletoBreathe -> Independently
|
| 104 |
+
}
|
| 105 |
+
''')
|
| 106 |
+
|
| 107 |
+
st.graphviz_chart('''
|
| 108 |
+
digraph {
|
| 109 |
+
Respiration -> Anatomy -> Physiology
|
| 110 |
+
Respiration -> Continuityof -> Care
|
| 111 |
+
Respiration -> Coping -> Skills
|
| 112 |
+
Respiration -> Dietary -> Management
|
| 113 |
+
Respiration -> Durable -> Medical -> Equipment
|
| 114 |
+
Respiration -> Education
|
| 115 |
+
Respiration -> EndofLife -> Care
|
| 116 |
+
Respiration -> Environment
|
| 117 |
+
Respiration -> Exercises
|
| 118 |
+
Respiration -> Infection -> Precautions
|
| 119 |
+
Respiration -> Laboratory -> Findings
|
| 120 |
+
Respiration -> Medical -> Dental -> Care
|
| 121 |
+
Respiration -> Medication -> Action -> SideEffects
|
| 122 |
+
Respiration -> Medication -> Administration
|
| 123 |
+
Respiration -> Medication -> Prescription
|
| 124 |
+
Respiration -> Medication -> SetUp
|
| 125 |
+
Respiration -> Mobility -> Transfers
|
| 126 |
+
Respiration -> Nursing -> Care
|
| 127 |
+
Respiration -> Positioning
|
| 128 |
+
Respiration -> Relaxation -> Breathing -> Techniques
|
| 129 |
+
Respiration -> Respiratory -> Care
|
| 130 |
+
Respiration -> Respiratory -> Therapy -> Care
|
| 131 |
+
Respiration -> Safety
|
| 132 |
+
Respiration -> Screening -> Procedures
|
| 133 |
+
Respiration -> SignsSymptoms -> MentalEmotional
|
| 134 |
+
Respiration -> SignsSymptoms -> Physical
|
| 135 |
+
Respiration -> Specimen -> Collection
|
| 136 |
+
Respiration -> Supplies
|
| 137 |
+
Respiration -> Support -> Group
|
| 138 |
+
Respiration -> Support -> System
|
| 139 |
+
Respiration -> Wellness
|
| 140 |
+
}
|
| 141 |
+
''')
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
st.graphviz_chart('''
|
| 145 |
+
digraph {
|
| 146 |
+
Circulation -> Abnormal -> BloodPressureReading
|
| 147 |
+
Circulation -> Abnormal -> CardiacLaboratoryResults
|
| 148 |
+
Circulation -> Abnormal -> Clotting
|
| 149 |
+
Circulation -> Abnormal -> HeartSoundsMurmurs
|
| 150 |
+
Circulation -> Anginal -> Pain
|
| 151 |
+
Circulation -> Cramping -> Pain -> ofExtremities
|
| 152 |
+
Circulation -> Decreased -> Pulses
|
| 153 |
+
Circulation -> Discoloration -> ofSkinCyanosis
|
| 154 |
+
Circulation -> EdemaSwelling -> inlegsarmsfeet
|
| 155 |
+
Circulation -> ExcessivelyRapid -> HeartRate
|
| 156 |
+
Circulation -> IrregularHeartRate
|
| 157 |
+
Circulation -> SyncopalEpisodes -> Fainting -> Dizziness
|
| 158 |
+
Circulation -> TemperatureChange -> inAffectedArea
|
| 159 |
+
Circulation -> Varicosities
|
| 160 |
+
}
|
| 161 |
+
''')
|
| 162 |
+
|
| 163 |
+
st.graphviz_chart('''
|
| 164 |
+
digraph {
|
| 165 |
+
Circulation -> Anatomy -> Physiology
|
| 166 |
+
Circulation -> Cardiac -> Care
|
| 167 |
+
Circulation -> Continuityof -> Care
|
| 168 |
+
Circulation -> Coping -> Skills
|
| 169 |
+
Circulation -> Dietary -> Management
|
| 170 |
+
Circulation -> Durable -> Medical -> Equipment
|
| 171 |
+
Circulation -> Exercises
|
| 172 |
+
Circulation -> Finances
|
| 173 |
+
Circulation -> Infection -> Precautions
|
| 174 |
+
Circulation -> Laboratory -> Findings
|
| 175 |
+
Circulation -> Medical -> Dental -> Care
|
| 176 |
+
Circulation -> Medication -> Action -> SideEffects
|
| 177 |
+
Circulation -> Medication -> Administration
|
| 178 |
+
Circulation -> Medication -> SetUp
|
| 179 |
+
Circulation -> Mobility -> Transfers
|
| 180 |
+
Circulation -> Nursing -> Care
|
| 181 |
+
Circulation -> Personal -> Hygiene
|
| 182 |
+
Circulation -> Relaxation -> Breathing -> Techniques
|
| 183 |
+
Circulation -> Safety
|
| 184 |
+
Circulation -> Screening -> Procedures
|
| 185 |
+
Circulation -> SignsSymptoms -> MentalEmotional
|
| 186 |
+
Circulation -> SignsSymptoms -> Physical
|
| 187 |
+
Circulation -> Support -> Group
|
| 188 |
+
Circulation -> Support -> System
|
| 189 |
+
Circulation -> Wellness
|
| 190 |
+
}
|
| 191 |
+
''')
|
| 192 |
+
|
| 193 |
+
df = pd.read_csv("testfile.csv")
|
| 194 |
+
@st.cache
|
| 195 |
+
def convert_df(df):
|
| 196 |
+
return df.to_csv().encode('utf-8')
|
| 197 |
+
csv = convert_df(df)
|
| 198 |
+
st.download_button(
|
| 199 |
+
"Press to Download",
|
| 200 |
+
csv,
|
| 201 |
+
"testfile.csv",
|
| 202 |
+
"text/csv",
|
| 203 |
+
key='download-csv'
|
| 204 |
+
)
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
st.title('Streamlit Visualization')
|
| 208 |
+
dataframe = pd.DataFrame(np.random.randn(10, 20),
|
| 209 |
+
columns = ('col %d' % i
|
| 210 |
+
for i in range(20)))
|
| 211 |
+
st.write(dataframe)
|
| 212 |
+
|
| 213 |
+
dataframe = pd.DataFrame(np.random.randn(10, 5),
|
| 214 |
+
columns = ('col %d' % i
|
| 215 |
+
for i in range(5)))
|
| 216 |
+
dataframe
|
| 217 |
+
st.write('This is a line_chart.')
|
| 218 |
+
st.line_chart(dataframe)
|
| 219 |
+
|
| 220 |
+
st.write('This is a area_chart.')
|
| 221 |
+
st.area_chart(dataframe)
|
| 222 |
+
|
| 223 |
+
st.write('This is a bar_chart.')
|
| 224 |
+
st.bar_chart(dataframe)
|
| 225 |
+
|
| 226 |
+
st.write('Map data')
|
| 227 |
+
data_of_map = pd.DataFrame(
|
| 228 |
+
np.random.randn(1000, 2) / [60, 60] + [36.66, -121.6],
|
| 229 |
+
columns = ['latitude', 'longitude'])
|
| 230 |
+
st.map(data_of_map)
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
st.title('Pyvis VisJS DOTlang Legend')
|
| 234 |
+
|
| 235 |
+
Network(notebook=True)
|
| 236 |
+
# make Network show itself with repr_html
|
| 237 |
+
|
| 238 |
+
def net_repr_html(self):
|
| 239 |
+
nodes, edges, height, width, options = self.get_network_data()
|
| 240 |
+
html = self.template.render(height=height, width=width, nodes=nodes, edges=edges, options=options)
|
| 241 |
+
return html
|
| 242 |
+
|
| 243 |
+
Network._repr_html_ = net_repr_html
|
| 244 |
+
|
| 245 |
+
st.sidebar.title('Choose your favorite Graph')
|
| 246 |
+
option=st.sidebar.selectbox('select graph',('Simple','Karate', 'GOT'))
|
| 247 |
+
physics=st.sidebar.checkbox('add physics interactivity?')
|
| 248 |
+
got.simple_func(physics)
|
| 249 |
+
|
| 250 |
+
if option=='Simple':
|
| 251 |
+
HtmlFile = open("test.html", 'r', encoding='utf-8')
|
| 252 |
+
source_code = HtmlFile.read()
|
| 253 |
+
components.html(source_code, height = 900,width=900)
|
| 254 |
+
|
| 255 |
+
got.got_func(physics)
|
| 256 |
+
|
| 257 |
+
if option=='GOT':
|
| 258 |
+
HtmlFile = open("gameofthrones.html", 'r', encoding='utf-8')
|
| 259 |
+
source_code = HtmlFile.read()
|
| 260 |
+
components.html(source_code, height = 1200,width=1000)
|
| 261 |
+
|
| 262 |
+
got.karate_func(physics)
|
| 263 |
+
|
| 264 |
+
if option=='Karate':
|
| 265 |
+
HtmlFile = open("karate.html", 'r', encoding='utf-8')
|
| 266 |
+
source_code = HtmlFile.read()
|
| 267 |
+
components.html(source_code, height = 1200,width=1000)
|