<?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 Rebours Baptiste on Medium]]></title>
        <description><![CDATA[Stories by Rebours Baptiste on Medium]]></description>
        <link>https://medium.com/@rebours.baptiste?source=rss-95d18c0d8a2f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hKPCrUsvHpRz8MiBGSpQOw.png</url>
            <title>Stories by Rebours Baptiste on Medium</title>
            <link>https://medium.com/@rebours.baptiste?source=rss-95d18c0d8a2f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 14:11:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rebours.baptiste/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[Data-Driven Air Freight: How We Built an Importance Index for Better Zoning]]></title>
            <link>https://medium.com/upply/data-driven-air-freight-how-we-built-an-importance-index-for-better-zoning-2dbf6badca9a?source=rss-95d18c0d8a2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dbf6badca9a</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[air-freight]]></category>
            <category><![CDATA[open-data]]></category>
            <category><![CDATA[logistics]]></category>
            <category><![CDATA[supply-chain]]></category>
            <dc:creator><![CDATA[Rebours Baptiste]]></dc:creator>
            <pubDate>Thu, 26 Feb 2026 13:02:46 GMT</pubDate>
            <atom:updated>2026-02-26T13:02:46.122Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WdCyrIuOVR95YCzRRwzsVw.jpeg" /></figure><p>Upply digitizes the world of transportation and enables its clients to obtain market price estimates, particularly for air freight. To achieve this, an Artificial Intelligence (AI) model, trained on millions of transports, is used. This model returns an estimate for a given origin airport and destination airport. However, clients can choose to provide only cities instead of directly specifying airports. In such cases, it becomes imperative for us to perform zoning to find the most relevant airport based on the provided location. This zoning algorithm is based on both the distance between the city and the airports and their logistical importance.</p><p>We are building an <strong>airport importance index</strong> based on the <strong>methodology</strong> used by the <strong>United Nations Conference on Trade and Development (UNCTAD)</strong> for the <a href="https://unctadstat.unctad.org/datacentre/dataviewer/US.PLSCI">Port Liner Shipping Connectivity Index (PLSCI)</a>. Several factors are taken into account such as the <strong>number of flights</strong>, the <strong>number of aircraft</strong>, and the <strong>number of connected airports for each airport</strong>. This article details our thought process on this subject.</p><h3>Diving into the World of Upply: Data at the Heart of Freight Transportation</h3><h4>Upply: Technology Serving Freight Transport</h4><p>Upply is a digital platform dedicated to professionals in freight transportation and logistics. Thanks to AI models built on a database of millions of transports, it offers various services that allow its clients to compare prices, anticipate market fluctuations, and optimize their costs.</p><p>These clients are key players in the transportation world: shippers (companies looking to transport their goods, such as major retail chains), carriers (companies that move goods for shippers), freight forwarders (specialized intermediaries who plan, optimize, and coordinate the transport of goods on behalf of clients), and even transportation consulting firms. All these actors need to know the market prices in order to position themselves and negotiate effectively. And nothing beats data for that.</p><h4>Data: The Engine Behind Transport Price Prediction</h4><p>Determining the cost of transporting goods involves several factors: the mode of transport, the departure and arrival locations, the transport date… and, of course, all the details about the goods themselves: weight, volume, content, etc. Upply’s AI models learn from this variety of data, identify the decisive parameters for pricing, and can estimate costs with precision.</p><p>Thus, a client can provide an origin location, a destination location, and information regarding the goods being transported, and the model returns a price estimate. This is how the models work for the three types of transport managed by Upply: road, maritime, and air.</p><p>For air freight, the model is slightly more specific since it is composed of sub-models that take one or several airports as input locations. If a client decides to benchmark between cities, we must therefore find the most relevant airports for them.</p><h4>Air Freight: A Unique Ecosystem</h4><p>Compared to other modes of transport, air freight is distinguished by its speed and reliability, although it represents a smaller share of the total volume of goods transported worldwide. While maritime dominates international trade in terms of volume, air transport is crucial for high-value, perishable, or time-sensitive goods, such as electronic components, pharmaceuticals, and fresh produce.</p><p>However, it shares with maritime the way in which a transport is executed. An air freight transport is generally divided as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*8LO2_MDuzrqDZBw3JzvDzA.png" /><figcaption>Decomposition of an Air Freight Transport</figcaption></figure><p>First, the goods are transported from a warehouse to the origin airport (<em>pre-carriage</em>). Then they are flown from the origin airport to the destination airport (<em>main leg</em>). Finally, they are delivered from the destination airport to a new warehouse (<em>post-carriage</em>).</p><p>The total transport cost is the sum of the cost of each segment. At Upply, two distinct models are used to predict the cost of these three segments: the <em>freight</em> model for the <em>main leg</em> and the <em>carriage</em> model for the <em>pre-carriage</em> and <em>post-carriage</em> segments.</p><p><strong>Zoning Is Necessary for Non-Airport Locations…</strong></p><p>We saw that the <em>freight</em> model estimates the price for the <em>main leg</em>, i.e., the transport cost between two airports. However, a client might want to know the price for a transport between two cities, or between a city and an airport, for example, between Berlin and Los Angeles International Airport. In this case, before using the <em>pre-carriage</em> and <em>freight</em> models to compute the estimate, it is necessary to choose the airport through which the goods will flow from Berlin before reaching Los Angeles.</p><p>This is made possible thanks to our zoning algorithm, which returns the most relevant airport for a given location. At Upply, the relevance of an airport relative to a city is measured by the distance between them and the <strong>logistical importance of that airport</strong>. The functioning of this algorithm is similar to the one presented in the article <strong><em>Finding the Most Relevant Port Using Weighted K-Nearest Neighbors</em></strong>. However, unlike sea freight, we do not have an index quantifying the overall importance of all terminals worldwide for air freight.</p><p><strong>… And an Importance Index Is Necessary for Zoning</strong></p><p>To perform the zoning, we use distance, which is easily accessible given the geolocations (latitude and longitude) of airports, along with their importance. The latter is much more complicated to obtain.</p><p>When discussing the logistical importance of an airport, we refer to the role it plays in the global supply chain and its influence in air freight. More specifically, what share of air freight departures and arrivals occur through that airport? How many different aircraft transit through it? To how many other airports is it connected via freight flights? We need an indicator that reflects the answers to all these questions.</p><p>One idea considered was to use rankings published by specialized organizations that list the top 10 or even the top 50 airports worldwide in terms of air freight. However, in addition to the fact that these rankings are far from exhaustive in terms of the number of airports, they mostly use a single characteristic for comparison, usually the volume of goods handled.</p><p>Yet, we need an indicator that compares a much larger list of airports, covering the widest possible geographical area, in order to best meet client demands. Furthermore, we want this indicator to take into account several factors beyond just the volume of goods, such as the number of arrivals and departures for each airport, so that it is as representative as possible of market reality. We are therefore building this <strong>airport importance index for the international air freight network</strong>.</p><h3>An Importance Index Built from a Validated Methodology and Open Source Data</h3><h4>PLSCI: An Indicator Validated by Transport Experts</h4><p>To create our index of airport importance from a logistical standpoint, we decided to base it on the methodology employed by the United Nations Conference on Trade and Development (UNCTAD) for the <a href="https://unctadstat.unctad.org/datacentre/dataviewer/US.PLSCI">Port Liner Shipping Connectivity Index (PLSCI)</a>. It is from this same index that we built <a href="https://medium.com/upply/finding-the-most-relevant-port-using-weighted-k-nearest-neighbors-8f18044f61e8">our maritime zoning algorithm</a>. This is an indicator validated by transport experts, including our own specialists at Upply, so we believe it is a good idea to adapt it for air freight.</p><p>The PLSCI reflects the position of ports in the global liner shipping network. It takes several factors into account:</p><ul><li>The number of vessels scheduled per week at the port</li><li>The annual cargo capacity deployed, measured in twenty-foot equivalent units (TEUs)</li><li>The number of regular maritime transport services offered from and arriving at the port</li><li>The number of shipping companies offering regular services to and from the port</li><li>The average TEU size of the largest container ship that regularly departs from and arrives at the port</li><li>The number of ports connected to the port</li></ul><p>The PLSCI is calculated quarterly for each port as follows: each component’s ratio (compared to the average of that component across all ports) is computed, then these ratios are averaged and multiplied by 100.</p><p><strong>The Advantages of This Type of Index</strong></p><p>The main advantage of this method is that it examines the terminal from several aspects rather than just one, for example, not solely the volume of goods handled. Indeed, if a port handles a large volume of goods but these goods are limited to only a few ships arriving and departing at the same location, the importance of the port would be overestimated.</p><p>Moreover, it is calculated regularly over extended periods to smooth out results that might be exceptionally low or high over a given period. Multiplying by 100 gives an index with an average of 100, which makes it easier to compare any given terminal with the <em>average terminal</em>.</p><p>We therefore decided to follow the main principles of the PLSCI for our airport importance index in the global air freight network. However, to build it, we need air transport data that provides similar components to those mentioned above.</p><h4>Open Source and Reliable Flight Data</h4><p><strong>Data That Meets Our Needs</strong></p><p>To build the importance index, we use an open source database of more than <strong>250,000 aircraft routes</strong>. These air freight transports involve around <strong>3,000 aircraft</strong> and took place between April and the end of June 2024. We have the following information concerning the flight:</p><ul><li>Origin airport</li><li>Destination airport</li><li>Departure date</li><li>Arrival date</li></ul><p>We also have additional information concerning the aircraft:</p><ul><li>Aircraft identifier</li><li>Aircraft type</li><li>Airline identifier</li><li>Service type (cargo = goods only / mix = both goods and passengers)</li><li>Aircraft capacity (in tonnes of cargo)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_9zrMipNcFMolZXCw0AfXA.png" /><figcaption>Sample of the Raw Data Used</figcaption></figure><p><strong>Data That Accurately Reflects the Market</strong></p><p>Before building the index, we begin by exploring the data through some basic descriptive statistics. This allows us to verify that the data aligns with market realities (thanks to our internal industry expertise) and to detect any potential discrepancies that might bias our calculations.</p><p>We start by counting the number of flights departing from and arriving at each airport to obtain a basic component representing their importance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*HoQWiY78cEhxBkG8IPO-0A.png" /><figcaption>Number of Departing Flights per Airport</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*0hZP7W6hzimf-Ry-MJd92A.png" /><figcaption>Number of Arriving Flights per Airport</figcaption></figure><p>Among the most frequented airports, we find Memphis (USMEM), Hong Kong (HKHKG), and Dubai (AEDXB). These figures allow us to perform an initial check regarding the most important airports overall and by geographic region. The results are consistent with our industry expertise.</p><p>We also examine this data by country to verify the results on a broader scale. These results also appear to reflect market reality well, as the top 10 countries with the most air freight transports include major global powers (USA, China, France, Germany, etc.).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*wgcmktuv2sNhaB_vljMMmw.png" /><figcaption>Number of Flights by Origin Country</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*3SFATKT3vDsxAnAxhrkL8w.png" /><figcaption>Number of Flights by Destination Country</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Rb5uwdPBZsCJynME3msyQ.png" /><figcaption>Number of Flights by Country (Origin — Destination)</figcaption></figure><p>Finally, when checking the number of flights executed by each airline, we notice that FedEx Express and UPS Airlines are the two most popular carriers. This observation also aligns with reality, as these two companies are among the most important, if not the two most important, cargo airlines.</p><p><strong>One Caution Regarding Our Data</strong></p><p>Our industry expertise raised one alert based on these results: the over-representation of flights involving Australian airports. There appears to be a higher proportion of Australian flights in our data than in reality. This could bias results depending on the subject of study, but not in this case.</p><p>Indeed, we aim to create an airport importance index for use with our zoning algorithm. This algorithm returns the most relevant airport based on a given location and only considers airports located on the same landmass as the location in question. For example, if the location is in Australia, the calculation for the most relevant airport will only consider Australian airports.</p><p>Thus, it is not problematic if the importance index for Australian airports is overestimated compared to other international airports, since they will not be compared to one another. However, attention should be paid to this point if the index is used in other contexts, perhaps by applying a weighting.</p><h4>A Reliable Index to Measure Airport Importance</h4><p><strong>Components That Reflect the Reach of Airports in the Global Air Freight Network</strong></p><p>Based on the data presented above, we develop an importance score for each of the <strong>754 airports</strong> in our database, which we can then use with our zoning algorithm.</p><p>To calculate this index, we draw inspiration from the methodology used for the PLSCI by UNCTAD, as mentioned earlier, as well as from the insights of our industry experts in air freight. We cannot produce the importance index directly from raw data; instead, we first calculate several components that characterize importance:</p><ul><li>Number of flights departing from the airport</li><li>Number of flights arriving at the airport</li><li>Number of distinct aircraft transiting through the airport</li><li>Number of distinct airlines operating through the airport</li><li>Number of airports connected to the airport</li><li>Total potential cargo volume transiting through the airport</li></ul><p>These components reflect the key ideas behind those used to calculate the maritime index on which we base our reasoning. They provide a comprehensive view of the overall activity of a freight terminal. We do not only consider the volume of goods handled and the number of flights, but also the geographical reach of each airport and how many different players are connected to it.</p><p><strong>The Revised PLSCI Methodology for Our Needs and Data</strong></p><p>We calculate the above components on a monthly basis for each airport. We choose to do it monthly rather than weekly, as we believe the volume of data is too low for some weeks. Unlike UNCTAD, we do not calculate them quarterly because we do not have enough total data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n8rrPh02u6LRygHrQIR5FA.jpeg" /></figure><p>From these components, we are able to calculate metrics that ultimately allow us to produce the index. The metrics are obtained by computing, for each component, the monthly average for each airport and then the ratio of this average compared to the overall average of all airports. This allows us to compare each airport to an <em>average airport</em> for each metric.</p><p>For example, for the number of departing and arriving flights, the results for the busiest airports are as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*pOiZKhOveiEsjhcJ8QWlFw.png" /><figcaption>Normalized Average Number of Departing Flights per Airport</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*ao23YSimHfLj12sx154kSQ.png" /><figcaption>Normalized Average Number of Arriving Flights per Airport</figcaption></figure><p>We can observe that there are 45 times more flights departing monthly from Memphis (USMEM) than from an average airport. We can therefore expect that it will be among the most important airports in the world.</p><p>We continue to follow UNCTAD’s methodology and then calculate the average of all these metrics. Unlike UNCTAD, however, we do not use a simple arithmetic mean but a weighted average. Based on advice from our industry experts, we want to create an index that gives more weight to the characteristics that matter most when evaluating an airport’s importance. This weighting, determined in consultation with the experts, is central to ensuring the index aligns with market reality. For example, we have given more importance to the number of distinct aircraft and distinct airlines than to the number of flights. This approach notably reduces the impact of airports that have many flights but where most flights are operated by only a few airlines.</p><p>Finally, we decide to normalize this score between 1 and 100 to make it more interpretable, as well as to control the range of possible values and facilitate the creation of our zoning algorithm.</p><p><strong>An Importance Index Consistent with the Market</strong></p><p>Among the top 10 most important airports worldwide in terms of air freight, 6 are American airports, including Memphis (USMEM) and Los Angeles (USLAX), and 4 are Asian, including the most important according to our index, Hong Kong International Airport (HKHKG).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/235/1*HEQQR__cFd7CO5vb7nhyKA.png" /><figcaption>Top 10 Most Important Airports According to Our Index</figcaption></figure><p>Notably, there is an absence of European airports in the global top 10. Among the most important in Europe, we find Paris-Charles de Gaulle (FRCDG), Frankfurt (DEFRA), and Amsterdam (NLAMS).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*1klV_UXzKjhZJxQzIkOWtQ.png" /><figcaption>Map of European Airports by Importance</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*ftxSqiKI90Y0hu29EhTeSA.png" /><figcaption>Top 10 Most Important European Airports According to Our Index</figcaption></figure><p>The airports ranked as most important by our index are consistent with our industry expertise and similar to those published by organizations specializing in air freight, confirming the reliability of our approach.</p><h3>A Consistent Index That Can Serve Transportation Professionals</h3><h4>A Relevant and Coherent Indicator</h4><p>In order to perform zoning for an air freight benchmark when no specific airports are provided, it was necessary to build an importance index. In fact, no open source index exists, and the only rankings produced by industry experts cover at most around fifty airports and compare them using a single metric.</p><p>Our index perfectly addresses this problem. It is calculated using open source data that aligns with market reality according to our analyses. Moreover, its methodology is based on that of an equivalent indicator for maritime transport, calculated by a recognized organization in the transportation world and validated by industry experts. It takes into account several components to provide the most faithful picture of each airport relative to other terminals worldwide.</p><p>The results of the created index are very satisfactory, correctly reflecting the position of each airport within the air freight network. The top airports globally, as well as by geographic region, are consistent with our industry expertise. We are therefore very pleased with the produced index and can build our zoning algorithm based on it.</p><h4>Useful Internally, But Not Only</h4><p>This index initially addresses an internal challenge. In cases where a client performs an air freight benchmark without directly specifying the relevant airports, we use a zoning algorithm to identify the most pertinent ones based on the provided locations. This relevance takes into account both the distance and the importance of the airports, which is our focus here. Thus, the index allows us to build a high-quality zoning algorithm to satisfy clients when they wish to know market prices.</p><p>However, this indicator also has broader potential applications. It could help logistics companies and shippers select the most efficient airports for their transportation needs. It might also serve as a tool for market analysts to forecast air freight trends.</p><p>Going even further, one can imagine investors using it to identify the most influential airports and prioritize investments in infrastructure or cargo processing technologies. Insurers might leverage this index to assess the risk associated with strategic hubs and offer insurance products tailored to the challenges of business continuity in freight transportation. Finally, researchers could use it to study the dynamics of freight networks, understand the success factors of airport hubs, or model scenarios for the evolution of traffic and cargo flows.</p><h4>Some Adjustments Are Still Needed</h4><p>Despite validation by our industry experts and the fact that it is built on reliable data and a recognized methodology from another type of transport, there are still some aspects to refine in order to perfect the index.</p><p>Firstly, while we worked with a sizable dataset, it could certainly be much larger. Aggregating larger volumes of data would likely make our index even more robust.</p><p>Additionally, the data contains too many transports involving Australia. As mentioned earlier, this does not affect our current use case, but it could be an issue in other projects. We need to consider a solution to achieve a better representation of Australian air freight within the global network. One idea would be to filter the input data to include only certain airlines or aircraft types. Another idea would be to adjust afterward by applying a weighting for Australian airports.</p><p>Finally, at the moment, this index is used only internally for our zoning algorithm. We could consider sharing it more widely so that it can benefit the growth and understanding of this mode of freight transportation, tell us in the comments if you’re interested!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dbf6badca9a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/upply/data-driven-air-freight-how-we-built-an-importance-index-for-better-zoning-2dbf6badca9a">Data-Driven Air Freight: How We Built an Importance Index for Better Zoning</a> was originally published in <a href="https://medium.com/upply">Upply</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Finding the Most Relevant Port Using Weighted K-Nearest Neighbors]]></title>
            <link>https://medium.com/upply/finding-the-most-relevant-port-using-weighted-k-nearest-neighbors-8f18044f61e8?source=rss-95d18c0d8a2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f18044f61e8</guid>
            <category><![CDATA[knn]]></category>
            <category><![CDATA[freight]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[zoning]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Rebours Baptiste]]></dc:creator>
            <pubDate>Wed, 26 Feb 2025 13:44:29 GMT</pubDate>
            <atom:updated>2025-02-26T13:44:29.542Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bbeb3fDw1UZD-4oQPVGENg.jpeg" /></figure><p>Upply digitizes the world of transportation, enabling its clients to obtain market price estimates, particularly for maritime transport. To achieve this, an Artificial Intelligence (AI) model — trained on millions of transports — is used. This model returns an estimate for a given origin port and destination port. However, clients can choose to provide only cities instead of directly specifying ports. In such cases, it becomes imperative for us to perform zoning to find the most relevant port based on the provided location. For this purpose, we decided to use <strong>K-nearest neighbors (KNN) weighted by port importance and using the Haversine distance</strong>. This article details our thought process on the subject.</p><h3>Diving into the World of Upply: Data at the Heart of Freight Transport</h3><h4>Upply: Technology Serving Freight Transport</h4><p>Upply is a digital platform revolutionizing freight transportation management by leveraging data and technology to enhance operational efficiency. Built on AI models trained on a vast database of several million transports, Upply offers a suite of solutions that empower businesses to compare prices, anticipate market fluctuations, optimize costs, and streamline their operations.</p><p>Serving a diverse range of clients — including shippers, carriers, freight forwarders, and consulting firms — Upply provides essential tools for price analysis, carrier sourcing, shipment tracking, administrative management, and CO₂ impact assessment. By combining cutting-edge technology with deep industry expertise, Upply simplifies and optimizes transport operations, making the supply chain more accessible, efficient, and transparent.</p><h4>Data: The Engine Behind Transport Price Prediction</h4><p>To determine the price of transporting goods, several factors come into play: the mode of transport, the departure and arrival locations, the transport date… And, of course, all the details about the goods themselves: weight, volume, content, etc. Upply’s AI models learn from these diverse data sources, identify the decisive parameters for pricing, and can estimate costs with precision.</p><p>Thus, a client can provide an origin location, a destination location, and details about the goods being transported, and the model returns a price estimate. This is how the models work for the three types of transport managed by Upply: road, air, and maritime.</p><p>For maritime transport, the model is slightly more specific, as it is composed of sub-models that take one or more ports as input locations. If a client decides to benchmark between cities, we must then find the most relevant ports for those cities.</p><h4>Maritime: A Unique Ecosystem</h4><p>To begin, it is important to understand how maritime transport works. It is generally divided into the following stages:</p><figure><img alt="Picture showing the different stages of a sea freight shipment" src="https://cdn-images-1.medium.com/max/909/1*ciaTFDa0fs5FKPAPv3gSyg.png" /><figcaption>Decomposition of a maritime transport</figcaption></figure><p>First, the goods are transported from a warehouse to the origin port (<em>pre-carriage</em>). Then they are shipped by boat from the origin port to the destination port (<em>main leg</em>). Finally, they are delivered from the destination port to a new warehouse (<em>post-carriage</em>).</p><p>The total transport cost is the sum of the cost of each segment. At Upply, two distinct models predict the cost of these three segments: the <em>freight</em> model for the <em>main leg</em> and the <em>carriage</em> model for the <em>pre-carriage</em> and <em>post-carriage</em> segments.</p><p><strong>Zoning is Necessary for Non-Port Locations</strong></p><p>We saw that the <em>freight</em> model can estimate the price of the <em>main leg</em>, meaning the transport cost between two ports. However, a client may want to know the price for a transport between two cities, or between a city and a port — for example, between Paris and the port of Shanghai. In this case, before using the <em>pre-carriage</em> and <em>freight</em> models for the estimate, it is necessary to choose the port through which the goods will flow from Paris before reaching the port of Shanghai.</p><p>It is therefore essential to <strong>find the most relevant port corresponding to the location provided by the user</strong>. At Upply, the relevance of a port relative to a city is measured by the port’s <strong>logistical importance</strong> and the <strong>distance</strong> separating them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*btw096nj8uDACss5IblKFQ.png" /></figure><h3>Our Approach in a Few Steps</h3><p>We aim to associate a port with each location. To do this, we use a classification algorithm: K-nearest neighbors (KNN). We test the effectiveness of our various solutions on a sample of French municipalities.</p><h4>KNN: The Key Tool for Zoning</h4><p><strong>KNN: The Ideal Algorithm for Distance-Based Classification</strong></p><p>KNN is an algorithm that relies on the distance between observations to categorize them into groups. The fundamental idea behind KNN is to find the <em>k</em> samples closest to a given point in the feature space. For classification, it assigns the most frequent label among its neighbors to that point. The default metric used to calculate the distance between points is generally the Euclidean distance.</p><p>The choice of <em>k</em>, the number of neighbors, is crucial to strike the right balance between specialization and generalization. Here, since we want to associate a location with its most relevant port, we use <strong>k = 1</strong>.</p><p><strong>Applying KNN with Euclidean Distance</strong></p><p>We test KNN with the Euclidean distance to associate a port with each French municipality. The ports used are all those in the Upply database.</p><p>We obtain the following result:</p><figure><img alt="Map showing the zoning with KNN and Euclidean Distance assigning each French commune to a port" src="https://cdn-images-1.medium.com/max/760/1*TXDEg2kK-h2KQaFgMJ247A.png" /><figcaption>Zoning with KNN and Euclidean Distance</figcaption></figure><p>As seen on the map, each municipality is associated with its closest port based on Euclidean distance. This distance corresponds to the straight-line distance between two points:</p><figure><img alt="Representation of Euclidean distance in two-dimensional space" src="https://cdn-images-1.medium.com/max/283/1*8wWtuLR8kP0IOi3bZX8mww.png" /><figcaption>Euclidean Distance</figcaption></figure><p>This measure is simple to compute and thus not computationally intensive (here, 1.35 seconds for classifying 20,000 municipalities), but it does not take into account the Earth’s curvature.</p><h4>The Haversine Distance: Superior Geographic Accuracy</h4><p><strong>Calculating Distances on Earth Using the Haversine Formula</strong></p><p>When working with geographic coordinates, using the Euclidean distance can lead to inaccuracies, especially over long distances.</p><p>In contrast, the Haversine distance — based on the eponymous formula — is specifically designed to measure distances on a sphere like Earth. However, this formula is more complex and thus more computationally demanding.</p><figure><img alt="Representation of Haversine distance on a sphere" src="https://cdn-images-1.medium.com/max/283/1*Qzd87jBo7CnOjCiZT5eaBA.png" /><figcaption>Haversine Distance</figcaption></figure><p><strong>KNN with Haversine to Enhance Zoning Accuracy</strong></p><p>We test our algorithm on the same municipalities, modifying only the distance metric used to determine the nearest neighbor by using the Haversine distance.</p><p>Here is the result:</p><figure><img alt="Map showing the zoning with KNN and Haversine Distance assigning each French commune to a port" src="https://cdn-images-1.medium.com/max/771/1*adai43PIzHGppINKn5ughA.png" /><figcaption>Zoning with KNN and Haversine Distance</figcaption></figure><p>We notice that using the Haversine distance slightly adjusts some zones, correcting the inaccuracies mentioned earlier. However, the computation time is significantly longer: 19.08 seconds for classifying 20,000 municipalities versus 1.35 seconds with the Euclidean distance.</p><p>So, Euclidean or Haversine?</p><p>Since we do not have millions of queries to handle simultaneously, the increased computation time is not a major issue. Although there is nearly a 20-fold difference in calculation time, the time per query remains minimal. Therefore, we favor the precision of the Haversine method over the efficiency of the Euclidean method.</p><p><strong>Beyond Distance: Incorporating the Logistical Importance of Ports</strong></p><p>A new challenge arises when observing the zoning results on the map above. For instance, the ports of Rouen (FRURO), Montoir (FRMTX), and La Pallice (FRLPE) have much larger zones than that assigned to the port of Le Havre (FRLEH).</p><p>However, according to our industry expertise, the port of Le Havre (FRLEH) is the most logistically important port in France, and one of the most significant in Northern Europe. Its area of influence should therefore be much larger. We thus decide to factor in not only the distance but also the logistical importance of the ports.</p><h4>Measuring the Logistical Importance of Ports</h4><p><strong>Connectivity Index: The Key to Evaluating Port Importance</strong></p><p>To assess the logistical importance of ports, we use the <a href="https://unctadstat.unctad.org/datacentre/dataviewer/US.PLSCI">Port Liner Shipping Connectivity Index (PLSCI)</a> calculated by the United Nations Conference on Trade and Development (UNCTAD). The PLSCI reflects the position of ports in the global liner shipping network. It considers several factors, including:</p><ul><li>The number of vessels scheduled per week at the port</li><li>The annual cargo capacity deployed, measured in twenty-foot equivalent units (TEUs)</li><li>The number of shipping companies offering liner services to and from the port</li><li>The number of ports connected to the port</li></ul><p>The PLSCI is calculated quarterly for each port, and its value is expressed as a ratio relative to the highest value in Q1 2006, multiplied by 100.</p><p>The initial dataset contains around 1,300 ports, from which we retain only those with at least 3 data points over the past 5 years (to ensure statistical relevance for comparisons) and that are included in our internal database. The final port database contains 945 ports. For each port, we have:</p><ul><li>Its UN/LOCODE (port identifier code)</li><li>Its importance (average importance over each quarter)</li><li>Its geographic coordinates (latitude and longitude)</li></ul><figure><img alt="Table of most important ports in France and neighboring countries as of 2023, with their importance score and geographical coordinates" src="https://cdn-images-1.medium.com/max/239/1*g6LxBDD3mq32vpN2MKcMkw.png" /><figcaption>Most Important Ports in France and Neighboring Countries as of 2023</figcaption></figure><p>The most significant ports in Western Europe (excluding the United Kingdom) are Rotterdam (NLRTM), Antwerp (BEANR), and Hamburg (DEHAM). In France, the dominant ports are Le Havre (FRLEH), Dunkerque (FRDKK), and Fos-sur-Mer (FRFOS).</p><p><strong>Weighted KNN: Combining Distance and Logistical Importance</strong></p><p>As mentioned earlier, we want to assign to a location the most relevant port, not just the nearest one. Therefore, we do not simply use the basic algorithm that computes the Haversine distance between the location and each port and assigns the nearest port.</p><p>Instead, we use a variant of KNN known as weighted KNN. This alternative to classic KNN allows us to assign different weights to observations, taking them into account when searching for the nearest neighbors. The nearest neighbors are no longer determined solely by geographic proximity; we now consider their weight. Thus, an observation that is farther away from our target point but more important can be deemed the nearest neighbor, depending on the distance/weight weighting applied.</p><p>In our case, we weight the Haversine distance by the importance of the ports. More precisely, to find the nearest neighbor, we divide the distance from the location to each port by its importance.</p><p>Here is the resulting outcome:</p><figure><img alt="Map showing the zoning with Weighted KNN and Haversine Distance assigning each French commune to a port" src="https://cdn-images-1.medium.com/max/690/1*AOsVCvfEfZ5NCrnqvGk3XQ.png" /><figcaption>Zoning with Weighted KNN and Haversine Distance</figcaption></figure><p>We observe that French municipalities are now assigned to fewer distinct ports. Ports with very low importance are no longer selected, as the algorithm favors a more important port even if it is farther away. The extent of the zone assigned to each port now depends on both its location and its importance, which aligns more closely with market reality according to our industry expertise.</p><p>For example, the port of Dunkerque (FRDKK) is more important than the port of Fos-sur-Mer (FRFOS), yet fewer locations are assigned to it. This is because it is close to two more important ports, Antwerp (BEANR) and Le Havre (FRLEH), while Fos-sur-Mer (FRFOS) faces two ports with similar importance.</p><p>Moreover, the port of Le Havre (FRLEH) is now the designated port for a large part of western France, which was not the case with the previous zoning version. However, some locations are still assigned to ports of medium or even low importance.</p><figure><img alt="Zoom on Western France — Map showing the zoning with Weighted KNN and Haversine Distance assigning each French commune to a port" src="https://cdn-images-1.medium.com/max/772/1*jJa5J3xt_4aJyklt9bUA5A.png" /><figcaption>Zoom on Western France with Weighted KNN and Haversine Distance</figcaption></figure><p>Zooming in on western France, we notice that the zoning assigns some municipalities to ports such as Brest (FRBES), Montoir (FRMTX), or La Pallice (FRLPE). This is due to their importance, which, although significantly lower than that of Le Havre (FRLEH), is sufficient to allocate them a certain number of municipalities.</p><p>According to our industry expertise, goods from these locations almost exclusively depart from the port of Le Havre (FRLEH), with the other ports (e.g., FRBES, FRMTX, and FRLPE) being used only in very specific cases. We thus modify our algorithm to better align with market reality.</p><h4>Expertise Beyond the Data</h4><p><strong>Filtering Ports to Retain Only the Most Significant</strong></p><p>We do not want to assign the port of Brest (FRBES) to municipalities in Brittany, because, based on industry expertise, we know that the port of Le Havre (FRLEH) is almost the only port systematically used for locations in western France.</p><p>Therefore, we filter the ports used by our algorithm to retain only the most important ones, all in collaboration with our industry experts.</p><p><strong>Our Zoning Closely Reflects Market Reality</strong></p><p>Finally, after filtering the ports used in the zoning, we obtain the following result:</p><figure><img alt="Map showing the zoning with Weighted KNN, Haversine Distance, and Significantly Important Ports assigning each French commune to a port" src="https://cdn-images-1.medium.com/max/694/1*KkeLjbh1dAqyR1qzLhM55g.png" /><figcaption>Zoning with Weighted KNN, Haversine Distance, and Significantly Important Ports</figcaption></figure><p>We note that only two French ports (Le Havre — FRLEH and Fos-sur-Mer — FRFOS) are now returned, compared to thirteen before filtering. These ports respectively cover northwestern and southeastern France. Meanwhile, northeastern, southwestern, and extreme southeastern regions of the country are assigned to the most important ports of neighboring countries — Antwerp (BEANR), Barcelona (ESBCN), and Genoa (ITGOA).</p><p>We compare our results with the map of economic influence and attraction zones of ports, also known as hinterlands:</p><figure><img alt="Map of French Hinterlands" src="https://cdn-images-1.medium.com/max/804/1*w4MOda6Y2MUA9X69QQNYUg.png" /><figcaption>Map of French Hinterlands (Source: Upply)</figcaption></figure><p>Overall, our classification is satisfactory and remains very close to what is observed in reality. We recover the ports of Le Havre (FRLEH), Fos-sur-Mer (FRFOS), and Antwerp (BEANR) which respectively cover western, southeastern, and northeastern France. As indicated by our industry experts, ports such as Brest (FRBES) or Montoir (FRMTX) are not used, being sidelined in favor of the port of Le Havre (FRLEH). However, some differences remain between our classification and the hinterland map.</p><h3>A Functional and Efficient Algorithm</h3><h4>Zoning with Weighted KNN</h4><p>The objective was to develop an algorithm that finds the most relevant port corresponding to the location provided by the user, enabling the use of the benchmark model when a port code is not directly specified.</p><p>The algorithm presented in this article — KNN with Haversine distance weighted by port importance — perfectly addresses the stated problem. KNN with k = 1 enables zoning. Using the Haversine metric for distance calculation provides better precision than the Euclidean metric by accounting for the Earth’s curvature, without being too computationally intensive. Finally, employing weighted KNN allows us to consider the critical aspect of a port’s relevance — its logistical importance. The port of Le Havre (FRLEH) is not as important as Fos-sur-Mer (FRFOS); their zones of influence are affected accordingly, and it is imperative to account for this in the algorithm. As in most data projects, industry expertise is essential to deliver a product that meets expectations. Here, we used expert insights to filter out ports that are rarely used by clients, except in exceptional cases.</p><p>This algorithm does not perfectly mirror market reality — as seen with the hinterland map — but it represents an excellent compromise between complexity and performance. We are very satisfied with the proposed solution.</p><h4>Areas for Improvement</h4><p>Our classification differs from the hinterland map in the zones of influence for the ports of Le Havre (FRLEH) and Fos-sur-Mer (FRFOS). Based on expertise, the influence of these ports is greater than that of foreign ports in their respective regions. We could therefore refine the importance index we calculated to address these points.</p><p>Moreover, our zones are delineated rather crudely due to the simplicity of our algorithm. In contrast, hinterlands are much more nuanced. A striking example is the area around Paris. Our classification divides it into two — the western part being assigned to Le Havre (FRLEH) and the eastern part to Antwerp (BEANR) — whereas in reality, the entire region is served by Le Havre (FRLEH), as seen on the hinterland map. We could adjust our algorithm to incorporate other factors such as administrative boundaries (departments, regions), topography (natural relief, road networks), and demographics (population size).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f18044f61e8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/upply/finding-the-most-relevant-port-using-weighted-k-nearest-neighbors-8f18044f61e8">Finding the Most Relevant Port Using Weighted K-Nearest Neighbors</a> was originally published in <a href="https://medium.com/upply">Upply</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>