diff options
| author | Bobby <[email protected]> | 2022-12-03 23:48:20 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-12-03 23:48:20 -0500 |
| commit | 0b11c46231cdc922c0195a4bd2cd903860aeadc7 (patch) | |
| tree | 8e4497f39c60a5c4a315c5f02a7e4893251fa4cd | |
| parent | 432685c4972870a8119996335f53c08838661b80 (diff) | |
| download | RedditEngagementPrediction-0b11c46231cdc922c0195a4bd2cd903860aeadc7.tar.xz RedditEngagementPrediction-0b11c46231cdc922c0195a4bd2cd903860aeadc7.zip | |
Considering Time and Day in Predictions:
| -rw-r--r-- | src/windows/predict.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/windows/predict.py b/src/windows/predict.py index 49402ff..0783d14 100644 --- a/src/windows/predict.py +++ b/src/windows/predict.py @@ -87,7 +87,7 @@ class Predict(customtkinter.CTkToplevel): hour = int(hour.split(':')[0]) distinguished = False if self.distinguished_entry.get() == 0 else True - if not title or not selftext or not subreddit or not day or not hour: + if not title or not selftext: tkinter.messagebox.showerror('Error', 'Please fill all the fields') return @@ -120,5 +120,26 @@ class Predict(customtkinter.CTkToplevel): num_comments = num_comments_model.predict(X) num_comments = int(num_comments[0]) + # Bias for day, hour, subreddit, distinguished, if the user does not post on best time of the day + best_time_df = self.parent.posts[['subreddit', 'day', 'hour', 'ups', 'num_comments']].groupby(['subreddit', 'day', 'hour']).sum().reset_index() + ups_best_time = best_time_df[(best_time_df['subreddit'] == subreddit) & (best_time_df['day'] == day) & (best_time_df['hour'] == hour)]['ups'].values[0] + num_comments_best_time = best_time_df[(best_time_df['subreddit'] == subreddit) & (best_time_df['day'] == day) & (best_time_df['hour'] == hour)]['num_comments'].values[0] + + ups_bias = ups_best_time / ups + + print(ups, ups_bias) + num_comments_bias = num_comments_best_time / num_comments + + ups = ups * ups_bias + num_comments = num_comments * num_comments_bias + + # distinguished bias + if distinguished: + ups = ups * 1.5 + num_comments = num_comments * 1.5 + + ups = int(ups) + num_comments = int(num_comments) + tkinter.messagebox.showinfo('Result', 'Predicted ups: {}\nPredicted num_comments: {}'.format(ups, num_comments)) |
