figh8back commited on
Commit
e5e32da
·
verified ·
1 Parent(s): 918cd20

Update backend/models/recommender/rec.py

Browse files
Files changed (1) hide show
  1. backend/models/recommender/rec.py +12 -18
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 the DataFrames
136
- dff = pd.concat([dff, foundation, concealer, primer])
137
-
138
- # Handle the case where no items are found
139
- if dff.empty:
140
- print(f"No makeup items found for skin tone: {skin_tone}, skin type: {skin_type}")
141
- return []
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
- # Wrap each entry in the result using wrap_makeup
 
 
 
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