Towards AI Can Help your Team Adopt AI: Corporate Training, Consulting, and Talent Solutions.


Phil the Gaps: Unraveling the Hidden Threads of the Philippines’ 2022 Trade Network
Data Science   Latest   Machine Learning

Phil the Gaps: Unraveling the Hidden Threads of the Philippines’ 2022 Trade Network

Last Updated on August 9, 2023 by Editorial Team

Author(s): Erika Lacson

Originally published on Towards AI.

Image from Canva


Diving into Network Science, my latest academic pursuit, a familiar sensation was rekindled. Recalling a project from three terms ago, a project I’d vowed to revisit, I found myself drawn back to the Bureau of Customs’ trade data from 2015 to 2022. That itch, the compulsion to delve deeper and try a different method in uncovering insights into the Philippines’ trade patterns, was back. My interest in using novel techniques to uncover patterns, reminiscent of my previous experiment with Benford’s Law, spurred me to view the Philippines trade data through a fresh lens. Given the recent political shifts, emerging leadership, and the inception of transformative laws like the Rice tariffication, the Filipino trade landscape is continuously evolving, offering new avenues for insights. It’s personal to me: understanding this complex web isn’t just about data — it’s about the stories, opportunities, and intrinsic value I derive from such projects.

So, why the sudden interest in Network Science? Well, it offers a fresh lens, a new perspective. While on the surface, it might seem like merely studying relationships and connections, this field has already proven instrumental in addressing and modeling some of our most complex challenges. No matter how chaotic they may appear, solutions become attainable with Network Science.

Since Network Science is most useful when we have specific goals or problems to solve in mind, in this exploration, I aim to answer the following questions:

1. How does the Philippines connect and interact with its trade partners, and what does this mean for our country’s future alliances and opportunities?
2. By dissecting most traded products, can we pinpoint untapped opportunities or foresee emerging trends?

Join me as we chart this journey, filling the gaps in the untapped opportunities and trends in the Philippines’ 2022 Trade Network.

Background and Basics

Before we begin with our analysis, let me give you a simple refresher about the dataset and the key concepts that we’ll discuss later.

Data Source:

The data has been sourced from Comtradeplus, a renowned repository for global trade data. A key term that will frequently pop up in our dataset is the ‘HS Codes’. These Harmonized System (HS) codes serve as international identification codes for traded goods, ensuring a standardized classification across borders.

Key Terms:

Nodes and Degrees: At its core, Network Science revolves around ‘nodes’ and ‘degrees’. In this study, nodes may represent countries or product categories. Their interactions or relationships are signified by edges or links. The degree is a simple count of how many links a node has. For instance, if the Philippines (a node) trades with ten countries, its degree is ten.

Bipartite & Tripartite Networks: The terms ‘bipartite’ and ‘tripartite’ might sound like jargons, but they’re quite straightforward. Think of them as layers in a network. A bipartite network has two sets of nodes, like countries and products. Edges link nodes from one set to another but never within the same set. On the other hand, a tripartite network has three node sets, increasing the complexity and richness of the data.

Armed with these basics, let’s continue with our analysis.


The following discussions contain the results of my analysis using standard Python libraries, plotly express, and NetworkX. If you’d like to see the complete code, please refer to my GitHub link here.

Network Representation

The following summarizes my representation of this trade network:


  • Reporter Country — exclusively includes the Philippines, as I only want to analyze using the Philippines’ point of view.
  • Partner Countries — include partner countries with which the Philippines conduct import / export trade activities.
  • Chapters — represent product categories based on HS Codes. Again, these are identification codes assigned to goods that are traded and recognized internationally.


  • Edges between the Reporter Country and Partner Countries represent trade interactions (imports and exports) weighted based on trade value in USD.
  • Edges between the Reporter Country and Chapters represent traded product categories (imported and exported product categories) weighted based on trade value in USD.


  • This network will be a directed [the direction of the edges will represent the imports (pointing to the Philippines) and exports (pointing out of the Philippines), weighted (based on trade value in USD)], and tripartite graph (3 different nodes above, 1 same edge attribute based on trade value in USD).

