Spaces:
Runtime error
Runtime error
Update backend/models/recommender/rec.py
Browse files
backend/models/recommender/rec.py
CHANGED
@@ -127,26 +127,21 @@ def recs_essentials(vector = None, name = None):
|
|
127 |
def makeup_recommendation(skin_tone, skin_type):
|
128 |
result = []
|
129 |
dff = pd.DataFrame()
|
130 |
-
|
131 |
-
foundation = makeup[(makeup['skin tone'] == skin_tone) & (makeup['skin type'] == skin_type) & (makeup['label'] == 'foundation')].head(2)
|
132 |
-
concealer = makeup[(makeup['skin tone'] == skin_tone) & (makeup['skin type'] == skin_type) & (makeup['label'] == 'concealer')].head(2)
|
133 |
-
primer = makeup[(makeup['skin tone'] == skin_tone) & (makeup['skin type'] == skin_type) & (makeup['label'] == 'primer')].head(2)
|
134 |
|
135 |
-
# Concatenate
|
136 |
-
dff = pd.concat([
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
# Shuffle the rows randomly
|
144 |
dff = dff.sample(frac=1).reset_index(drop=True)
|
145 |
-
|
146 |
-
# Extract relevant columns and convert to list of dictionaries
|
147 |
-
data = dff[['brand', 'name', 'price', 'url', 'skin type', 'skin tone']].to_dict('split')['data']
|
148 |
|
149 |
-
#
|
|
|
|
|
|
|
150 |
for element in data:
|
151 |
result.append(wrap_makeup(element))
|
152 |
|
@@ -154,4 +149,3 @@ def makeup_recommendation(skin_tone, skin_type):
|
|
154 |
|
155 |
|
156 |
|
157 |
-
|
|
|
127 |
def makeup_recommendation(skin_tone, skin_type):
|
128 |
result = []
|
129 |
dff = pd.DataFrame()
|
|
|
|
|
|
|
|
|
130 |
|
131 |
+
# Concatenate all makeup categories into a single DataFrame
|
132 |
+
dff = pd.concat([
|
133 |
+
makeup[(makeup['skin tone'] == skin_tone) & (makeup['skin type'] == skin_type) & (makeup['label'] == 'foundation')].head(2),
|
134 |
+
makeup[(makeup['skin tone'] == skin_tone) & (makeup['skin type'] == skin_type) & (makeup['label'] == 'concealer')].head(2),
|
135 |
+
makeup[(makeup['skin tone'] == skin_tone) & (makeup['skin type'] == skin_type) & (makeup['label'] == 'primer')].head(2)
|
136 |
+
])
|
137 |
+
|
138 |
+
# Shuffle the DataFrame rows
|
|
|
139 |
dff = dff.sample(frac=1).reset_index(drop=True)
|
|
|
|
|
|
|
140 |
|
141 |
+
# Extract relevant columns and convert to dictionary
|
142 |
+
data = dff[['brand', 'name', 'price', 'url', 'img', 'skin type', 'skin tone']].to_dict('split')['data']
|
143 |
+
|
144 |
+
# Wrap the makeup items into the result list
|
145 |
for element in data:
|
146 |
result.append(wrap_makeup(element))
|
147 |
|
|
|
149 |
|
150 |
|
151 |
|
|