<?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 Tobia Albergoni on Medium]]></title>
        <description><![CDATA[Stories by Tobia Albergoni on Medium]]></description>
        <link>https://medium.com/@tobia.albergoni?source=rss-3490e25aecfa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MuTm8yTq1R2UeulhP82yDA.jpeg</url>
            <title>Stories by Tobia Albergoni on Medium</title>
            <link>https://medium.com/@tobia.albergoni?source=rss-3490e25aecfa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 23:49:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tobia.albergoni/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[A personalized ranking, content-based approach to model digital media]]></title>
            <link>https://medium.com/elca-it/a-personalized-ranking-content-based-approach-to-model-digital-media-60c2f8dbfa57?source=rss-3490e25aecfa------2</link>
            <guid isPermaLink="false">https://medium.com/p/60c2f8dbfa57</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[recommendation-system]]></category>
            <category><![CDATA[media-bias]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[bayesian-optimization]]></category>
            <dc:creator><![CDATA[Tobia Albergoni]]></dc:creator>
            <pubDate>Wed, 19 Jan 2022 11:11:09 GMT</pubDate>
            <atom:updated>2022-02-04T14:43:29.340Z</atom:updated>
            <content:encoded><![CDATA[<p>As news reports possess the power to influence and alter our perception of world events, our information consumption choices are really important. The rise of digital media and the abundance of sources has recently increased the difficulty of these choices. The development of new media monitoring methods is important to increase awareness about the widespread media bias, which is not objectively or easily quantifiable by humans.</p><p>For these reasons, we developed <em>News Cracker</em>, a novel embedding method for digital news sources. <em>News Craker </em>is the outcome of my Master&#39;s Thesis, which was conducted at <a href="http://www.elca.ch/">ELCA</a> in collaboration with the <a href="https://www.epfl.ch/labs/lsir/">LSIR</a> EPFL laboratory. It learns a latent representation space for news outlets to highlight similarities based on the content they produce. The method also exposes hidden higher-order patterns which reflect editorial guidelines and ideological alignment trends.</p><p>We will first present the key intuition behind <em>News Cracker: </em>approaching the subject as a personalized ranking problem, like a recommender system. We will then showcase the optimization criterion, the architecture of the model, and its performance. Lastly, the second half of the article is dedicated to the analysis of the obtained embedding space, including an evaluation of <em>News Cracker</em> as a classifier for ideological alignment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ku4hXp96Q3ybt34y" /><figcaption>Photo by <a href="https://unsplash.com/@obionyeador?utm_source=medium&amp;utm_medium=referral">Obi Onyeador</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>A personalized ranking problem</h3><p>The key idea is to have our model learn the implicit content-publishing preferences of news sources through a personalized ranking approach. We assume that lexical and semantic choices in articles implicitly reflect an interest towards them from the sources, which end up using them frequently. In other words, a source “prefers” one of their own articles (<em>aⱼ</em>) over an article from another news outlet (<em>aₖ</em>).</p><p>This modeling approach is akin to what recommendation systems do, where “users” (sources) implicitly express their preference towards an “item” (article) by buying it. Formally, this problem is an instance of <a href="http://www.rongpan.net/publications/pan-oneclasscf.pdf">One-Class Collaborative Filtering (OCCF)</a> from implicit feedback, with dyadic interactions of the form “source <em>sᵢ</em> has published article <em>aⱼ”</em></p><p>We want to optimize the representations of the sources by learning to produce an accurate total ordering of articles &gt;<em>sᵢ </em>for each publisher, where</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/84/1*U95cAjha55NeFhiyuB3fng.png" /></figure><p>means that source <em>sᵢ</em> prefers article <em>aⱼ </em>over article <em>aₖ.</em></p><p>This approach is heavily inspired by the work of D. Bourgeois and J. Rappaz <a href="https://arxiv.org/pdf/1904.07536.pdf">Selection Bias in News Coverage: Learning it, Fighting it</a>, where they employ the same personalized ranking idea to capture the latent structure of media’s decision process regarding event coverage. They show a worrisome coverage convergence trend following channel acquisitions from large media conglomerates.</p><h3>The News Cracker source embedding method</h3><p>To learn our source-embeddings, we employ the <a href="https://arxiv.org/ftp/arxiv/papers/1205/1205.2618.pdf">Bayesian Personalized Ranking</a> (BPR) loss. It is a pairwise approach where the model is presented with triplets <em>(sᵢ , aⱼ , aₖ )</em> sampled uniformly at random from the article corpus, where <em>s</em>ᵢ is a random source from the source set <em>S</em>, <em>a</em>ⱼ is an article published by <em>sᵢ</em> (positive sample) and <em>a</em>ₖ is an article not published by <em>sᵢ </em>(negative sample).</p><p>In BPR, we maximize the following posterior probability over the training set of such triplets, where <em>Θ</em> are the parameters of an arbitrary ranking model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*GpXbCJRBqEk036br9MvEoQ.png" /></figure><p>Concretely, we can compute the right-hand side of the formula thanks to a source-article interaction model (ranking model) which produces real-valued scores</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/47/1*q60gzBha4XUbzEzisFdCRw.png" /></figure><p>that represent the likelihood of source <em>sᵢ </em>publishing article <em>a</em>ⱼ. With the likelihood score from the ranking model, we can define</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*IrY-h_gKXqS-Bc8hK-AJag.png" /></figure><p>where <em>H(.)</em> denotes the <a href="https://en.wikipedia.org/wiki/Heaviside_step_function">Heaviside step function</a> and σ the <a href="https://en.wikipedia.org/wiki/Sigmoid_function">sigmoid function</a>. Finally, with a Gaussian prior on <em>Θ, </em>we obtain the following criterion to maximize</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*S4Coz3-EjOq4wXCtS_7FWQ.png" /></figure><p>This approach is clarified in the following diagram. Our source vectors <em>sᵢ </em>are initialized at random and optimized through BPR-OPT along with all the other parameters of the architecture, which are trained all at the same time (embeddings, article-embedding model, source-article interaction model).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*G9J2q60GcojD34lT61XPNg.png" /><figcaption>The News Cracker source-embedding method. Image by the author.</figcaption></figure><h3>Text representations and ranking model</h3><p>We obtain the likelihood scores from the source-article interaction model. First, we embed the articles through an LSTM-based architecture that combines word-embeddings learned through <a href="https://fasttext.cc/">FastText</a>. We maintained the article-embedding model relatively simple on purpose (no transformers), in order to more closely model individual lexical choices, as one of the goals of the project was to understand whether these choices would induce enough separation between source representations. With this article-embedding model, we obtain article representations <em>a</em>ⱼ.</p><p>These representations are used in a ranking model that we define as the <em>source-article</em> interaction model, which outputs the likelihood of the article being published by source <em>sᵢ. </em>For this part, we experimented with latent factor models like matrix factorizations, as they are a traditional approach to personalized ranking problems, but they didn’t yield the desired results. We hence decided on a feedforward neural network architecture that, given the source vector (<em>sᵢ</em>) and an article representation (<em>aⱼ</em>), learns to output a likelihood score that maximizes the BPR-OPT criterion presented above. In doing so, and since the article representation <em>aⱼ</em> is given by the article embedding model, we can learn the source vectors <em>sᵢ</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*7ebPVkIvXrzbA6iki5m9ow.png" /><figcaption>The source-article interaction model architecture (ranking model). Image by the author.</figcaption></figure><h3>Dataset and model evaluation</h3><p>The article corpus used during this project was collected in the context of the <a href="https://www.media-initiative.ch/project/media-observatory-initiative/">Media Observatory Initiative</a> and consists of titles and bodies of articles (in English) scraped from a large number of news outlets on the web, based all around the world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*pM_ueFee85HHucdp_-suKg.png" /></figure><p>In order to evaluate the <em>News Cracker </em>model, we adopted a leave-5-articles-out methodology. For each of the 446 sources, we selected 5 articles at random to be kept out and used as positive samples in testing triplets, which result in a test set composed of 2&#39;230 samples. From the remaining articles, we sampled 2&#39;000&#39;000 triplets, uniformly at random, to make up our training set. From the same pool of articles as the training set, we sampled 5 pairs of training/validation sets with the same methodology (leave-5-out and 2 million training triplets) to have a more robust assessment of results.</p><p>In terms of metrics, we use a formulation of the Area Under the ROC Curve (AUC) which is specific for this pairwise setting and can also be referred to as “pairwise accuracy”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*8BCBiZZGGw-36X9PbQar6Q.png" /></figure><p>The model achieves <strong>0.94 test AUC</strong> and <strong>0.93 validation AUC</strong>, proving to be extremely good at learning this personalized ranking task.</p><h3>Analyze the embedding space</h3><p>After learning the source-embeddings (dimensionality 100), we need analysis and visualization methods to interpret our results. First, we computed the cosine similarity between embeddings as a measure of source similarity, to identify the closest neighbors. Second, to visualize the space, we applied the <a href="https://lvdmaaten.github.io/publications/papers/JMLR_2008.pdf">T-distributed Stochastic Neighbor Embedding</a> (t-SNE) dimensionality reduction technique to project the embeddings to a bi-dimensional space, in which we applied the DBSCAN clustering algorithm to obtain groups of sources. The resulting space and clusters are depicted in the following plot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*iwCTOMUj0RNhBdNGxqruuA.png" /><figcaption>The source-embedding space learned by News Cracker on our article corpus. Image by the author.</figcaption></figure><p>We now show that the model is able to easily capture three factors that characterize a source:</p><ul><li>Geography</li><li>News organizations/conglomerates</li><li>Domain/editorial guidelines</li></ul><p>We state that most of the regions of the space identified by DBSCAN can be described by one of these clustering factors.</p><p>The plot below has been annotated with respect to the geographical location of sources. It is a trivial distinguishing factor that we expect to find, as local entities (places, people, …) are frequently mentioned only by news sources from the same area. These lexical “choices” cause the source embeddings to be really similar, which proves that our embedding method is learning as intended. We can see that grouping happens at different geographical levels, from macro-regions down to individual cities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*4bczKsy6lw7UN6kggv3EDw.png" /><figcaption>The source-embedding space, annotated for geography. Image by the author.</figcaption></figure><p>The second factor is source ownership/brand membership. If we look at the closest neighbors of a few sources, we see a clear trend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*ECMF9uheMtZmaI5UMGf8UQ.png" /><figcaption>The three closest source embeddings for some selected news outlets. Image by the author.</figcaption></figure><p>Sources from the same brand/organization tend to have very similar embeddings, forming groups of closely grouped neighbors. We can identify these subclusters in the space within location-based groups, as the annotated plot below shows. This shows that the algorithm can learn structure that goes beyond expected content differences and finds high-level patterns in the news landscape.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*lq47ueYAS7TGHo7PNPjN0A.png" /><figcaption>The source-embedding space, annotated for organizations. Image by the author.</figcaption></figure><p>The third and last clearly distinguishable factor is represented by the source domain. We can see below that clusters arise for sources reporting about the entertainment business, science&amp;nature, finance, think tanks, etc. It should come as no surprise now that <em>News Cracker</em> is equally able to group together sources with similar editorial guidelines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*68Pxf7NbrcxFyBBY2u7ILg.png" /><figcaption>The source-embedding space, annotated for the domain. Image by the author.</figcaption></figure><p>The embedding space seems to have a hierarchical structure. Geography represents the upper-level factor according to which sources are distributed on the projection plane. Then, for regions where we have numerous outlets (mainly the U.S.), the other two clustering factors (brand/organization and domain/editorial guidelines) form most of the remaining structure, producing source sub-clusters with clear semantics.</p><h3>What about media bias?</h3><p>While this analysis is interesting, we want to assess whether the approach is able to capture non-trivial structure in the news ecosystem and relate sources that share similar ideological/political stances about world events. We remind that the approach is completely unsupervised in terms of media bias prediction and the model is free of any potentially bias-inducing design.</p><p>To determine whether some of the insights align with known political leanings, we collect explicit bias ratings for 123 of our U.S. sources from the <a href="https://www.allsides.com/unbiased-balanced-news">AllSides Media Bias Ratings</a>. This rating labels over 600 online news sources, almost exclusively from the United States, employing a sound methodology to produce the rating for each source. Additionally, the ratings are to some extent community-driven. It is the ideal type of data to compare to our purely data-driven results. The news outlets are labeled with one of five ratings: Left, Lean Left, Center, Lean Right, Right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*2jEg0Mq42gZPCX7dMp54_Q.png" /><figcaption>The media bias ratings collected from AllSides for 123 of our sources. Image by the author.</figcaption></figure><p>We plot the subset of (now labeled) sources on our projection plane and color code them according to their media bias rating.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*c4d-W3d5UT6VbFeTR42XLg.png" /><figcaption>Subset of U.S. news sources for which we collected an explicit media bias rating. Image by the author.</figcaption></figure><p>At first view, there is not a super clear structure revolving around the bias ratings, but there are still many regions of the space where <em>some</em> same-label groups/regions appear. Therefore, to see whether <em>News Cracker</em> has actually learned something about ideological leaning, we use this dataset of 123 labeled sources and their projected embeddings to evaluate a majority-voting Nearest Neighbor classifier (k=12). On the task of predicting the exact label (5 classes), the model achieves <strong>52.03% accuracy</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*aaQ6ug2U9RCKPldjcVWy6w.png" /><figcaption>Confusion matrix and performances of the kNN classifier trained on sources labeled with bias ratings. Image by author.</figcaption></figure><p>Even though this is not impressive, from the confusion matrix we can see the model is making reasonable predictions and mostly confusing labels which are adjacent in the political spectrum (ex: Left and Lean Left). Since such a discretization of the continuous ideological spectrum is arbitrary, we evaluate the model on the binary task of predicting whether a source leans left or right (for this, we discard the 11 sources labeled as “Center”). For this task, the classifier achieves<strong> 78.25% accuracy</strong>. In other words, given a source, our embedding space can help identify the correct (according to AllSides) leaning for almost 4 out of 5 news sources. We need to reiterate how hard this task is, even for humans. This kind of performance is therefore noteworthy and surprising, considering the unsupervised nature of our model.</p><h3>Conclusions</h3><p>With <em>News Cracker</em>, we propose a novel embedding method for online news sources. We model each news source by learning its latent content preferences, an approach that allows us to identify similar sources with respect to the news reports they choose to publish. The analysis of the embedding space indicates that News Cracker is capable of successfully identifying many factors that distinguish news sources. The embeddings seem to capture to some extent the ideological leaning of news sources in certain regions of the space. This media bias prediction task is extremely difficult even for humans. Overall, we can conclude it is possible to capture source preferences that lead to bias-related considerations, even with a model that does not push any explicit definition of ideological bias.</p><p><a href="https://news-cracker-demo.azurewebsites.net/">Explore the embedding space through this demo interface!</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3-dCvxEIczTMXLoqFvk3PQ.png" /><figcaption>The interactive Plotly dashboard we prepared to inspect the embedding space in detail. Image by author.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60c2f8dbfa57" width="1" height="1" alt=""><hr><p><a href="https://medium.com/elca-it/a-personalized-ranking-content-based-approach-to-model-digital-media-60c2f8dbfa57">A personalized ranking, content-based approach to model digital media</a> was originally published in <a href="https://medium.com/elca-it">ELCA IT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tip and tricks for building a price estimation model for used cars]]></title>
            <link>https://medium.com/data-science/tip-and-tricks-for-building-a-price-estimation-model-for-used-cars-ac0953e194c4?source=rss-3490e25aecfa------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac0953e194c4</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[used-cars]]></category>
            <category><![CDATA[price-prediction]]></category>
            <category><![CDATA[gradient-boosting]]></category>
            <category><![CDATA[transfer-learning]]></category>
            <dc:creator><![CDATA[Tobia Albergoni]]></dc:creator>
            <pubDate>Sun, 16 May 2021 16:23:19 GMT</pubDate>
            <atom:updated>2022-02-04T15:57:03.094Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tips and tricks for building a price estimation model for used cars</h3><h4>Challenges and solutions for creating a robust machine learning prediction model for car prices</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UYzAaVXN41VGTwnE" /><figcaption>Photo by <a href="https://unsplash.com/@campful?utm_source=medium&amp;utm_medium=referral">Campbell</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Recently, I’ve published a short <a href="https://medium.com/elca-data-science/building-a-robust-price-prediction-model-for-used-cars-da1ce2643cbe">Medium story</a> in which I presented the motivations, goals, and challenges that prompted the <a href="https://www.elca.ch/en?gclid=CjwKCAjw2bmLBhBREiwAZ6ugowuw0ITiAetPePNudMPfMl4RJRN8Z96E8W37wlcduKU7vlWcg_zXbRoCHnQQAvD_BwE">ELCA </a>Data Science team to develop a machine learning (ML) model to accurately estimate the price of used cars on the Swiss market. The price prediction task has always gathered considerable attention from the machine learning community, and the rise of online marketplaces for all kinds of used objects has increased the need for automated tools to accurately predict reasonable price tags.</p><p>In this note, I will briefly present the architecture of our model, along with some strategies we employed to tackle the following key challenges:</p><ul><li>How to handle and encode <strong>categorical variables</strong> in this setting,</li><li>How to make up for<strong> an insufficient number of data samples</strong> for car models</li><li>How to implement an <strong>outlier detection</strong> approach to protect our training process from noisy data.</li></ul><p>In particular, our <strong>cross-market entity-embedding solution</strong> is a <em>transfer learning</em> approach that boosts the predictive accuracy of our model by around <strong>4.3%</strong>.</p><h3>Datasets and task formalization</h3><p>We worked with three distinct car datasets composed of car sale announcements from different Swiss and European digital marketplaces.</p><ul><li>The <a href="https://www.autoscout24.ch/fr"><em>AutoScout24-CH</em></a> dataset contains 119’414 announcements and was used for training and validation purposes.</li><li><em>AutoScout24-DE</em> is a set of 558’295 German sale announcements (extracted from the <a href="https://www.autoscout24.com/">European website version</a>). This larger dataset is used for our transfer learning approach.</li><li>A third Swiss dataset (<a href="https://www.comparis.ch/carfinder/default"><em>Comparis-CH</em></a>, 111’972 samples) is used as the test set, to assess model generalization</li></ul><p>We limit ourselves to a small and simple set of car features, known to the general public and easy to collect for most used cars.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*NXSYnX8F0t943U116XDDbQ.png" /><figcaption>The set of features we adopted as our car modeling approach. Image by author.</figcaption></figure><p>The goal is to perform a standard <em>regression task</em> with this feature set, in which the target quantity is the sale price <em>y_n </em>of car <em>x_n</em> in Swiss francs (CHF), divided by the mean price of the respective car model in the training set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*x0SAgUBQN3omdcJ57VvFoQ.png" /></figure><p>This simple manipulation makes the targets a relative quantity and stabilizes the optimization process. Estimated prices in CHF are obtained by simply scaling back the prediction.<em> Root Mean Squared Erro</em>r (<strong>RMSE</strong>) is the loss function of choice. We report it with respect to the original targets in CHF for interpretability reasons.</p><h3>Model architecture</h3><p>We identified and validated an <strong>XGBoost </strong>regressor as the best model for our prediction pipeline. <a href="https://xgboost.readthedocs.io/en/latest/index.html">XGBoost </a>is a popular and powerful framework that implements the <em>gradient boosting</em> technique. At its core, it’s an <em>ensemble method</em> that combines weak decision trees. All model search and optimization experiments were carried out following standard machine learning procedures, with <strong>10-fold stratified cross-validation</strong> on the <em>AutoScout24-CH</em> dataset. The figure below shows the final prediction pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*8wPVc3b_xMncVV7-RJTLbw.png" /><figcaption>Our price prediction pipeline. Image by author.</figcaption></figure><h3>Encoding categorical variables</h3><p>The manufacturer (<em>maker</em>) and car model (<em>model</em>) features encode most of the available information about the price class of a new car. The datasets contain 37 different car manufacturers and 211 car models. As these are <strong>categorical features</strong> (as opposed to continuous), we need to <em>encode </em>them before we can concatenate them with the remaining features and use them to train a model. The simplest encoding approach is the standard <em>one-hot scheme</em>, where we create as many binary variables as there are classes in each field. This method is almost equivalent to training a different regression model for each class. Given that data is scarce for many car models, this encoding scheme is not enough. A method that maps the variables to a single continuous space is preferable, as it would allow the model to <strong>leverage similarities</strong> between classes.</p><p>A simple representation choice that accomplishes this goal is to represent the categorical variables with two continuous values each: the mean price of the class in the training data, and its standard deviation. Intuitively, this encoding method enriches the car representation vector with approximate information about the starting price and the depreciation range. Nevertheless, it does not offer the possibility to learn more fine-grained details of the depreciation pattern for each car class.</p><p>The <em>Entity Embedding</em> (EE) approach proposed by <a href="https://arxiv.org/abs/1604.06737">C. Guo and F. Berkhan in 2016 </a>and displayed in the schema below is a more involved method, which uses a small <strong>neural network</strong> to learn a mapping from one-hot representations of each variable to a latent representation. This mapping is represented by an encoding <em>EE layer</em> for each variable, whose weights are trained alongside the rest of the model with respect to the price prediction task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*Riek8tDF0Y-gIKaNr4Z1Cw.png" /><figcaption><em>Illustration of entity embedding layers (EE), which correspond to extra layers on top of each one-hot encoded input. Image by </em><a href="https://arxiv.org/abs/1604.06737"><em>C. Guo and F. Berkahn</em></a><em>.</em></figcaption></figure><p>The three encoding approaches provide the following mean validation performances. Variable substitution with mean class price and standard deviation slightly outperforms the EE approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*OohvUrgJDJCA90gE_r0zXw.png" /></figure><h3>Data scarcity: knowledge transfer to the rescue</h3><p>The lack of enough data samples for some car models might explain the disappointing results of the EE method. Some models occur less than 100 times in <em>AutoScout24-CH</em>, which does not allow learning sufficiently precise mappings. Therefore, we train the EE network on the larger <em>AutoScout24-DE</em> dataset, since the German automobile market presents a distribution similar to the Swiss one. The relative distances of car classes in the latent EE space should hence be <strong>transferable</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*EnLFnw8Ahp0E9QgSgEO2ew.png" /><figcaption>Our cross-market entity-embedding approach to overcome the data scarcity problem. EE encoding layers are trained on German data and then transferred to our Swiss model. Image by author.</figcaption></figure><p>This cross-market transfer learning approach provides a performance boost of about <strong>4.3%</strong> on the Swiss RMSE, making the EE approach superior to other encoding schemes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*utgD7mNobjS965ZfPUuzPA.png" /></figure><h3>Train on likely pricing trends: outlier detection</h3><p>Further analysis of the datasets allowed us to realize that sale announcements might not always be a <strong>reliable </strong>ground truth for prices. There is no control or limit on the inaccuracy of a listed price tag, even more so since we do not account for car accessories and many other important car features. There is a clear need to “see through the noise” and train the model only on samples that adhere to a <strong>general pricing trend</strong> for each car manufacturer/model.</p><p>Our solution is to apply a rather aggressive <strong>outlier removal procedure</strong> for each car model separately. We perform density-based outlier detection in three separate bi-dimensional subspaces of the feature-target space: <em>Price-Mileage</em>, <em>Price-Age, </em>and <em>Price-Power. </em>Mileage and age are our two wear level indicators and the two primary causes of depreciation. We also found a non-negligible set of samples for which the price is abnormally high with respect to the listed power class. If a sample is detected as an outlier in any of the three planes, it is removed from the dataset. We use the <a href="https://www.dbs.ifi.lmu.de/Publikationen/Papers/LOF.pdf">Local Outlier Factor (LOF)</a> algorithm to find anomalous data points by measuring their local density deviation with respect to neighbors. The following schema clarifies this approach:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*trzz2Fu3o4cjtTRnw2P9cw.png" /><figcaption>The proposed outlier detection approach, based on the Local Outlier Factor (LOF) method, applied to three different feature-target subspaces. Image by author.</figcaption></figure><p>We remove approximately <strong>12.5% of the training data</strong> and train the entire model on the new datasets (including the German EE layers). This results in the following large boost to performances:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*jP8S5yJb3pHa4wKYz7mKmA.png" /></figure><h3>Results and performances</h3><p>We report both the final validation/test RMSE and <em>Mean Absolute Error</em> (MAE) of our ML model computed on all car models. For the vast majority of cars, the average estimation error is less than <strong>20% of the price variability</strong> for that particular car model in the training data. Given the relative simplicity of our car modeling approach, the performances of our approach are more than satisfactory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*THcMG8RiHtJVOT7c0ZOSAA.png" /></figure><p>Our model can be queried through <a href="https://car-price-demo.azurewebsites.net/">this demo interface</a>. The user can insert the characteristics of the car and obtain a price estimation from the predictor, along with a confidence interval and information about the number of same-model cars that the model has seen during training. We hope that this <strong>quick overview </strong>of our experiments with this task and the <strong>successful solutions</strong> we employed was a helpful read for anyone intending to tackle similar problems from a machine learning perspective.</p><h4>References</h4><ul><li>[1] C. Signer, <a href="https://www.semanticscholar.org/paper/Is-the-Price-Right-Bachelor-thesis-Signer/33d929141ace83bdf34ba0c77201fdd537d1a8d1">Is the Price right?</a> (2016)</li><li>[2] N. Pal et al., <a href="https://arxiv.org/abs/1711.">How much is my car worth? A methodology for predicting used cars prices using Random Fores</a>t (2017)</li><li>[3] K. Noor and S. Jan, <a href="https://www.semanticscholar.org/paper/Vehicle-Price-Prediction-System-using-Machine-Noor-Jan/fc87ead6754b188b1b8629db77badf361fd24a22">Vehicle Price Prediction System using Machine Learning Techniques</a> (2017)</li><li>[4] S. Pudaruth, <a href="https://www.semanticscholar.org/paper/Predicting-the-Price-of-Used-Cars-using-Machine-Pudaruth/dc148913b7271b65d221d2c41f77a9e41750c867">Predicting the Price of Used Cars using Machine Learning Techniques</a> (2014)</li><li>[5] C. Guo and F. Berkhahn, <a href="https://arxiv.org/abs/1604.06737">Entity Embeddings of Categorical Variables</a> (2016)</li><li>[6] M. Breunig, <a href="https://www.researchgate.net/publication/221214719_LOF_Identifying_Density-Based_Local_Outliers">LOF: Identifying Density-Based Local Outliers</a>, (2000)</li><li>[7] T. Albergoni, <a href="https://mojito.switzerlandnorth.cloudapp.azure.com/car-price/">Price prediction for used cars in the Swiss market, demo interface</a> (2020)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac0953e194c4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/tip-and-tricks-for-building-a-price-estimation-model-for-used-cars-ac0953e194c4">Tip and tricks for building a price estimation model for used cars</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a robust price prediction model for used cars]]></title>
            <link>https://medium.com/elca-it/building-a-robust-price-prediction-model-for-used-cars-da1ce2643cbe?source=rss-3490e25aecfa------2</link>
            <guid isPermaLink="false">https://medium.com/p/da1ce2643cbe</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[regression]]></category>
            <category><![CDATA[price-prediction]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Tobia Albergoni]]></dc:creator>
            <pubDate>Wed, 05 May 2021 10:24:39 GMT</pubDate>
            <atom:updated>2022-02-04T15:56:27.628Z</atom:updated>
            <content:encoded><![CDATA[<p>Price estimation models have always gathered considerable attention from the machine learning community. The rise of large online marketplaces for all kinds of used objects has increased the need for automated tools to quickly and accurately predict reasonable price tags. Housing and vehicles are two classic examples of high-value items with complex characterizations that cause non-trivial pricing and depreciation trends. Precise prediction models are extremely valuable to both individuals and businesses and many digital marketplaces are investing heavily in their development, but without disclosing the details. In this short note, we present the motivations and goals of a project where we attempted to develop a <strong>price estimation machine learning (ML) model</strong> for used cars on the Swiss market.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*K8ATeO4AO-Dm4P24Uzjrkw.png" /><figcaption>Our vehicle evaluation tool for the Swiss used cars market</figcaption></figure><h3>Used cars market</h3><p>Car trading gives rise to extremely large and active markets all around the world. With around 4.5 million registered touring cars in 2018 and more than 300’000 new registrations in 2019, Switzerland is no exception, boasting a motorization rate of 543 vehicles per 1’000 inhabitants, higher than the European average. Such a large influx of new cars automatically generates a parallel market of similar magnitude for used vehicles. The car price estimation problem presents itself as a straightforward <em>regression problem</em>. The target quantity is the sale price of a used car, which we want to predict from a set of car features representing either original car characteristics or its wear level. We think that providing consumers with <strong>unbiased and practical tools</strong> to predict the value of their items is a useful contribution to the current ecosystem of digital marketplaces. This is why we developed our machine learning model with this goal in mind and equipped it with a simple user interface.</p><h3>Data collection</h3><p>Obtaining a large volume of data samples is a key challenge for most machine learning projects. Luckily, <strong>digital marketplaces</strong> are rich data sources for used items such as cars, allowing collecting car sale announcements as data samples. While websites differ in the layout and information contained in each offer, the most important car features are always present, along with the current price of the item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*RBPa393FXNvqs5bQ-M5siw.png" /><figcaption>An example of an online car sale announcement found on the AutoScout24 website</figcaption></figure><p>It is generally easy to collect large quantities of these announcements. We automatically collected three datasets:</p><ul><li>The <a href="https://www.autoscout24.ch/fr"><em>AutoScout24-CH</em></a> dataset contains 119’414 car sale announcements.</li><li><em>AutoScout24-DE</em> is a similarly structured set of 558’295 German sale announcements (extracted from the <a href="https://www.autoscout24.com/">European website version</a>).</li><li>A third Swiss dataset from another website (<a href="https://www.comparis.ch/carfinder/default"><em>Comparis-CH</em></a>, 111’972 samples) was collected in a second phase.</li></ul><h3>Challenges</h3><p>The car price estimation problem poses several interesting challenges:</p><ul><li><strong>Item variety and complexity.</strong> The number of different car models produced by manufacturers is quite important and continuously grows larger as new cars are launched every year. Car models evolve, and the same car is available in variants belonging to different power classes, not to mention the huge range of possible options and accessories. There is a high number of factors that contribute to item pricing and it is thus hard to choose a modeling approach.</li><li><strong>The environment evolves rapidly.</strong> Building a predictor that can stand the test of time and not be useful only in a very limited time window is a considerable challenge.</li><li><strong>Imbalanced datasets.</strong> Any car dataset that reflects the distribution of real-world markets will be imbalanced in terms of manufacturers and car models. The scarcity of sale announcements for many types of cars makes it difficult to define a single machine learning model that performs reasonably well for a wide range of car models. Finding ways to leverage similarities between different cars is another necessity of the predictor, especially for smaller markets like the Swiss one.</li><li><strong>Unreliable data.</strong> Digital marketplaces show us the seller’s proposed price. This estimation will in most cases adhere to real market trends and be a reasonable price tag, but we won’t know the final selling price of the item after off-platform negotiations. It is also difficult to detect offers that present large inaccuracies in the estimation process. For these reasons, we should be aware that these crowd-based datasets are inherently noisy. The ML model must hence account for high output variability and outliers.</li></ul><h3>Representation of used cars</h3><p>According to our goal of keeping the model simple and interpretable, we limit ourselves to the following set of car features. The inputs to our ML model consist of cars represented with this information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*TWVcGOSTh0-18ZFQnfbg6A.png" /></figure><h3>Outcomes and price prediction interface</h3><p>Our machine learning price prediction model performs remarkably well if we consider the simplicity of our modeling approach. The <em>mean average error</em> is <strong>2187 CHF</strong>, but this is considering all car models on the market, even luxury and very expensive ones. For the vast majority of cars, the average estimation error is <strong>less than 20% of the price variability</strong> for that particular car model in the training data. <a href="https://mojito.switzerlandnorth.cloudapp.azure.com/car-price/">The following user interface</a> allows interacting with our predictor. The user can insert the characteristics of the car and obtain a price estimation, along with a confidence interval and information about the number of same-model cars that the model has seen during training. Be aware that the model is trained on 2019 data and has not been re-trained or updated since.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*-fuVlNHE1dMDp9YO4YFlWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*K8ATeO4AO-Dm4P24Uzjrkw.png" /><figcaption>At the top, an announcement for an ALFA ROMEO MiTo found on AutoScout24 in March 2021. At the bottom, the prediction obtained through the interface, which in this case is quite accurate.</figcaption></figure><p>Price estimation for complex items such as cars is challenging, mostly because the available data presents some key weaknesses, which require thought-out solutions and a <em>holistic approach</em>. This is especially true for small markets such as the Swiss one, even more so when the goal is to propose a user-friendly price estimation tool. It is desirable to work our way to the best possible results while keeping the feature set small and interpretable for the general public, and this requires refined <strong>data preparation and feature engineering processes</strong>.</p><p>We hope that this quick overview of the car price estimation task and our simple tool was a helpful read for anyone intending to tackle similar problems in the future. The presentation of our full model architecture will be the subject of a future article.</p><h4>Resources</h4><ul><li>Price prediction for used cars in the Swiss market, demo interface: <a href="https://car-price-demo.azurewebsites.net/">https://car-price-demo.azurewebsites.net/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da1ce2643cbe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/elca-it/building-a-robust-price-prediction-model-for-used-cars-da1ce2643cbe">Building a robust price prediction model for used cars</a> was originally published in <a href="https://medium.com/elca-it">ELCA IT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>