Delete app/utils/recommendation.py
Browse files- app/utils/recommendation.py +0 -21
app/utils/recommendation.py
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
from sentence_transformers import SentenceTransformer, util
|
| 2 |
-
|
| 3 |
-
embedding_model = SentenceTransformer("all-MiniLM-L6-v2")
|
| 4 |
-
|
| 5 |
-
def recommend_similar_products(input_ingredients, df_brand, product_embeddings, top_n=3):
|
| 6 |
-
query = " ".join(input_ingredients)
|
| 7 |
-
query_embedding = embedding_model.encode(query, convert_to_tensor=True)
|
| 8 |
-
scores = util.cos_sim(query_embedding, product_embeddings)[0]
|
| 9 |
-
top_results = scores.topk(k=min(top_n, len(scores)))
|
| 10 |
-
|
| 11 |
-
recommended = []
|
| 12 |
-
for idx in top_results.indices:
|
| 13 |
-
row = df_brand.iloc[int(idx)]
|
| 14 |
-
recommended.append({
|
| 15 |
-
"brand": row.get('brand', ''),
|
| 16 |
-
"name": row.get('name', ''),
|
| 17 |
-
"type": row.get('type', ''),
|
| 18 |
-
"ingredients": row.get('ingridients', ''),
|
| 19 |
-
"description": row.get('afterUse', ''),
|
| 20 |
-
})
|
| 21 |
-
return recommended
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|