Akankshg commited on
Commit
519db0a
·
verified ·
1 Parent(s): 84ae3ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py CHANGED
@@ -1087,6 +1087,45 @@ if analysis_option == 'Machine Learning':
1087
 
1088
 
1089
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1090
 
1091
 
1092
 
@@ -1140,6 +1179,9 @@ if analysis_option == 'Data':
1140
  col6 = st.columns(1)[0]
1141
  fig_man = scatter_man(data)
1142
  col6.plotly_chart(fig_man, use_container_width=True)
 
 
 
1143
 
1144
  st.dataframe(data.head(20).style.format({'PatientID': "{:.0f}"}))
1145
 
@@ -1197,6 +1239,9 @@ if analysis_option == 'EDA':
1197
  col12, col13 = st.columns(2)
1198
  fig10 = chart_11(health_data)
1199
  col12.plotly_chart(fig10, use_container_width=True)
 
 
 
1200
 
1201
  st.dataframe(health_data.head(20).style.format({'PatientID': "{:.0f}"}))
1202
 
 
1087
 
1088
 
1089
 
1090
+ def word_cloud(data):
1091
+ no_nan = data.dropna(subset=['ImmunizationName'])
1092
+ immu = list(no_nan['ImmunizationName'])
1093
+ filtered_data = [item for item in immu if item and not pd.isna(item)]
1094
+ unique_values = set(filtered_data)
1095
+ my_string = ' '.join(unique_values)
1096
+ lmao = my_string.strip(', ')
1097
+ lmao = lmao.replace(',', '')
1098
+
1099
+ cloud = WordCloud(
1100
+ scale=3,
1101
+ max_words=150,
1102
+ colormap='RdYlGn',
1103
+ mask=None,
1104
+ background_color='white',
1105
+ stopwords=None,
1106
+ collocations=True,
1107
+ contour_color='black',
1108
+ contour_width=1
1109
+ ).generate(lmao)
1110
+
1111
+ # Create a Matplotlib figure
1112
+ fig, ax = plt.subplots(figsize=(10, 6))
1113
+ ax.imshow(cloud, interpolation='bilinear')
1114
+ ax.axis('off') # Remove the axes
1115
+ ax.set_title('Immunization Word Cloud', color='black', fontsize=20)
1116
+
1117
+ # Return the figure to be used in Streamlit
1118
+ return fig
1119
+
1120
+ def more_scatter(data):
1121
+ component_icd_counts = data.groupby(['ComponentName', 'GroupedICD','Description']).size().reset_index(name='Count')
1122
+ component_icd_counts = component_icd_counts[component_icd_counts['Count']> 900]
1123
+ import plotly.express as px
1124
+ # Scatter plot
1125
+ fig16 = px.scatter(component_icd_counts, y='ComponentName', x='Description', size='Count',
1126
+ hover_name='ComponentName', color='Count', title='Lab Component-ICD Relationship',color_continuous_scale='YlOrBr')
1127
+ fig16.update_layout(template="plotly_dark",xaxis_title='ICD Code', yaxis_title='Component Name', coloraxis_colorbar=dict(title='Count'))
1128
+ return fig16
1129
 
1130
 
1131
 
 
1179
  col6 = st.columns(1)[0]
1180
  fig_man = scatter_man(data)
1181
  col6.plotly_chart(fig_man, use_container_width=True)
1182
+ fig16 = more_scatter(data)
1183
+ col8 = st.columns(1)[0]
1184
+ col8.plotly_chart(fig16, use_container_width=True)
1185
 
1186
  st.dataframe(data.head(20).style.format({'PatientID': "{:.0f}"}))
1187
 
 
1239
  col12, col13 = st.columns(2)
1240
  fig10 = chart_11(health_data)
1241
  col12.plotly_chart(fig10, use_container_width=True)
1242
+
1243
+ fig11 = word_cloud(health_data)
1244
+ col13.pyplot(fig11, use_container_width=True)
1245
 
1246
  st.dataframe(health_data.head(20).style.format({'PatientID': "{:.0f}"}))
1247