Now that you understand our network let’s start with a visualization of the Directed, Weighted, and Tripartite Trade Network of the Philippines in 2022 [Partner Countries — Philippines (Reporter Country) — HS Code (Product Categories)]:

Figure 1. 2022 Tripartite Trade Network. Image by Author

Figure 1 illustrates the import and export transactions between the Philippines, its 221 global partners, and the 97 diverse product categories for 2022.

PHL-Partner Bipartite Network

While our tripartite network gives a broad perspective, it’s equally vital to focus on more granular relationships. Let’s pivot our focus into the bipartite networks, beginning with the PHL-Partner Bipartite Network.

Figure 2. Bipartite Network highlighting the top 10 partner countries that the Philippines exports products to. Image by Author.
TOP 10 partners based on exports: 'USA', 'Japan', 'China', 'China, Hong Kong SAR', 'Singapore', 'Thailand', 'Rep. of Korea', 'Other Asia, nes', 'Netherlands', 'Germany'

Figure 2 uncovers the USA and Japan as the leading trade partners for the Philippines, spotlighting a balanced trade synergy. The prominence of Asian nations, including China and the ASEAN members, points towards a potentially strengthening regional bond, perhaps influenced by ASEAN collaborations as well as their proximity to our country. Meanwhile, the Philippines’ global outreach is also evident, with European nations like the Netherlands and Germany making it to the top 10. This diverse set of relationships not only highlights the breadth of the Philippines’ trade arena but also signals potential markets and alliances waiting to be further nurtured and assessed (more on this in our PHL-Chapter discussion).

Figure 3. Bipartite Network highlighting the top 10 partner countries that the Philippines imports products from. Image by Author.
TOP 10 partners based on imports: 'China', 'Indonesia', 'Japan', 'Rep. of Korea', 'USA', 'Singapore', 'Thailand', 'Other Asia, nes', 'Malaysia', 'Viet Nam'

In Figure 3, as expected, China emerges as the top, suggesting an economic reliance or a strategic tie-up. The substantial trade values associated with other Asian countries, such as Indonesia, Japan, and the Republic of Korea, hint at the Philippines’ inclination towards regional sourcing, probably because of proximity and costs. Moreover, the presence of “Other Asia, nes” indicates a collection of smaller trade activities within the Asian region, which could be an area to investigate further.

When evaluating both imports and exports, China’s dominant role is undeniable. As the leading import partner and a top three export destination, this signifies a deep-rooted economic interdependency between the Philippines and China. Such a relationship underscores the importance of bilateral ties the potential for joint ventures, strategic collaborations, and free trade agreements.

On the other hand, the balanced trade relationship with countries like the USA and Japan is also noteworthy. These countries not only source significantly from the Philippines but also play a vital role in supplying it. This bilateral dynamic can be an indicator of mutual economic growth and a balanced trade equilibrium that may reduce the risks associated with over-dependence in China.

PHL-Chapter Bipartite Network

Let’s also analyze the other side of the network, the PHL-Chapter Bipartite Network.

Figure 4. Bipartite Network highlighting the top 10 HS Codes (product categories) that the Philippines exports. Image by Author.
TOP 10 Exports by Chapter:
1. 'Electrical machinery and equipment and parts thereof; sound recorders and reproducers; television image and sound recorders and reproducers, parts and accessories of such articles',
2. 'Nuclear reactors, boilers, machinery and mechanical appliances; parts thereof',
3. 'Optical, photographic, cinematographic, measuring, checking, medical or surgical instruments and apparatus; parts and accessories',
4. 'Copper and articles thereof',
5. 'Animal or vegetable fats and oils and their cleavage products; prepared animal fats; animal or vegetable waxes',
6. 'Ores, slag and ash',
7. 'Fruit and nuts, edible; peel of citrus fruit or melons',
8. 'Natural, cultured pearls; precious, semi-precious stones; precious metals, metals clad with precious metal, and articles thereof; imitation jewellery; coin',
9. 'Mineral fuels, mineral oils and products of their distillation; bituminous substances; mineral waxes',
10. 'Plastics and articles thereof'

