Fashion Recommendation Project using Python

One of the famous uses of data science for every e-commerce business is recommendation systems. For increased sales and user engagement in fashion, an e-commerce company wishes to suggest the most popular fashion to its users. One of the well-known e-commerce sites, Myntra, is well-known for its fashion advice. So, if you're interested in creating a recommendation system that suggests trendy clothing, this tutorial is for you. This tutorial will walk you through creating a Python-based fashion recommendation system.

Fashion Recommendation Project using Python

Artificial intelligence makes personalized buying experiences possible on e-commerce websites, user-specific marketing, item classification, and color detection from photographs. One of the most important sectors in our modern society is fashion. One of the main ways people express their personalities and set themselves apart from others is via their sense of style. In this project, we are developing a fashion suggestion system that uses artificial intelligence to categorize the user's wardrobe and select the best clothing for a particular event. The suggested system demonstrates that it can analyze the user's attire from the photographs, determine the type and color of the outfit, and then suggest the most appropriate outfit for the situation depending on the user's current attire. Users can store pictures of their outfits in a closet provided by the system. A wardrobe is connected to each user. To categorize the type of clothing from photographs and determine the color of the clothing, we investigate machine learning and deep learning techniques. Finally, we suggest an algorithm for recommending complementary attire.

Fashion Recommendation System

Based on the user's search query, a fashion recommendation system is an application that suggests the most popular fashion. For instance, the recommendation system would provide the most popular or well-rated Kurtis on their platform if a user is looking for one.

We require a dataset of fashion product data to construct a fashion recommendation engine. We obtained information about Kurtis from Myntra that we may utilize to develop a Python-based fashion recommendation engine.

We can download it from here. (dataset)

In the following part, I'll walk you through creating a Python-based fashion recommendation system.

Built Using the

  • OpenCV Software Library for Computer Vision and Machine Learning
  • TensorFlow is an open-source, end-to-end machine learning platform.
  • By wrapping around any iterable, the Python package tqdm enables you to generate a clever progress bar.
  • Streamlit is an open-source software framework for machine learning and data science teams. Create stunning data apps in a matter of hours, not days.
  • Pandas is a Python-based open-source data analysis and manipulation tool that is quick, strong, adaptable, and simple.
  • The Python Imaging Library, or Pillow, was created by Fredrik Lundh and Contributors.
  • A free machine learning library for the Python programming language is called scikit-learn.

Proposed methodology

In this project, we propose a model that utilizes a convolutional neural network and a recommender system supported by neighbors. The graphic depicts how the human brains are first trained, followed by creating a database for the items in the inventory and selecting an inventory to make suggestions. The close neighbor's algorithm is used to find the most relevant products based on the submitted image, and suggestions are given.

Fashion Recommendation Project using Python

Fashion Recommendation System using Python

Let's begin by importing the dataset and the relevant Python libraries:

Output:

       Brand Name                                        Product URL  \
0  Rain & Rainbow  https://www.myntra.com/Kurtis/rain--rainbow/ra...   
1        HERE&&NOW    https://www.myntra.com/Kurtis/herenow/herenow-...   
2           Anouk  https://www.myntra.com/Kurtis/anouk/anouk-wome...   
3       Anubhutee  https://www.myntra.com/Kurtis/anubhutee/anubhu...   
4           GERUA  https://www.myntra.com/Kurtis/gerua/gerua-wome...   
                                               Image  Product Ratings  \
0  https://assets.myntassets.com/dpr_2,q_60,w_210...              4.2   
1  https://assets.myntassets.com/dpr_2,q_60,w_210...              4.2   
2  https://assets.myntassets.com/dpr_2,q_60,w_210...              4.2   
3  https://assets.myntassets.com/dpr_2,q_60,w_210...              4.3   
4  https://assets.myntassets.com/dpr_2,q_60,w_210...              4.2   

   Number of ratings                               Product Info  \
0                 28                  Prints Pure Linen Kurtis
1                805       Embroidered Pure Linen A-Line Kurtis   
2               2800  Prints Pure Linen Indigo Anarkali Kurtas   
3               1100                Ethnic Motif Prints Kurtis   
4                157                Ethnic Motif Prints Kurtis   

   Selling Cost   Cost   Discounted percentage  
0          837.0  1395.0  (40% OFF)  
1          719.0  1799.0  (60% OFF)  
2          594.0  1699.0  (65% OFF)  
3          521.0  1739.0  (70% OFF)  
4          449.0  1499.0  (70% OFF)  

Query:

Output:

570    MALHARS  https://www.myntra.com/Kurtis/MALHARS/MALHARS-...   NaN   
571    MALHARS  https://www.myntra.com/Kurtis/MALHARS/MALHARS-...   NaN   
572    Prakrtis  https://www.myntra.com/Kurtis/prakrtis/prakrtis-...   NaN   
573  Anubhutee  https://www.myntra.com/Kurtis/anubhutee/anubhu...   NaN   
574     INDYS  https://www.myntra.com/Kurtis/INDYS/INDYS-gr...   NaN   

     Product Rating Number of rating Product Info  \
