OmPrakashSingh1704 commited on
Commit
5cb7f33
1 Parent(s): de30414

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -0
app.py CHANGED
@@ -10,6 +10,10 @@ import pandas as pd
10
  from huggingface_hub import login, InferenceClient
11
  from sklearn.metrics.pairwise import cosine_similarity
12
  import streamlit as st
 
 
 
 
13
 
14
  st.set_page_config(layout="wide")
15
 
@@ -363,3 +367,61 @@ if not mode:
363
  show_recipe(filtered_recipes[0])
364
  else:
365
  st.write("No recipe found.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  from huggingface_hub import login, InferenceClient
11
  from sklearn.metrics.pairwise import cosine_similarity
12
  import streamlit as st
13
+ import wordcloud
14
+ import matplotlib.pyplot as plt
15
+ from pygwalker.api.streamlit import StreamlitRenderer
16
+ import plotly.express as px
17
 
18
  st.set_page_config(layout="wide")
19
 
 
367
  show_recipe(filtered_recipes[0])
368
  else:
369
  st.write("No recipe found.")
370
+ else:
371
+ st.markdown("# :eyes: PEOPLE SEARCHING FOR...")
372
+ print(st.session_state.ind)
373
+ flattened_indices = list(set(index for sublist in st.session_state.ind for index in sublist))
374
+ df = items_dict.iloc[flattened_indices]
375
+ if st.session_state.ind != []:
376
+ with st.spinner("LET'S SEE, WHAT PEOPLE WANT..."):
377
+ cont1 = st.container(border=True, height=500)
378
+ with cont1:
379
+ wc = wordcloud.WordCloud(width=1000, height=320, background_color='white').generate(
380
+ ' '.join(df['CATEGORY']))
381
+
382
+ # Display word cloud
383
+ fig, ax = plt.subplots()
384
+ ax.imshow(wc, interpolation='bilinear')
385
+ ax.axis('off')
386
+
387
+ st.pyplot(fig, use_container_width=True)
388
+
389
+ with st.container(border=True, height=500):
390
+ col1, col2 = st.columns(2)
391
+ with col1:
392
+ st.markdown('## DEMAND AS PER CATEGORY')
393
+ with plt.style.context('Solarize_Light2'):
394
+ fig0 = px.pie(df, names='CATEGORY', hole=0.5)
395
+ fig0.update_traces(text=df['CATEGORY'], textposition='outside')
396
+ st.plotly_chart(fig0, use_container_width=True)
397
+
398
+ with col2:
399
+ st.markdown('## DEMAND AS PER AVAILABILITY')
400
+ with plt.style.context('Solarize_Light2'):
401
+ fig1 = px.pie(df, names='AVAILABILITY', hole=0.5)
402
+ fig1.update_traces(text=df['AVAILABILITY'], textposition='outside')
403
+ st.plotly_chart(fig1, use_container_width=True)
404
+
405
+ with st.container(border=True, height=620):
406
+ st.markdown('## :deciduous_tree: Hierarchical view of Sales using TreeMap')
407
+ fig4 = px.treemap(df, path=['CATEGORY', 'AVAILABILITY','PRODUCT'],color='AVAILABILITY')
408
+ fig4.update_layout(height=550)
409
+ st.plotly_chart(fig4, use_container_width=True,scrolling=False)
410
+
411
+ with st.container(border=True, height=500):
412
+ fig = px.bar(df,
413
+ y='CATEGORY',
414
+ x='BREADCRUMBS',
415
+ color='BRAND',
416
+ # title='Gross Sales of Every Segment Country-wise',
417
+ barmode='relative',
418
+ title="Segment Vs. Gross Sales"
419
+ )
420
+ st.plotly_chart(fig, use_container_width=True)
421
+
422
+ @st.cache_resource
423
+ def pygwalerapp(df):
424
+ return StreamlitRenderer(df)
425
+ # st.markdown("## :desktop_computer: DO YOUR OWN RESEARCH...")
426
+ with st.expander("## :desktop_computer: LOOKING FOR SOMETHING ELSE..."):
427
+ pygwalerapp(df).explorer()