Figure 4 shows that Electrical machinery and equipment (Chapter 85) continue to dominate our main exports, which solidifies the Philippines’ position as a significant player in the global electronics market. This is an attractive proposition for global tech firms looking to outsource or set up manufacturing hubs. Similarly, the substantial exports of nuclear reactors, machinery, and mechanical appliances (Chapter 84) highlight a robust machinery production ecosystem. Interestingly, while the country boasts rich biodiversity, it’s the exports of non-traditional products like copper (Chapter 74) and fats and oils (Chapter 15) that have found significant markets abroad. For entrepreneurs, this opens up avenues to explore value-added products, same or complementary products from these top product categories, to ensure greater market penetration and diversification.

Figure 5. Bipartite Network highlighting the top 10 HS Codes (product categories) that the Philippines imports. Image by Author.
TOP 10 imports by Chapter:
1. 'Electrical machinery and equipment and parts thereof; sound recorders and reproducers; television image and sound recorders and reproducers, parts and accessories of such articles',
2. 'Mineral fuels, mineral oils and products of their distillation; bituminous substances; mineral waxes',
3. 'Nuclear reactors, boilers, machinery and mechanical appliances; parts thereof',
4. 'Vehicles; other than railway or tramway rolling stock, and parts and accessories thereof',
5. 'Iron and steel',
6. 'Plastics and articles thereof',
7. 'Cereals',
8. 'Optical, photographic, cinematographic, measuring, checking, medical or surgical instruments and apparatus; parts and accessories',
9. 'Food industries, residues and wastes thereof; prepared animal fodder',
10. 'Pharmaceutical products'

Figure 5 suggests a growing domestic demand for tech products and perhaps the absence of certain specialized machinery domestically (which could be an opportunity for local entrepreneurs to look into). The high import value of mineral fuels and oils (Chapter 27) and vehicles (Chapter 87) indicates a booming transportation sector, potentially signaling urban expansion or infrastructure development. The substantial import of cereals (Chapter 10) can be an area of concern, reflecting a dependency on foreign sources for basic food staples. This could be an opportunity for agri-entrepreneurs to intensify domestic cereal production, leveraging new-age farming techniques.

Combining the results of Figure 4 and 5 reveals an intriguing scenario. The Philippines exports a considerable amount of electrical machinery and equipment (Chapter 85) while also importing in the same category. This could indicate a sophisticated value chain where basic components are imported, value is added domestically and then exported as finished or semi-finished products. Such a pattern underscores the importance of the Philippines in the global electronics supply chain. However, the duality in importing and exporting similar products might also hint at potential inefficiencies or gaps in the domestic production capabilities. This insight can be used to implement targeted incentives to attract foreign inventors in the same and complementary industries. Continuing this net export of Chapter 85 can help ensure a more self-reliant and streamlined supply chain, solidifying the country’s position in the global market.

Let’s also analyze the results based on our trade balance:

Figure 6. Bipartite Network top and bottom 10 in terms of trade balance (exports-imports). Image by Author.

Figure 6 displays that the Philippines exhibits a pronounced trade surplus with regions like China’s Hong Kong SAR and the USA, underscoring potential untapped demand for specific Filipino products, especially in gateway markets like the Netherlands, opening European avenues. This is also something that the government can look into in deciding on specific free trade agreements to boost exports to these countries more. On the other hand, significant trade deficits with countries like China and Indonesia highlight potential over-reliance on certain imports. Entrepreneurs should explore opportunities for domestic production of these high-demand imported goods, while simultaneously amplifying exports that resonate with surplus countries. This kind of dual strategy can foster a more balanced trade ecosystem, and reduce our trade vulnerabilities while capitalizing on our strengths.

Now that we’re done with the separate analysis of the bipartite networks of trade partners and product chapters, let’s combine these two again together to now capture a more holistic view of the Philippines’ trade landscape, starting with the following:

Figure 7. Imports by Partner Country and Chapter. Image by Author.

