ogegadavis254 commited on
Commit
91ad748
·
verified ·
1 Parent(s): 86ccd3b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -26
app.py CHANGED
@@ -264,45 +264,48 @@ elif page == "Skills Analysis":
264
  skills = st.multiselect("Select skills to analyze:",
265
  ["Data Analysis", "Web Development", "Digital Marketing", "Cybersecurity", "Cloud Computing", "AI/Machine Learning", "Mobile App Development", "UI/UX Design"])
266
  regions = st.multiselect("Select regions:",
267
- ["Nairobi", "Mombasa", "Kisumu", "Nakuru", "Eldoret", "Thika", "Malindi", "Kitale", "Kisii", "Nyamira", "Western"])
268
  time_period = st.selectbox("Select time period:", ["Last 3 months", "Last 6 months", "Last year"])
269
  with col2:
270
  st_lottie(lottie_skills, height=200, key="skills")
271
 
272
  if st.button("Analyze Skills Demand"):
273
  with st.spinner("Analyzing skills demand..."):
274
- # Simulated data generation
275
- demand_data = generate_simulated_data(skills)
276
 
277
- # Plotting
278
- fig = go.Figure()
279
- for skill in skills:
280
- fig.add_trace(go.Bar(x=regions, y=demand_data[skill], name=skill))
281
- fig.update_layout(title="Digital Skills Demand by Region", barmode='group')
282
- st.plotly_chart(fig)
283
 
284
- # AI Insights
285
- ai_prompt = f"Analyze the demand for {', '.join(skills)} in {', '.join(regions)} over the {time_period}. Provide insights on trends, gaps, and recommendations for skill development."
286
- ai_insights = call_ai_model(ai_prompt)
287
- st.markdown("### AI Insights")
288
- st.write(ai_insights)
 
 
 
 
289
 
290
- # Word Cloud
291
- word_cloud_text = " ".join(skills + regions + ai_insights.split())
292
- st.markdown("### Skills Demand Word Cloud")
293
- st.pyplot(create_word_cloud(word_cloud_text))
 
294
 
295
- # Skills growth projection
296
  st.markdown("### Skills Growth Projection")
297
- growth_data = {skill: [random.uniform(0, 15) for _ in range(5)] for skill in skills}
298
- years = [datetime.now().year + i for i in range(5)]
299
- fig = go.Figure()
300
- for skill, growth in growth_data.items():
301
- fig.add_trace(go.Scatter(x=years, y=growth, mode='lines+markers', name=skill))
302
- fig.update_layout(title="Projected Skills Growth (Next 5 Years)", xaxis_title="Year", yaxis_title="Growth Rate (%)")
303
- st.plotly_chart(fig)
304
 
305
  st.markdown('</div>', unsafe_allow_html=True)
 
 
306
 
307
  elif page == "Program Evaluation":
308
  animated_progress_bar()
 
264
  skills = st.multiselect("Select skills to analyze:",
265
  ["Data Analysis", "Web Development", "Digital Marketing", "Cybersecurity", "Cloud Computing", "AI/Machine Learning", "Mobile App Development", "UI/UX Design"])
266
  regions = st.multiselect("Select regions:",
267
+ ["Nairobi", "Mombasa", "Kisumu", "Nakuru", "Eldoret", "Thika", "Malindi", "Kitale"])
268
  time_period = st.selectbox("Select time period:", ["Last 3 months", "Last 6 months", "Last year"])
269
  with col2:
270
  st_lottie(lottie_skills, height=200, key="skills")
271
 
272
  if st.button("Analyze Skills Demand"):
273
  with st.spinner("Analyzing skills demand..."):
274
+ # Simulated data generation (optimized)
275
+ demand_data = {skill: [random.randint(1, 100) for _ in regions] for skill in skills}
276
 
277
+ # Plotting (single chart instead of multiple)
278
+ df = pd.DataFrame(demand_data, index=regions)
279
+ fig = px.bar(df, barmode='group', title="Digital Skills Demand by Region")
280
+ st.plotly_chart(fig, use_container_width=True)
 
 
281
 
282
+ # AI Insights (with timeout)
283
+ ai_prompt = f"Briefly and shortly analyze the demand for {', '.join(skills)} in {', '.join(regions)} over the {time_period}. Provide key insights on trends and gaps."
284
+ try:
285
+ with st.spinner("Generating AI insights..."):
286
+ ai_insights = call_ai_model(ai_prompt)
287
+ st.markdown("### AI Insights")
288
+ st.write(ai_insights)
289
+ except Exception as e:
290
+ st.error(f"Failed to generate AI insights: {str(e)}")
291
 
292
+ # Word Cloud (optional)
293
+ if st.checkbox("Generate Word Cloud"):
294
+ word_cloud_text = " ".join(skills + regions + ai_insights.split())
295
+ st.markdown("### Skills Demand Word Cloud")
296
+ st.pyplot(create_word_cloud(word_cloud_text))
297
 
298
+ # Skills growth projection (simplified)
299
  st.markdown("### Skills Growth Projection")
300
+ growth_data = {skill: [random.uniform(0, 15) for _ in range(2)] for skill in skills}
301
+ years = [datetime.now().year, datetime.now().year + 5]
302
+ df_growth = pd.DataFrame(growth_data, index=years)
303
+ fig_growth = px.line(df_growth, title="Projected Skills Growth (5 Year Projection)")
304
+ st.plotly_chart(fig_growth, use_container_width=True)
 
 
305
 
306
  st.markdown('</div>', unsafe_allow_html=True)
307
+
308
+
309
 
310
  elif page == "Program Evaluation":
311
  animated_progress_bar()