Python 服装推荐系统项目

2025年03月17日 | 阅读 9 分钟

数据科学在每个电子商务业务中最著名的用途之一是推荐系统。为了增加销售额和用户参与度,一家时尚电子商务公司希望向其用户推荐最受欢迎的时尚。著名的电子商务网站 Myntra 以其时尚建议而闻名。因此,如果您有兴趣创建一个推荐系统来推荐潮流服装,那么本教程适合您。本教程将引导您完成使用 Python 创建时尚推荐系统。

Fashion Recommendation Project using Python

人工智能使电子商务网站上的个性化购物体验、用户特定营销、商品分类以及从照片中检测颜色成为可能。时尚是我们现代社会最重要的领域之一。人们通过穿着风格来表达个性和与众不同。在这个项目中,我们正在开发一个时尚建议系统,该系统利用人工智能对用户的衣橱进行分类,并为特定场合选择最佳服装。该建议系统表明,它可以分析用户照片中的服装,确定服装的类型和颜色,然后根据用户当前的着装推荐最合适的服装。用户可以将他们的服装照片存储在系统提供的衣橱中。每个用户都有一个衣橱。为了从照片中对服装类型进行分类并确定服装颜色,我们研究了机器学习和深度学习技术。最后,我们提出了一个推荐互补服装的算法。

时尚推荐系统

基于用户的搜索查询,时尚推荐系统是一个建议最受欢迎时尚的应用程序。例如,如果用户正在寻找一件库尔蒂(Kurtis),推荐系统就会提供他们平台上最受欢迎或评价最高的库尔蒂。

我们需要一个时尚产品数据集来构建时尚推荐引擎。我们获取了关于 Myntra 上的库尔蒂的信息,我们可以利用这些信息来开发一个基于 Python 的时尚推荐引擎。

我们可以在 这里 下载。 (数据集)

在接下来的部分,我将指导您完成使用 Python 创建时尚推荐系统。

使用

  • 用于计算机视觉和机器学习的 OpenCV 软件库
  • TensorFlow 是一个开源的端到端机器学习平台。
  • 通过包装任何可迭代对象,Python 包 tqdm 可以为您生成一个智能进度条。
  • Streamlit 是一个开源的软件框架,供机器学习和数据科学团队使用。在数小时内创建令人惊叹的数据应用程序,而不是数天。
  • Pandas 是一个基于 Python 的开源数据分析和操作工具,它快速、强大、灵活且易于使用。
  • Python 图像库 (PIL),或称 Pillow,由 Fredrik Lundh 和 Contributors 开发。
  • scikit-learn 是一个用于 Python 编程语言的免费机器学习库。

建议的方法

在这个项目中,我们提出了一种模型,该模型利用卷积神经网络和基于邻居的推荐系统。该图描绘了人脑如何首先进行训练,然后为库存中的商品创建数据库并选择库存以进行建议。利用最近邻算法根据提交的图像查找最相关的产品,并给出建议。

Fashion Recommendation Project using Python

使用 Python 构建时尚推荐系统

让我们开始导入数据集和相关的 Python 库

输出

       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)  

查询

输出

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)  

数据包含以下详细信息

  1. 产品的品牌名称
  2. 产品网址
  3. 产品图片网址
  4. Myntra 上的产品评价
  5. 总评价数量
  6. 关于商品的细节
  7. 商品的原始价格和当前价格
  8. 以及产品折扣。

Pandas DataFrame 的 describe() 方法提供了有关数据的所有必要详细信息,这些详细信息可用于分析数据并生成进一步的数学假设以供研究。Pandas 库的统计部分由 DataFrame describe() 函数处理。

默认情况下,.describe() 方法仅检查数值列,但如果您使用 include 参数,您可以提供其他数据类型。

查询

输出

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

查询

输出


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

检查数据集是否包含任何空值

查询:1

输出

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

数据集中有一些空值。但是,Image 列包含 467 个空条目,共有 600 行。因此,我将在继续之前删除 Image 列:1

现在让我们删除数据集中其余列中的空值:1

现在让我们检查一下数据集的结构:1

输出

删除空值后,数据集包含 364 行。接下来,让我们检查一下哪些品牌在 Myntra 上销售的库尔蒂最多:1

输出

Fashion Recommendation Project using Python

因此,Myntra 上的库尔蒂经常从 Anubhutee、Now、Tissu、MALHARS 和 Pistaas 等品牌购买。接下来,让我们检查一下 Myntra 上评分最高的库尔蒂。

输出

                        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

Myntra 上评分最高的库尔蒂由 Indies、Sangria、Paramount Chikan、MALHARS、Biba、Fabindia 和 Saanjh 等品牌销售。

推荐时尚产品

我们无法应用基于内容的过滤方法来推荐当前时尚。当用户正在查看时尚产品,而您的应用程序想要推荐类似的产品时,基于内容的过滤方法效果很好。

我们可以计算所有评价的滚动总和,并根据计算出的平均评分推荐产品,以推荐当前时尚。要获得所有库尔蒂评价的加权分数,我们需要以下内容:

  1. 平均评分 (Mr):分配给每个产品的平均分数
  2. 最低评分 (m):最低评价数量
  3. 总评价数量 (n):商品的总体评价数量
  4. 平均评分 (a):产品的平均评分

以下显示了确定产品评分相对权重的公式

现在让我们获取加权分数,并列出 Myntra 上当前最流行的库尔蒂。

输出

         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)  

所以,这就是如何使用 Python 构建时尚推荐系统。

总结

基于用户的搜索查询,时尚推荐系统是一个建议最受欢迎时尚的应用程序。著名的电子商务网站 Myntra 以其时尚建议而闻名。另一个因素是时尚受时代影响很大。然而,该系统在帮助用户培养时尚感方面做得非常出色,并且可以根据用户的着装提供最佳建议。由于该系统被实现为网站,因此最终用户可以相对容易地访问和使用它。通过允许系统识别各种服装设计和图案以及其他场合,可以扩大该系统的覆盖范围。

希望您喜欢阅读这篇关于使用 Python 创建时尚推荐系统的教程。这里有更多关于推荐系统的更多信息。