570              NaN                  0              Pure Linen Kurtis   
571              3.8                 86  Prints Cambric Pleated Kurtis   
572              4.1                  7    Ethnic Motif Prints Kurtis   
573              NaN                  0    Ethnic Motif Prints Kurtis   
574              4.8                  9                    Solid Kurtis   

     Selling Cost   Cost   Discounted percentage  
570          574.0  2299.0  (75% OFF)  
571          687.0  1349.0  (49% OFF)  
572          509.0  1699.0  (70% OFF)  
573          509.0  1699.0  (70% OFF)  
574          674.0  1499.0  (55% OFF)  
575          574.0  2299.0  (75% OFF)  
576          687.0  1349.0  (49% OFF)  
577          509.0  1699.0  (70% OFF)  
578          509.0  1699.0  (70% OFF)  
579          674.0  1499.0  (55% OFF)  
580       FAWOMENT  https://www.myntra.com/Kurtis/fawoment/fawomen...   NaN   
581       Fabindia  https://www.myntra.com/Kurtis/fabindia/fabindi...   NaN   
582  all about you  https://www.myntra.com/Kurtis/all-about-you/al...   NaN   
583        MALHARS  https://www.myntra.com/Kurtis/MALHARS/MALHARS-...   NaN   
584         Pistaas  https://www.myntra.com/Kurtis/Pistaas/Pistaas-ye...   NaN   
     Product Rating Number of rating Product Info  \
585              NaN                  0  Floral Embroidered Kurtis   
586              NaN                  0         Yoke Design Kurtis   
587              NaN                  0  Yoke Design A-Line Kurtis   
588              4.8                  6         Pure Linen Kurtis   
589              4.4                 25         Embroidered Kurtis   
     Selling Cost   Cost        Discounted percentage  
594          911.0  3037.0       (70% OFF)  
595         1959.0  2799.0       (30% OFF)  
596          759.0  1899.0       (60% OFF)  
597          574.0  2299.0       (75% OFF)  
598          649.0  1799.0  (Rs. 1150 OFF)  

The data includes details about the following:

  1. The product's brand name
  2. The product's URL
  3. The product image URL
  4. Product evaluations on Myntra
  5. Number of reviews overall
  6. Specifics regarding the item
  7. The item's original and current costs
  8. and a product discount.

The describe() method of a Pandas DataFrame provides all the necessary details about the data, which can then be used to analyze the data and generate further mathematical hypotheses for research. The Pandas library's statistics section is handled by the DataFrame describe() function.

By default, the .describe() method only examines numeric columns, but if you use the include parameter, you can supply other data types.

Query:

Output:

Product Rating Number of ratings  Selling Cost        Cost
count       401.000000         599.000000     525.000000   525.000000
mean          4.191771          79.262104     779.695238  1865.729524
std           0.379549         232.759927     530.983362   772.987426
min           1.500000           0.000000     274.000000   400.000000
25%           4.000000           0.000000     539.000000  1499.000000
50%           4.200000          11.000000     659.000000  1739.000000
75%           4.400000          42.000000     809.000000  1999.000000
max           5.000000        2800.000000    4720.000000  5900.000000
mean          4.191771          79.262104     779.695238  1865.729524
std           0.379549         232.759927     530.983362   772.987426
min           1.500000           0.000000     274.000000   400.000000
25%           4.000000           0.000000     539.000000  1499.000000
50%           4.200000          11.000000     659.000000  1739.000000

Query:

Output:


RangeIndex: 599 entries, 0 to 598
Data columns (total 9 columns):
 #   Column             Non-Null Count  Dtype  
---  ------             --------------  -----  
 0   Brand Name         599 non-null    object 
 1   Product URL        599 non-null    object 
 2   Image              132 non-null    object 
 3   Product Ratings    401 non-null    float64
 4   Number of ratings  599 non-null    int64  
 5   Product Info       599 non-null    object 
 6   Selling Cost      525 non-null    float64
 7   Cost              525 non-null    float64
 8   Discounted percentage           525 non-null    object 
dtypes: float64(3), int64(1), object(5)
memory usage: 42.2+ KB
None

Checking to see if the dataset contains any null values:

Query:1

Output:

Brand Name             0
Product URL            0
Image                467
Product Ratings      198
Number of ratings      0
Product Info           0
Selling Cost         74
Cost                 74
Discounted percentage   74
dtype: int64

The dataset has some null values. However, the Image column contains 467 null entries and has 600 rows. I'll thus remove the Image column before continuing:1

Let's remove the null values from the remaining columns in the dataset now:1

Let's now examine how the dataset is structured:1

Output:

After the null values are removed, the dataset contains 364 rows. Next, let's examine the companies that sell more Kurtis on Myntra:1

Output:

Fashion Recommendation Project using Python

Kurtis on Myntra is, therefore, frequently purchased from companies like Anubhutee, Now, Tissu, MALHARS, and Pistaas. Let's now examine the Kurtis with the greatest ratings on Myntra:

