This is a Flask-based API for providing personalized fashion recommendations for shopping products. The API uses cosine similarity to find the most similar items to a given item.
To use this API, follow the steps below:
- Clone the repository or download the code.
git clone https://github.com/saadkh1/shopping-recommendation-api.git
- Install the required Python packages using pip.
! pip install -r requirements.txt
-
Download the dataset from Kaggle here. Alternatively, The dataset used in this project is available in the dataset.xlsx file, and product images are available in the shopping.zip file provided in this repository.
-
Start the Flask server.
python product_recommender_api.py
After starting the server, you can access the API at http://localhost:5000.
To get the most similar items to a given item, make a GET request to http://localhost:5000/get_similar_items/<item_id>, where <item_id> is the ID of the item you want to find similar items for.
For example, to get the most similar items to item 219075028, make a GET request to 'http://localhost:5000/get_similar_items/219075028'.
The API will return a JSON object containing the IDs of the most similar items.
{
"similar_items": ["219075014", "219075021", "219075017"]
}
To test the recommendation system, use the test.ipynb notebook file. This file demonstrates how to load the dataset, run the recommendation system, and retrieve the list of similar items for a specific item.
Note that the API uses cosine similarity to find the most similar items, so the results may not be perfect. Additionally, the dataset used by the API is from H&M's Personalized Fashion Recommendations competition on Kaggle, so the results may be biased towards H&M products.