ayushsaini1207 commited on
Commit
52d977e
·
verified ·
1 Parent(s): 21bb5ba

Upload 9 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ maindataInstagram.csv filter=lfs diff=lfs merge=lfs -text
37
+ maindataYoutube.csv filter=lfs diff=lfs merge=lfs -text
age_range.csv ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Audience_age_range,Encoded_Value
2
+ 10-15,0
3
+ 15-20,1
4
+ 20-25,2
5
+ 25-30,3
6
+ 30-35,4
7
+ 35-40,5
8
+ 40-45,6
9
+ 45-50,7
10
+ 5-10,8
11
+ 50-55,9
12
+ 55-60,10
13
+ 60-65,11
14
+ 65-70,12
15
+ 70-75,13
16
+ 75-80,14
17
+ 80-85,15
18
+ 85-90,16
19
+ 90-95,17
20
+ 95-100,18
algo_instagram.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e11ce9eb65ebb6f0a364c5557a672c8374ea6882e5d620d8321227dfdf09f14b
3
+ size 305964536
algo_youtube.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c42fdee89021b447a64256cb0887894a65e4dada9818545e916952140462df48
3
+ size 194283087
app.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pandas as pd
4
+ import pickle
5
+
6
+ youtube_model = pickle.load(open('algo_youtube.pkl', 'rb'))
7
+ instagram_model = pickle.load(open('algo_instagram.pkl', 'rb'))
8
+ maindataYoutube = pd.read_csv("maindataYoutube.csv")
9
+ maindataInstagram = pd.read_csv("maindataInstagram.csv")
10
+
11
+ age_df = pd.read_csv("age_range.csv")
12
+ category_df = pd.read_csv("category.csv")
13
+ country_df = pd.read_csv("country.csv")
14
+
15
+ st.title("Recommendation")
16
+
17
+ def format_gender(option):
18
+
19
+ if option == 0:
20
+ return "Male"
21
+ elif option == 1:
22
+ return "Female"
23
+ else:
24
+ return option
25
+
26
+ def format_age(option):
27
+ age = age_df.loc[age_df['Encoded_Value'] == option, 'Audience_age_range'].values[0]
28
+ return age
29
+
30
+
31
+ def format_category(option):
32
+ content_category = category_df.loc[category_df['Encoded_Value'] == option, 'Content_category'].values[0]
33
+ return content_category
34
+
35
+
36
+ def format_country(option):
37
+ country = country_df.loc[country_df['Encoded_Value'] == option, 'Audience_country'].values[0]
38
+ return country
39
+
40
+
41
+ target_gender = st.selectbox(label= "Select Target Gender", options= [0,1], format_func= format_gender)
42
+ platform = st.selectbox(label= "Select Platform", options= ["Instagram", "Youtube"])
43
+ category = st.selectbox(label= "Select Category", options= category_df['Encoded_Value'], format_func= format_category) # edit
44
+ budget = st.slider(label="Select Budget", min_value= 10000, max_value= 800000) #edit
45
+ min_engagement_rate = st.slider(label="Select Minimum Engagement Range", min_value= 1, max_value= 5) #edit
46
+ target_country = st.selectbox(label="Select Country" , options= country_df['Encoded_Value'],format_func= format_country ) #edit
47
+ target_age_range = st.selectbox(label="Select Target Age Range" ,options= age_df['Encoded_Value'], format_func= format_age) #edit
48
+
49
+ def filtered_influencer_youtube():
50
+ filtered_youtubers = []
51
+ for _,youtuber in maindataYoutube.iterrows():
52
+ if youtuber['Engagement_rate'] >= min_engagement_rate \
53
+ and youtuber['Majority_audience_gender'] == target_gender \
54
+ and youtuber['Audience_country'] == target_country \
55
+ and youtuber['Audience_age_range'] == target_age_range \
56
+ and youtuber['Cost_per_post'] <= budget:
57
+ filtered_youtubers.append((youtuber["YouTube_channel_name"],youtuber['Content_category'], youtuber['Cost_per_post']))
58
+
59
+ return filtered_youtubers
60
+
61
+ def filtered_influencer_instagram():
62
+ filtered_insta = []
63
+ for _, insta in maindataInstagram.iterrows():
64
+ if insta['Engagement_rate'] >= min_engagement_rate \
65
+ and insta['Majority_audience_gender'] == target_gender \
66
+ and insta['Audience_country'] == target_country \
67
+ and insta['Audience_age_range'] == target_age_range \
68
+ and insta['Cost_per_post'] <= budget:
69
+ filtered_insta.append((insta["Influencer_insta_username"],insta['Content_category'], insta['Cost_per_post']))
70
+
71
+ return filtered_insta
72
+
73
+
74
+ def get_recommendations_with_age_range_filter_youtube():
75
+
76
+ filtered = filtered_influencer_youtube()
77
+ dataset1 = [tup[:3] for tup in filtered]
78
+ predictions = {}
79
+ for uid, iid, category in dataset1:
80
+ pred = youtube_model.predict(uid, iid)
81
+ predictions[uid] = pred.est
82
+ sorted_predictions = sorted(predictions.items(), key=lambda x: x[1], reverse=True)
83
+ return sorted_predictions[:10]
84
+
85
+ def get_recommendations_with_age_range_filter_instagram():
86
+ filtered = filtered_influencer_instagram()
87
+ dataset1 = [tup[:3] for tup in filtered]
88
+ predictions = {}
89
+ for uid, iid, category in dataset1:
90
+ pred = instagram_model.predict(uid, iid)
91
+ predictions[uid] = pred.est
92
+ sorted_predictions = sorted(predictions.items(), key=lambda x: x[1], reverse=True)
93
+ return sorted_predictions[:10]
94
+
95
+
96
+ def checkPlatform():
97
+
98
+ if platform == "Youtube":
99
+ youtubers = get_recommendations_with_age_range_filter_youtube()
100
+ for youtuber, rating in youtubers:
101
+ youtuber_name = maindataYoutube.loc[maindataYoutube['YouTube_channel_name'] == youtuber , 'channel_name'].iloc[0]
102
+ st.success(youtuber_name + ' :thumbsup:')
103
+
104
+
105
+ else:
106
+ influencers = get_recommendations_with_age_range_filter_instagram()
107
+ for influencer, rating in influencers:
108
+ influencer_name = maindataInstagram.loc[maindataInstagram['Influencer_insta_username'] == influencer, 'Influencer_insta_id'].iloc[0]
109
+ st.success(influencer_name + ' :thumbsup:')
110
+
111
+
112
+
113
+ trigger = st.button('Recommend ', on_click=checkPlatform)
category.csv ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Content_category,Encoded_Value
2
+ Animals,0
3
+ Art,1
4
+ Beauty,2
5
+ Business & Careers,3
6
+ Cinema/Theatre,4
7
+ Comedy,5
8
+ Dance,6
9
+ Education,7
10
+ Family,8
11
+ Fashion,9
12
+ Fitness,10
13
+ Food & Cooking,11
14
+ Games,12
15
+ Inspirational quotes,13
16
+ Lifestyle,14
17
+ Literature & Journalism,15
18
+ Management & Marketing,16
19
+ Media,17
20
+ Medical,18
21
+ Modeling,19
22
+ Music,20
23
+ Photography,21
24
+ Real Estate,22
25
+ Retail,23
26
+ Spirituality,24
27
+ Sports,25
28
+ Technology,26
29
+ Travel,27
country.csv ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Audience_country,Encoded_Value
2
+ Algeria,0
3
+ Argentina,1
4
+ Australia,2
5
+ Austria,3
6
+ Bangladesh,4
7
+ Belgium,5
8
+ Bhutan,6
9
+ Brazil,7
10
+ Canada,8
11
+ Chile,9
12
+ China,10
13
+ Colombia,11
14
+ Costa Rica,12
15
+ Denmark,13
16
+ Egypt,14
17
+ France,15
18
+ Germany,16
19
+ Greece,17
20
+ Hong Kong,18
21
+ India,19
22
+ Indonesia,20
23
+ Iraq,21
24
+ Ireland,22
25
+ Italy,23
26
+ Japan,24
27
+ Malaysia,25
28
+ Mexico,26
29
+ Morocco,27
30
+ Netherlands,28
31
+ New Zealand,29
32
+ Nigeria,30
33
+ Norway,31
34
+ Pakistan,32
35
+ Peru,33
36
+ Philippines,34
37
+ Poland,35
38
+ Portugal,36
39
+ Romania,37
40
+ Russia,38
41
+ Saudi Arabia,39
42
+ Singapore,40
43
+ South Africa,41
44
+ South Korea,42
45
+ Spain,43
46
+ Sweden,44
47
+ Switzerland,45
48
+ Thailand,46
49
+ United Arab Emirates,47
50
+ United Kingdom,48
51
+ United States,49
52
+ Vietnam,50
maindataInstagram.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5af3ede92a72880b638c1440db9ecc1e591dfe8401d51d4298aabf581fa94cbe
3
+ size 74914142
maindataYoutube.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c24eecf4b4ec7227a56a728675f076795bd7de88ce746b13ef61f104bb357a8
3
+ size 40408901
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit==1.20.0
2
+ numpy>=1.9.2
3
+ scikit-learn>=0.18
4
+ pandas
5
+ surprise