<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Christopher Bonnett on Medium]]></title>
        <description><![CDATA[Stories by Christopher Bonnett on Medium]]></description>
        <link>https://medium.com/@c.bonnett?source=rss-f9bee9192cb7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zrJZIEv3zNo2BZ-G.jpg</url>
            <title>Stories by Christopher Bonnett on Medium</title>
            <link>https://medium.com/@c.bonnett?source=rss-f9bee9192cb7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:09:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@c.bonnett/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Classifying e-commerce products based on images and text]]></title>
            <link>https://medium.com/insight-data/classifying-e-commerce-products-based-on-images-and-text-14b3f98f899e?source=rss-f9bee9192cb7------2</link>
            <guid isPermaLink="false">https://medium.com/p/14b3f98f899e</guid>
            <category><![CDATA[insight-data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[insight-ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Christopher Bonnett]]></dc:creator>
            <pubDate>Thu, 05 Jan 2017 18:31:50 GMT</pubDate>
            <atom:updated>2019-11-01T17:35:42.033Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0XqOW8E7JjVN_K1fbAG6VA.jpeg" /></figure><p><a href="https://www.linkedin.com/in/cbonnett"><em>Christopher Bonnett</em></a><em> is an Insight alumnus from the Summer 2016 New York Data Science Fellowship, where he used Deep Learning and NLP to classify e-commerce products for </em><a href="https://www.lynks.com/en/sa"><em>Lynks</em></a><em>. He is now a Machine Learning Researcher at </em><a href="http://www.google.com/url?q=http%3A%2F%2Falpha-i.co%2F&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNEDXQSRQz81ZMwmoPHOP6CZ0fF3BA"><em>alpha-I</em></a><em>.</em></p><p><strong><em>Want to learn about Data Science or applied Artificial Intelligence from top professionals in Silicon Valley or New York?</em></strong><em> </em>Learn more about the <a href="http://insightdatascience.com/">Data Science</a> and <a href="http://insightdata.ai/">Artificial Intelligence</a> programs.</p><p>During my time at <a href="http://insightdatascience.com/">Insight</a> I consulted for a <a href="https://www.ycombinator.com/">Y-combinator</a> startup called <a href="https://www.lynks.com/">Lynks</a>. Lynks enables people in Egypt to ship fashion and fashion-related items from US e-commerce stores to their homes in Egypt, a useful service as many US e-commerce websites do not take orders from abroad. Lynks buys products from any e-retailer on behalf of customers through their “universal shopping cart” and ships that inventory to the Lynks warehouse in Delaware. From there, Lynks consolidates orders and ships completed ones to the end customer.</p><p>Other than the couple of days that products pass-through Lynks warehouse, Lynks doesn’t store inventory, so its theoretical product list is the combination of all US based e-commerce stores. All these products that are ordered are <strong><em>currently classified by hand</em></strong>. To assist in automating this task, I built a prototype pipeline for Lynks.</p><h3>Digging into the Data</h3><p>The data currently collected for each product is an image and a short description of the item. Here are two typical examples, along with the assigned labels Lynks uses:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*PMe_sRyd9Ni5uUq3KmGRww.jpeg" /></figure><p>As you can see, the both the image and text data can be quite varied. For the images, items can appear in many different poses or even on or off human models. Likewise the text can come in many forms, has varying levels of detail, and may contain brand names or unique descriptors. This variation presents quite a challenge, which we will keep in mind when construction our solution below.</p><p>The goal of this project is straightforward: Given an image and a short description, predict the label Lynks’ team would assign. However, what is not straightforward is the hierarchical structure of the item label. In principle, building a model which can understand and use this structure should result in better performance. Given we are building a prototype, I decided to ignore this structure and assume label independence. In other words, our model will try to predict “Clothing&gt;&gt;Women&gt;&gt;Top” without knowing its close relation to “Clothing&gt;&gt;Men&gt;&gt;Top”. While not ideal, this greatly simplifies the approach and allows for more rapid iteration.</p><p>In total, this approach results in 99 unique class labels. These classes are quite unbalanced, with many labels having only a few examples. For this prototype I will just work with the top 10 classes, covering 50% of the number of products. Unlike the others, these top 10 classes have lots of examples and more equally distributed, allowing us to more easily build an effective solution.</p><h3>Choosing the right model</h3><p>My goal is to combine the text and image into a single machine learning model, since they contain complementary information. There are many different forms such a model could take. Ultimately I settled on a model that is flexible, but still easy enough for Lynks to implement in their workflow.</p><h4>Extracting information: Images</h4><p>Understanding the content of images is hard, even more so when the images vary significantly. Currently, the best machine learning models for classifying images are <a href="https://en.wikipedia.org/wiki/Convolutional_neural_network">convolutional neural networks</a> (CNNs). These powerful neural networks are <em>the</em> leading model for image recognition, pushing state-of-the-art accuracy to <a href="http://karpathy.github.io/2014/09/02/what-i-learned-from-competing-against-a-convnet-on-imagenet/">human level performance</a> and beyond.</p><p>Training CNN architectures is hard — it typically takes lots of computing power and massive amounts of data to train a good model. Although our data set is not tiny (~5000 images in the training set) it can hardly be compared to <a href="http://image-net.org/">Image-Net</a> data set containing 1.2 million images across 1000 classes. For this reason it make sense to leverage the power of a pre-trained network that has been trained on Image-Net, since it already has the capability of extracting useful features for natural images.</p><p>Leveraging a pre-trained machine learning model is called transfer learning. The underlying idea behind transfer learning is quite simple. One takes a well trained model from one dataset or domain, and applies it to a new one. I won’t go in detail on how to use transfer learning in practice, but <a href="https://twitter.com/fchollet">François Chollet</a> has written a <a href="http://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html">very comprehesive guide to transfer learning</a>. Like his post, I used the François’ <a href="https://keras.io/">Keras</a> Deep Learning library for which a pre-trained VGG-16 convolutional network is available. This is a sensible choice, as <a href="https://arxiv.org/abs/1409.1556">VGG CNN</a> architecture won the Image-Net challenge in 2014 and ought to provide good performance.</p><h4>Extracting information: Text</h4><p>Processing text data is relatively simple compared to the images. As a stand alone approach, using a simple <a href="http://scikit-learn.org/stable/modules/feature_extraction.html#the-bag-of-words-representation">bag of words model</a> with <a href="https://en.wikipedia.org/wiki/Logistic_regression">logistic regression</a> will be sufficient given that the mere presence of a word is very informative.</p><p>However, the information content of the text varies quite widely. In some cases, the item can be classified accurately using the text alone (e.g., ‘men’s shirt’) while in other (rarer) cases, the text will not be as informative. For example, a description like “bronx 84 graphic t” might be difficult to classify as a male or female-oriented product since the text does not contain any gender information. Having said that, in most cases we can expect the text to be very informative and together with the images, good general performance seems reasonable.</p><h4>Tying it together</h4><p>For the final model, I created a neural network that has a convolutional branch one on side while the other branch processes vectorized words:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*oiLg3C3-7Ocklg9_xubRRw.jpeg" /><figcaption>Combined image + text model for Lynks. The part of the model (left side here) uses a convolutional neural network to process the images, while the rest processes the bag-of-words text. The two are combined for the final classification (bottom).</figcaption></figure><p>The VGG convolutional network provides the computer vision processing of the images (left above), while simple fully-connected neural networks process the text (right above). The last layer of neurons is simply the combination from both parts of the model, and is used to produce the final classification.</p><h3>Performance</h3><p>Above I explained that I would like to use a neural network architecture that utilizes both images and text. This combined model is larger and a bit more complex than ones that focus solely on text or images. In order to understand and justify the performance gains of the model, it makes sense to look at each component separately and compare them to the final model:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*DWNEttNHkQnyVEIZ6mUHtA.png" /><figcaption>Performance accuracy using text only, images only, or both combined.</figcaption></figure><p>This is quite interesting. The text-only analysis is slightly better than the image-only analysis (while at the same time being a lot cheaper to compute). However, it is striking that the images alone can also deliver good classifications. Given the two are competitive in performance, it is clear that the combination of both the images and the text should lead to increased performance since they presumably are picking up on different things. Indeed, when we look at the combined model performance we see a significant boost in accuracy.</p><p>To arrive at a final solution for Lynks, I explored varying the number of layers and hidden units in the model. In addition, one final way to optimize our model is try to find convolutional filters that are better suited for the task at hand. The pre-trained VGG network used here was trained on 1000 classes of images in Image-Net, none of which are clothing or fashion items. To customize this for e-commerce data, it makes sense to adjust the last few convolutional layers to taylor the learned features to the training set. This process is called fine tuning. I opted for fine-tuning the last 3 convolutional layers, here are the results.</p><p>The fine tuning brought another 1% in accuracy, resulting in our best model delivering 94% accuracy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*IetzO7M8ketN_5YR6rAXhQ.png" /></figure><h3>Final Thoughts</h3><p>It was really fun to explore different ways one might combine image and text data in the e-commerce space. I found the diversity in the data quality (size/shape of images) and context (variation of text descriptions and images) challenging to handle and incorporate into an analysis pipeline. In the end, the model I produced helped to significantly reduce the required person-power needed for Lynk’s workflow. Combined with advice on handling non-top-10 classes (not discussed here), Lynks was pleased with the results and is currently incorporating this into their production pipeline.</p><p><em>For additional technical and exploratory details, feel free to visit the </em><a href="http://cbonnett.github.io/Insight.html"><em>original version here</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14b3f98f899e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/insight-data/classifying-e-commerce-products-based-on-images-and-text-14b3f98f899e">Classifying e-commerce products based on images and text</a> was originally published in <a href="https://medium.com/insight-data">Insight</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>