xinah3131 commited on
Commit
59c76fe
·
1 Parent(s): 01797ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -206,7 +206,7 @@ def get_picture_from_url(url):
206
  return None
207
 
208
  def show_top_category():
209
- topCategory = pd.read_csv('topCategory.csv')
210
  # Sort the DataFrame in ascending order based on predicted_prob column
211
  topCategory_sorted = topCategory.sort_values('predicted_prob')
212
 
@@ -229,16 +229,16 @@ def show_top_category():
229
  st.pyplot(fig)
230
 
231
  def show_top_duration():
232
- topDuration = pd.read_csv('topDuration.csv')
233
  topDuration_sorted = topDuration.sort_values('predicted_prob', ascending=False)
234
 
235
  # Set the duration as the x-axis and predicted_prob as the y-axis
236
  x = topDuration_sorted['duration']
237
  y = topDuration_sorted['predicted_prob']
238
-
239
- # Create a scatter plot of duration vs predicted_prob
240
  plt.figure(figsize=(8, 5)) # Adjust the figure size here (width, height)
241
- plt.scatter(x, y)
242
  plt.xlabel('Duration')
243
  plt.ylabel('Predicted Probability')
244
  plt.title('Top Durations')
@@ -247,15 +247,16 @@ def show_top_duration():
247
  st.pyplot(plt)
248
 
249
  def show_top_title():
250
- topTitle = pd.read_csv('topTitle.csv')
251
  # Sort the DataFrame in ascending order based on predicted_prob column
252
  topTitle_sorted = topTitle.sort_values('Importance Score')
253
-
254
- plt.subplots(figsize=(5, 5))
255
- plt.barh(topTitle_sorted['Feature'], topTitle_sorted['Importance Score'])
256
- plt.xlabel('Importance Score')
257
- plt.ylabel('Feature')
258
- plt.title('Top Title Features')
 
259
  st.pyplot(plt)
260
 
261
 
@@ -264,7 +265,7 @@ def round_interval(interval_str):
264
  return f"({int(start)}, {int(end)})"
265
 
266
  def show_top_titleLength():
267
- topTitleLength = pd.read_csv('topTitleLength.csv')
268
 
269
  title_length_ranges = topTitleLength['titleLength']
270
  predicted_probs = topTitleLength['predicted_prob']
 
206
  return None
207
 
208
  def show_top_category():
209
+ topCategory = pd.read_csv(r'C:\Users\LEGION\Desktop\MMU\Data Science Fundamental\Project\Prediction of Video\topCategory.csv')
210
  # Sort the DataFrame in ascending order based on predicted_prob column
211
  topCategory_sorted = topCategory.sort_values('predicted_prob')
212
 
 
229
  st.pyplot(fig)
230
 
231
  def show_top_duration():
232
+ topDuration = pd.read_csv(r'C:\Users\LEGION\Desktop\MMU\Data Science Fundamental\Project\Prediction of Video\topDuration.csv')
233
  topDuration_sorted = topDuration.sort_values('predicted_prob', ascending=False)
234
 
235
  # Set the duration as the x-axis and predicted_prob as the y-axis
236
  x = topDuration_sorted['duration']
237
  y = topDuration_sorted['predicted_prob']
238
+
239
+ # Create a scatter plot of duration vs predicted_prob using seaborn
240
  plt.figure(figsize=(8, 5)) # Adjust the figure size here (width, height)
241
+ sns.scatterplot(x=x, y=y, palette='coolwarm') # Use coolwarm palette for colorful plot
242
  plt.xlabel('Duration')
243
  plt.ylabel('Predicted Probability')
244
  plt.title('Top Durations')
 
247
  st.pyplot(plt)
248
 
249
  def show_top_title():
250
+ topTitle = pd.read_csv(r'C:\Users\LEGION\Desktop\MMU\Data Science Fundamental\Project\Prediction of Video\topTitle.csv')
251
  # Sort the DataFrame in ascending order based on predicted_prob column
252
  topTitle_sorted = topTitle.sort_values('Importance Score')
253
+ sns.set(style="whitegrid")
254
+ plt.figure(figsize=(8, 6))
255
+ sns.barplot(x='Importance Score', y='Feature', data=topTitle_sorted, palette="rocket")
256
+ plt.xlabel('Importance Score', fontsize=12)
257
+ plt.ylabel('Feature', fontsize=12)
258
+ plt.title('Top Title Features', fontsize=14)
259
+ plt.tight_layout()
260
  st.pyplot(plt)
261
 
262
 
 
265
  return f"({int(start)}, {int(end)})"
266
 
267
  def show_top_titleLength():
268
+ topTitleLength = pd.read_csv(r'C:\Users\LEGION\Desktop\MMU\Data Science Fundamental\Project\Prediction of Video\topTitleLength.csv')
269
 
270
  title_length_ranges = topTitleLength['titleLength']
271
  predicted_probs = topTitleLength['predicted_prob']