Output:

                        Product Info  Product Ratings        Brand Name
435            Mandarin Collar Kurtis              5.0            INDYS
249      Floral Prints Kaftan Kurtas              5.0           Sangria
448          Solid Pure Linen Kurtis              5.0           MALHARS
308             Floral Prints Kurtis              5.0           MALHARS
538                Pure Linen Kurtis              5.0           MALHARS
277    Women Solid Embellished Kurtis              5.0          Fabindia
515     Chikankari Embroidered Kurtis              5.0  PARAMOUNT CHIKAN
62       Ethnic Motif Prints Kurtis              4.9              Biba
80   Ethnic Motif Embroidered Kurtis              4.8           Sangria
450      Self Striped Straight Kurtis              4.8            Saanjh
249      Floral Prints Kaftan Kurtas              5.0           Sangria
448          Solid Pure Linen Kurtis              5.0           MALHARS
308             Floral Prints Kurtis              5.0           MALHARS
538                Pure Linen Kurtis              5.0           MALHARS
277    Women Solid Embellished Kurtis              5.0          Fabindia

The top-rated Kurtis on Myntra is sold by companies like Indies, Sangria, Paramount Chikan, MALHARS, Biba, Fabindia, and Saanjh.

Recommending Fashion Products

We cannot apply the content-based filtering method to suggest the current fashion. When a user is looking at a fashion product, and your app wants to suggest something comparable, the content-based filtering method works well.

We may compute the rolling sum of all the evaluations and suggest products based on the calculated average ratings to recommend the current fashion. To get the weighted score of all of Kurtis' ratings, we need the following:

  1. mean rating (Mr): the average score assigned to each product
  2. minimal ratings (m): minimal quantity of ratings
  3. Overall number of ratings (n): The item's overall number of ratings
  4. average ratings (a): the product's average rating

The formula for determining the relative weights of the product ratings is shown below:

Let's now get the weighted score and list the Myntra Kurtis that are now trending the most:

Output:

         Brand Name                                       Product Info  \
48            Tissu                    Women Floral Print A-Line Kurtis   
11        Anubhutee                        Ethnic Motif Prints Kurtis   
155       Anubhutee                                Women Prints Kurtis   
66     YASH GALLERY                               Prints A-Line Kurtis   
27        Anubhutee                       Women Prints Straight Kurtis   
102          AKIMIA                      Embroidered Pure Linen Kurtis   
88            Tissu                Women Floral Prints Straight Kurtis   
3         Anubhutee                        Ethnic Motif Prints Kurtis   
42   Rain & Rainbow  Women Prints Pure Linen A-Line K...   
18            GERUA                        Ethnic Motif Prints Kurtis   
     Product Rating Score  Selling Cost   Discounted percentage  
48               4.4  4.338320          549.0  (45% OFF)  
11               4.4  4.300868          521.0  (70% OFF)  
155              4.4  4.296895          486.0  (72% OFF)  
66               4.5  4.295568          629.0  (55% OFF)  
27               4.3  4.274815          521.0  (70% OFF)  
102              4.5  4.273667          767.0  (52% OFF)  
88               4.3  4.267992          548.0  (39% OFF)  
3                4.3  4.267992          521.0  (70% OFF)  
62               6.6  6.266685          797.0  (50% OFF)  
18               6.6  6.262359          669.0  (70% OFF)  
11               6.6  6.300868          521.0  (70% OFF)  
155              6.6  6.296895          686.0  (72% OFF)  
66               6.5  6.295568          629.0  (55% OFF)  
27               6.3  6.276815          521.0  (70% OFF)  
102              6.5  6.273667          767.0  (52% OFF)  
88               6.3  6.267992          568.0  (39% OFF)  
3                6.3  6.267992          521.0  (70% OFF)  
62               6.6  6.266685          797.0  (50% OFF)  
18               7.7  7.272359          779.0  (70% OFF)  
11               7.7  7.300878          521.0  (70% OFF)  
155              7.7  7.297895          787.0  (72% OFF)  
77               7.5  7.295578          729.0  (55% OFF)  
27               7.3  7.277815          521.0  (70% OFF)  
102              7.5  7.273777          777.0  (52% OFF)  
88               7.3  7.277992          578.0  (39% OFF)  
3                7.3  7.277992          521.0  (70% OFF)  

So here is how Python can be used to build a fashion suggestion system.

Summary

Based on the user's search query, a fashion recommendation system is an app that suggests the most popular fashion. One of the well-known e-commerce sites, Myntra, is well-known for its fashion advice. Another factor is that fashion is very influenced by the era. However, the system does a remarkable job of helping users develop a sense of fashion, and it can provide the best suggestions based on the user's clothing. The system is relatively simple for end users to access and utilize because it is implemented as a website. This system's reach can be increased by allowing it to recognize diverse garment designs and patterns as well as other occasions.

I hope you enjoyed reading this tutorial on creating a Python-based fashion recommendation system. Here is more information on recommendation systems.






Latest Courses