Figure 7 reveals several strategic insights. Key Asian economies, especially China and Indonesia, dominate the import landscape, primarily in machinery (Chapter 85) and fuels (Chapter 27). These two Chapters are diversely sourced across several partners (great!). Diversifying fuel imports could offer the Philippines a buffer against geopolitical or economic fluctuations in a given country. Also, the prominence of electrical machinery, vehicles, and fuels in the imported matrix indicates areas where domestic advancements or alternative sourcing could significantly benefit the nation’s economic health and resilience.

Figure 8. Exports by Partner Country and Chapter. Image by Author.

Analyzing the Philippines’ exports by country and chapter in Figure 8 also presents a strategic opportunity. The USA, Japan, and Hong Kong are predominant export destinations, with electrical machinery and equipment being a standout category. Interestingly, while the Philippines exports a vast amount of this category to the USA and Hong Kong, there’s a notable diversification with Japan, hinting at a broader trade relationship. Enhancing these sectors through innovation and quality assurance, coupled with exploring new markets for these products, could amplify the Philippines’ competitive edge in the global arena.

Figure 9. Imports by Chapter and Partner Country. Image by Author.

Upon inspecting the Philippines’ imports by chapter and country in Figure 9, it’s obvious that China is a dominant trade partner, with significant imports spanning electrical machinery (Chapter 85), nuclear reactors (Chapter 84), and mineral fuels (Chapter 27). However, a closer look reveals the Philippines’ reliance on Indonesia for mineral fuels (Chapter 27), hinting at the strategic importance of maintaining this relationship for energy security. Given the variety of essential goods coming from different countries, it’s imperative for the Philippines to diversify its supply chains and foster resilient partnerships, ensuring a steady flow of critical imports.

Figure 10. Exports by Chapter and Partner Country. Image by Author.

Figure 10 demonstrates that electrical machinery (Chapter 85) remains the dominant export, especially to the USA, Hong Kong, and Japan. Yet, what’s intriguing is the broad spread of product categories exported to countries like Japan — from machinery (Chapter 85) to copper (Chapter 74). This diversified export portfolio suggests a mature trading relationship, offering stability and reduced vulnerability to market fluctuations. Another notable observation is the export of ores and copper to countries like China, revealing potential growth sectors that could be further developed. Strategic efforts to innovate and expand production in these sectors could potentially elevate the Philippines’ export value and strengthen its position in the global market.


And with that, by analyzing the relationships using nodes and edges in our Trade Network, we were able to gather and summarize the following useful insights:

For the Government:

  • While China remains a significant trade partner, the imbalance in trade necessitates diversifying partners to mitigate risks. Strengthening ties with countries like the Netherlands and Germany via strategic free trade agreements, foreign incentives, etc., could be beneficial.
  • The prominence of ores, copper, and electrical machinery in our exports suggests potential growth sectors. Investing in R&D and infrastructure in these sectors can elevate the Philippines’ global standing.

For NGOs:

  • With certain product categories like machinery and natural pearls being exported to diverse markets, NGOs can focus on grassroots-level initiatives to enhance local production capabilities.
  • Provide skill training in sectors that are emerging as significant export players, ensuring the workforce is equipped to meet global demands.

For Entrepreneurs:

  • The broad product spread in exports to countries like Japan suggests a market open to diverse products. Entrepreneurs should tap into this versatility.
  • With countries like China importing ores and copper, there’s room for innovation. Collaborative efforts to refine these raw materials locally can add value and increase export potential.

For Others:

  • As the landscape of Filipino trade evolves, staying abreast of trends and shifts is crucial. This not only aids in strategic decision-making but also in spotting opportunities as they arise.
  • Network science has shown the importance of connections. Building bridges, both within and outside the country, can lead to collaborative opportunities and shared growth.

Thank you for joining me in this exploration of the Philippines’ 2022 trade network. Stay tuned!


  1. United Nations Comtrade Database. Comtradeplus. A primary source for global trade data, offering detailed insights into trade flows and patterns.
  2. Tariff Commission of the Philippines. HS Codes and the Philippine Tariff Book. A detailed guide on the Harmonized System codes used for classifying traded goods on an international scale.
  3. United Nations Statistics Division (UNSD). “Areas not elsewhere specified.” UN Comtrade Wiki. Available at:

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI

Feedback ↓