Modeling of War-Induced Ukrainian Migration’s Impact on Poland’s Trade Using Machine Learning Nataliia Dziubanovska1 1 West Ukrainian National University, 11 Lvivska Str., Ternopil, 46009, Ukraine Abstract The article explores the impact of Ukrainian migration caused by the war on Poland’s external economic indicators, given that Poland is one of the main recipients of Ukrainian refugees in Europe. The scale and pace of the migration flows have created new challenges for the Polish economy, particularly in the context of changes in external trade. The study provides a detailed analysis of the relationships between Poland’s import and export volumes and the number of asylum seekers from Ukraine during the period from 2008 to 2023, considering key geopolitical events such as the conflict in Eastern Ukraine, the annexation of Crimea in 2014, and Russia’s full-scale invasion of Ukraine in 2022. It was found that traditional correlation analysis methods could not fully capture the complex nonlinear relationships between the variables; therefore, various machine learning methods were used to model these relationships, including Lasso, Ridge and Polynomial Regression, K-Nearest Neighbors (KNN), Random Forest, Gradient Boosting, XGBoost, CatBoost, Cubic Splines and Spline Transformer, and Statsmodels (GLMGam). The results obtained led to conclusions about the significant nonlinear relationships between refugee migration flows from Ukraine and Poland’s external trade indicators. This research contributes to understanding how migration can impact the macroeconomic stability and international trade of host countries and offers new approaches for forecasting the economic consequences of migration processes. Keywords ⋆1 correlation analysis, economic analysis, ensemble methods, forecasting, geopolitical events, machine learning, migration, Poland, splines, war in Ukraine, foreign trade. 1. Introduction The war in Ukraine has caused one of the largest migration waves in modern history, which has significantly affected neighboring countries, including Poland. Migration on such a scale has profound socio-economic consequences, including changes in the country’s foreign economic relations. According to UNHCR data as of August 19, 2024, there are 6,655,100 refugees from Ukraine worldwide, with 6,083,800 of them in Europe. As of June 11, 2024, Poland has recorded 957,504 Ukrainian refugees, with 21,388,746 Ukrainians crossing the border into Poland since February 24, 2022, of whom 19,498,566 returned in the opposite direction since February 28, 2022 [1]. The scale and speed of this migration have created new challenges for Poland’s economic system, which requires in-depth analysis. The influx of labor and spending by Ukrainian ⋆ ITTAP’2024: 4th International Workshop on Information Technologies: Theoretical and Applied Problems, October 23- 25, 2024, Ternopil, Ukraine, Opole, Poland 1 n.dziubanovska@wunu.edu.ua (N. Dziubanovska) 0000-0002-8441-5216 (N. Dziubanovska) © 2023 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). CEUR ceur-ws.org Workshop ISSN 1613-0073 Proceedings migrants abroad contribute to the economic growth of the host countries. The greatest contribution of Ukrainians to the labor force is observed in Poland, the Czech Republic, and Estonia. This trend creates a solid foundation for the growth of goods and services production in these European countries, especially those that have accepted the largest number of Ukrainian migrants or have a high percentage of Ukrainian refugees in the total population [2]. However, to fully understand the economic consequences, it is necessary to consider not only direct effects, such as filling vacant job positions and increased consumer demand, but also indirect impacts, particularly on foreign trade and macroeconomic stability. Specifically, in Poland, one of the recipient countries that has accepted the largest number of Ukrainian migrants, there is a significant impact on foreign economic indicators. Migration flows can alter the structure of imports and exports, affecting the competitiveness of local businesses and creating new opportunities for international trade. Analyzing the nonlinear relationships between Ukrainian migration and Poland’s foreign trade indicators will reveal subtle connections that may be overlooked in traditional models. Thus, the aim of this research is not only to identify and analyze these relationships but also to develop new forecasting models that account for these complex nonlinear dependencies. This will enhance the accuracy of predicting the economic impacts of migration and develop effective strategies for managing its effects. The research results could serve as a basis for developing policy and economic recommendations aimed at maximizing the benefits of migration processes and ensuring the economic stability of the host country. 2. Literature review Migration is a complex socio-economic phenomenon that impacts various aspects of economic development in countries. In the context of contemporary global challenges, including the war in Ukraine, migration flows have reached immense scales and have become a significant subject for research. Special attention should be given to analyzing the impact of migration on the economic indicators of host countries. Research in this area covers a wide range of issues, including labor market changes, income levels, consumer demand, effects on foreign trade, and socio-economic consequences for recipient countries. Scholars from various fields are actively studying the impact of migration on the economy to develop effective policies and integration strategies, reflecting a multidisciplinary approach to the issue. Sociologists are interested in how migrants integrate into new communities, their interactions with local residents, and the impact on social cohesion. Political scientists analyze the influence of migrants on electoral processes and political platform formation. Experts in technical fields use machine learning and big data analysis methods to identify patterns and trends in migration flows, as well as to forecast their potential economic and social consequences. In [3], Alina Sîrbu, Gennady Andrienko, Natalia Andrienko, Chiara Boldrini, Marco Conti, Fosca Giannotti, Riccardo Guidotti, Simone Bertoli, Jisu Kim, Cristina Ioana Muntean, Luca Pappalardo, Andrea Passarella, Dino Pedreschi, Laura Pollacci, Francesca Pratesi, and Rajesh Sharma (2021) analyze different stages of the migration process, comparing traditional and novel data sources and models at each stage. The authors consider three key phases of migration: travel, residence, and impact on the country of origin. The travel stage examines migration flows and stocks, with a focus on how big data can influence our understanding of these processes. The second phase emphasizes the incorporation of migrants in the host country. The review focuses on various datasets and models for quantitative assessment of adaptation, as well as the development of a new multi-level integration index. The third phase concerns the impact of migration on countries of origin and the issue of migrant return. Thus, the paper provides a comprehensive overview of how big data can be used to gain a deeper understanding of each stage of the migration process and how these data can help create new indices and models for assessing integration and the impact of migration. In their work, Aleksy Kwilinski, Oleksii Lyulyov, Tetyana Pimonenko, Henryk Dzwigol, Rafis Abazov, and Denys Pudryk (2022) [4] examine recent trends in international migration and analyze various perspectives on global migration processes, studying the impact of social, economic, environmental, and political determinants on regional and international migration. The aim of the paper is to analyze and compare causal relationships between international migration and the economic, environmental, and socio-political aspects of development in European Union (EU) countries and potential EU candidates. The paper also describes the methodology, including data collection and panel data analysis methods for the period 2000– 2018 using FMOLS and DOLS. The publication results include an analysis of the main economic, environmental, and socio-political determinants of international migration, such as wages, unemployment rates, income inequality (measured by the Gini coefficient), corruption, political stability (assessed by global governance indicators), CO2 emissions, and material footprint per capita (measured by the sustainable development index). The authors summarize the research findings by evaluating structural similarities and differences between EU countries and potential candidates, and analyze how these similarities and differences affect their response to economic conditions and changes. Mariusz Urbański (2022) in [5] compared the push and pull factors of migration between Poland and Romania. Using primary data from 298 surveys in Poland and 288 in Romania, the author applied a “push and pull” model in the study. The results showed that pull factors have a greater impact on migration in both countries than push factors. Specifically, economic pull factors were found to be key in all countries, while political factors had the greatest impact in Romania. The researcher concluded that addressing economic and political issues, such as instability and corruption, is crucial for reducing migration. Jonathan Portes and John Springford (2023) in [6] analyze the impact of Brexit on the UK labor market, particularly changes in the migration system. The authors examine how the cessation of free movement and the new migration system have affected the growth of the workforce in various sectors by comparing data before and after Brexit, as well as before and during the pandemic. The results show that the new system led to a reduction in the labor supply in certain sectors, especially those with low qualifications, while high-skilled sectors received more visas, aligning with pre-pandemic trends. This study highlights the importance of adapting migration policy to account for sectoral differences, which can help understand and regulate the impact of changes in migration systems on labor markets. Viorela Ducu, J. Jelle Lever, Julia Rone, & Áron Telegdi-Csetri (2024) in [7] explore the impact of migration on those directly involved in the process: both those who leave and those who stay. They note that there is significant divergence between different disciplines and theoretical approaches, such as mental health studies of migrants, political science studies of remittances, and economic studies of labor market impact. To reconcile these different approaches, the authors propose the concept of co-agency, which emphasizes the dynamic and interactive nature of migration. They stress that migration is a joint activity of both those who leave and those who stay, and that both groups actively influence migration processes and outcomes. Rather than focusing on the positive or negative aspects of migration, the authors call for a multi-level understanding of its complex interactions and consequences. Iwan Harsono, Himawan Sutanto, Ridwan Sya’rani (2024) in [8] investigate the impact of migration on the social and economic structures of the Indonesian region of Kalimantan, which has a long history of migration processes. In recent decades, migration patterns in this region have significantly changed due to urbanization, industrialization, and environmental changes. Quantitative analysis indicates a positive relationship between migration and social changes, as well as economic development, suggesting potential benefits of migration for cultural integration and economic growth. However, the authors emphasize the importance of context- specific policies to address issues such as infrastructure development and social cohesion, and note the need for further qualitative research for a deeper understanding of these processes. In addition to the broad range of scientific studies examining the impact of migration on the economy, there are also those focused on the relationship between migration flows and trade. Richard Bräuer and Felix Kersting (2023) in [9] analyze the economic and political consequences of a trade shock caused by the import of grain from America to Prussia during the first globalization (1870–1913). The authors show that this shock led to a decrease in employment and overall income; however, a reduction in per capita income or political polarization was not observed, which is explained by a strong migration response. The results indicate that the negative effects of trade shocks are not a universal feature of globalization but depend on labor mobility. For the analysis, the researchers used digitized data from Prussian censuses and national trade, as well as studied interregional variations in grain crops grown in Prussia and trade data from Italy and the USA. Yuan Tian (2024) in [10] explores how significant economic changes, such as trade liberalization, impact the institutions regulating internal migration, using China’s Hukou system as a case study. Using new data on migration policies at the prefecture level, the author documented an increase in regulatory norms for migrants following China’s accession to the WTO and assessed how changes in export tariffs affected migration rules. The results show that regions with greater liberalization of the export market introduced less restrictive rules for migrants. This indicates that migration policy and trade conditions can interact, shaping new dynamics in the labor market and influencing external trade. A significant portion of academic work is dedicated to applying various approaches to modeling migration and its impact on economic, social, and demographic processes. Among the primary approaches are econometric models, agent-based models, and machine learning models, which allow for forecasting and analyzing migration processes in the context of global challenges such as wars, economic crises, and climate change. Specifically, Jérôme Adda, Christian Dustmann, Joseph-Simon Görlach (2022) in [11] presented and evaluated a dynamic model that incorporates different abilities and location preferences of individuals to analyze the career evolution of immigrants in conjunction with their plans to return to their home countries. The analysis reveals a new form of selective return migration: immigrants who plan to stay longer invest more in skill acquisition, which impacts their career paths and earnings. The study also explains why immigrants are willing to accept lower-paying jobs compared to locals. The model provides important insights for developing migration policy, demonstrating how residence restrictions or achievement requirements shape immigrants’ career profiles, influence investment in human capital, and determine the choices of arrivals and those leaving. This understanding is crucial for analyzing the economic consequences of migration, as it explains how immigrants planning to stay longer may affect the labor market and consumer spending, which, in turn, may reflect on external trade. Haodong Qi, Tuba Bircan (2023) in [12] propose a new approach to modeling migration flows using a Flow Time-specific Gravity (FTG) model, which improves existing fixed-effects (FE) gravity models. They show that traditional FE models have limitations in explaining and predicting the temporal dynamics of migration, especially in the context of forced migration where processes are complex and heterogeneous. The FTG model, as confirmed by EUROSTAT data, provides more accurate forecasts when extending the analysis period. These findings are significant for improving migration forecasting methodologies and can be useful for developing more effective migration policies. Olivier Charlot, Claire Naiditch & Radu Vranceanu (2024) in [13] developed a model to analyze the market for smuggling forced migrants, based on empirical data regarding the illegal transportation of migrants from the Horn of Africa and the Middle East to Europe over the past decade. Comparative analysis of equilibrium decisions shows that coercive measures aimed at combating smugglers reduce the number of illegal migrants and smugglers but also decrease the overall welfare of migrants. Interestingly, a slight increase in opportunities for legal migration contributes to reducing illegal flows without negatively affecting migrant welfare or increasing the overall number of migrants. At the same time, extremely restrictive asylum policies have a similar impact on illegal migrant flows as more liberal policies, with the largest illegal flows observed under moderately strict policies. Chujian Shao (2024) in [14] analyzes skilled immigration through a dynamic general equilibrium model that accounts for endogenous labor migration and firm changes. It examines whether trade and immigration are substitutes or complements, as well as the effects of low barriers to labor mobility. The model shows that trade and immigration can be substitutes, with a negative impact of emigration of skilled workers on exporting countries, and an asymmetric impact on welfare in sending and receiving countries. Additionally, it demonstrates how immigrant flows affect the formation of new firms and labor costs. John O. R. Aoga, Juhee Bae, Stefanija Veljanoska, Siegfried Nijssen & Pierre Schaus (2024) in [15] investigate the impact of climate shocks on migration decisions, focusing on six agrarian- dependent countries: Burkina Faso, Ivory Coast, Mali, Mauritania, Niger, and Senegal. Using machine learning methods based on tree algorithms (specifically, XGB, Random Forest), they analyze how weather shocks, measured using the standardized precipitation-evapotranspiration index (SPEI), affect migration flows. The study shows that while weather factors improve forecasting accuracy, socio-economic characteristics have a more significant impact on migration intentions. Furthermore, the authors find that longer time scales of SPEI have a greater impact on international migration, while shorter time scales affect internal migration. It is also important to highlight the work by Serhii Kozlovskyi, Tetiana Kulinich, Ihor Vechirko, Ruslan Lavrov, Ivan Zayukov, and Hennadii Mazur (2024) [16], in which the authors explore the relationship between net migration volume and economic development in individual European countries, allowing for GDP forecasting and strengthening migration policy. Using correlation-regression analysis based on Eurostat and State Statistics Service of Ukraine data for the period 2014−2021 for specific European countries (EU-27 countries, Switzerland, and Ukraine), the study identified a relationship between net migration volume and GDP level. Linear correlation equations are used to forecast GDP values depending on net migration volume. Special attention is given to Poland, where migration contributes to economic growth due to the simplified procedures for relocating immigrants, ease of learning the language, geographical proximity, and a higher standard of living compared to neighboring former USSR countries. Specifically, an increase in net migration to Poland by 1% will lead to a GDP increase of 1.43 million euros. Due to the war between Russia and Ukraine, net migration from Ukraine to Poland has significantly increased, potentially raising Poland’s GDP in 2023 by 0.08% or 529.54 million euros. Unlike existing studies, which often focus on individual consequences of migration processes or specific economic indicators without a comprehensive approach, there is often a lack of systematic analysis of the interconnections between migration flows and economic changes at the level of individual countries or regions. To achieve a deeper understanding of the impact of Ukrainian migration due to the war on Poland’s trade indicators, a comprehensive analysis of migration and trade data is necessary. This will allow for a better assessment of the complex interrelationships and adaptation of policy to the real conditions and needs of society. 3. Methodology For the study, statistical data from Eurostat [17] was used. Specifically, information on Poland’s exports and imports was taken from the dataset “EU t At the initial stage, we constructed graphs (Figure 1) of these key indicators over time (Poland’s export and import flows, as well as data on asylum applicants from Ukraine). This allowed us to visualize changes over the study period and assess how significant geopolitical events (the onset of the conflict in 2014 and the full-scale invasion in 2022) affected Poland’s foreign trade indicators and Ukrainian migration processes to this country. The graphical representation of the data facilitated the identification rade since 1988 by HS2-4-6 and CN8,” which provides annual statistics by product categories. Additionally, data on asylum applicants by type, nationality, age, and sex from the dataset “Asylum applicants by type, citizenship, age and sex – annual aggregated data” was used, with a focus on Ukrainian citizens. This dataset provides annual figures on asylum seekers, measured in number of persons. The study period from 2008 to 2023 covers significant geopolitical events that have had a substantial impact on migration flows, including the conflict in eastern Ukraine and the annexation of Crimea by Russia in 2014, as well as the full-scale military invasion in 2022. These events have a direct impact on Ukrainian migration, which is a crucial aspect of our research aimed at modeling the impact of war-induced migration on Poland’s trade indicators using machine learning methods. of key trends and correlations, which became the basis for further analysis using machine learning methods. Figure 1: Dynamic Trends of Poland’s Trade and Ukrainian Asylum Applicants. From Figure 1, we can see that Poland’s imports demonstrate a general upward trend throughout the study period, while exports also show a growth trend with some periodic fluctuations. However, a significant increase in exports is observed in 2022, when exports reached their peak level. This trade dynamics could be related to economic and geopolitical changes. The number of asylum seekers from Ukraine shows sharp spikes in the context of key events, particularly in 2014 and 2022. This may indicate a close connection between migration processes and Poland’s external trade. The next step after the visual interpretation of the dynamic changes in the studied variables is to perform a correlation analysis to quantitatively assess the relationships between export volumes, imports, and the number of migrants (Figure 2). The correlation matrix helps to identify the degree and direction of these relationships, which serves as a basis for further application of machine learning methods. The correlation between imports and the number of asylum seekers is 0.404, indicating a moderate positive relationship, though this connection is not very strong. Similarly, the correlation between exports and the number of asylum seekers is 0.458, suggesting a moderate positive relationship. While these indicators suggest some interdependence between migration flows and foreign trade metrics, the intensity is relatively moderate. Figure 2: Correlation Matrix of Poland’s Trade and Ukrainian Asylum Applicants. These results highlight the need for a more in-depth analysis, as traditional correlation methods may not uncover complex nonlinear relationships. This justifies the use of machine learning methods, which can detect and model such nonlinear dependencies and provide more detailed insights into the impact of migration processes on economic indicators. To identify potential trends and patterns that might not be evident from simple correlation analysis, graphs (Figure 3) of the relationships between exports, imports, and the number of asylum seekers were created. These graphs allow for a visual tracking of dynamic changes in the data and reveal possible patterns that may not be explicitly represented in numerical correlations. Figure 3: Dynamic Trends between Poland’s Trade and Ukrainian Asylum Applicants. From the analysis in Figure 3, it is evident that the increase in the number of asylum seekers is accompanied by growth in both imports and exports, though with varying intensity. This suggests that, while there is some interconnection between the migration flows of Ukrainians and the foreign trade indicators of the host country, the nature of this relationship may be nonlinear. For a more detailed analysis and to uncover more complex dependencies, such as potential threshold effects or nonlinear models, the application of machine learning methods is advisable. This will provide a better understanding of the intricate patterns and relationships that are not always evident through simple correlation analysis. Various machine learning methods were used to analyze the dependencies between Poland’s imports, exports, and the number of Ukrainian asylum applications in the country. The choice of methods was based on the need to account for nonlinear relationships between variables that traditional linear models cannot capture. To achieve the best results, it was necessary to test different approaches, including both simple and complex models, for accurate prediction and pattern detection in the data. Among the methods used were linear regressions such as Lasso Regression (linear regression with L1 regularization) and Ridge Regression (linear regression with L2 regularization), which help avoid overfitting and select significant features; Polynomial Regression, which extends linear regression to model nonlinear dependencies using polynomial functions. Additionally, K- Nearest Neighbors (KNN) was applied, a nonlinear method that is based on the distance between points in feature space and determines results based on the average of neighboring points. Ensemble methods were also used, including Random Forest, which employs multiple decision trees to improve accuracy and reduce overfitting, and Gradient Boosting, which enhances results by incrementally adding models that correct errors from previous ones. XGBoost – an advanced decision tree with an improved gradient boosting algorithm and CatBoost, which trains based on multiple decision trees, were used to identify complex and nonlinear relationships between variables. The presence of dependencies among the studied indicators was also examined using methods for modeling nonlinear relationships through the construction of piecewise polynomials (Cubic Splines) and methods employing spline functions for nonlinear feature transformation (Spline Transformer). A generalized linear model with a gamma distribution for nonlinear dependencies (Statsmodels with GLMGam) was also applied. Model evaluation was based on three key metrics: Mean Absolute Error (MAE), Mean Squared Error (MSE), and R-squared (R2). Models with the lowest MAE and MSE values and the highest R2 values were identified as the best. 4. Results The first models tested were linear ones, such as Ridge Regression and Lasso Regression, which proved useful for initial analysis but did not demonstrate high accuracy. This indicates that simple linear models may be insufficient for capturing complex relationships in the data, especially when there is evident nonlinearity in the relationships. To better understand possible nonlinearities, methods capable of modeling more complex dependencies were employed. K-Nearest Neighbors (KNN) showed a significant improvement in prediction accuracy for exports. Polynomial Regression also indicated increased accuracy for exports, confirming the presence of nonlinear relationships between variables. Ensemble methods, such as Random Forest and Gradient Boosting, provided even better results. Gradient Boosting, due to its approach of incrementally improving models, achieved exceptionally high results, reflecting its high effectiveness in modeling complex, nonlinear dependencies. XGBoost and CatBoost, which are also powerful tools for dealing with nonlinear relationships, showed mixed results. XGBoost did not achieve competitive results compared to Gradient Boosting and Random Forest. In contrast, CatBoost demonstrated more significant achievements, indicating its effectiveness in modeling nonlinear relationships, though still falling short of the top results achieved by Gradient Boosting. Methods like Cubic Splines and Spline Transformer, which use nonlinear feature transformations, also showed high results. However, their accuracy was somewhat lower compared to Gradient Boosting, highlighting the advantages of ensemble methods in modeling complex relationships. Finally, models using statistical approaches, such as Statsmodels with GLMGam, showed lower accuracy compared to ensemble methods. This confirms that traditional statistical models are less effective in cases with significant nonlinearities. The numerical results of the study are presented in Table 1. Table 1 Modeling Results of Poland’s Trade Dependencies on Ukrainian Asylum Applicants Using Machine Learning Methods Machine Learning Method MAE MSE R2 (Import) Lasso Regression 32,457.32 1,377,119,408.26 0.084 Ridge Regression 32,457.32 1,377,119,341.39 0.084 Polynomial Regression 13,868.37 362,599,104.51 0.452 K-Nearest Neighbors (KNN) 11,800.79 269,891,799.13 0.592 Random Forest 5,589.26 54,640,560.67 0.917 Gradient Boosting 733.98 2,950,298.46 0.996 XGBoost 24,259.32 1,503,846,324.71 -0.00007 CatBoost 11,387.92 202,925,453.87 0.865 Cubic Splines 6,778.86 81,372,913.92 0.877 Spline Transformer 5,310.81 47,135,601.13 0.929 Statsmodels (GLMGam) 17,784.33 462,061,168.27 0.302 Machine Learning Method MAE MSE R2 (Export) Lasso Regression 18,406.33 422,536,540.09 0.168 Ridge Regression 18,406.33 422,536,509.74 0.168 Polynomial Regression 9,664.86 142,935,865.75 0.523 K-Nearest Neighbors (KNN) 7,660.00 98,974,286.92 0.670 Random Forest 3,784.71 22,339,751.14 0.925 Gradient Boosting 1,048.98 8,161,258.02 0.973 XGBoost 14,352.91 369,993,109.57 0.271 CatBoost 6,622.61 71,816,021.88 0.859 Cubic Splines 4,418.60 31,757,523.17 0.894 Spline Transformer 4,098.70 24,907,394.89 0.917 Statsmodels (GLMGam) 12,858.73 280,727,273.15 0.063 Based on these criteria, Gradient Boosting proved to be the most effective method for modeling the dependence of Poland’s foreign trade indicators on the number of Ukrainian migrants, demonstrating the highest accuracy and the smallest forecasting errors for both imports and exports compared to other machine learning methods. Gradient Boosting is a powerful method that provides high-quality predictions but does not generate explicit equations in the traditional sense, as linear or polynomial regressions do. This is because Gradient Boosting uses an ensemble of simple models (typically decision trees) to create a complex model made up of many decision trees. To visualize the modeling results, graphs were created (Figure 4) illustrating the obtained models. This allows for a clear assessment of the alignment between the predictions and the actual data. a) b) Figure 4: Modeling the Relationship Between Import of Poland (a) and Export of Poland (b) with Ukrainian Asylum Applicants Using Gradient Boosting. Gradient Boosting demonstrated a high level of effectiveness in modeling the relationship between Poland’s trade indicators and the number of Ukrainian asylum seekers due to its unique advantages. This method is characterized by its ability to accurately capture complex nonlinear relationships and interactions between variables, allowing for the creation of models with high predictive accuracy. Specifically, Gradient Boosting effectively handles diverse types of data and reduces the impact of noise, resulting in more stable outcomes. To ensure the reliability and accuracy of predictions for future trends, it is crucial to maintain the relevance of models through regular data updates and model validation with new data. In this study, using real data from 2008 to 2023, we implemented forecasting models for Poland’s imports and exports for the periods 2024–2026. Models were built both with and without considering the impact of the number of Ukrainian migrants. This approach allowed for a comprehensive assessment of accuracy and reliability in different scenarios, providing a deeper understanding of potential changes and their impact on Poland’s foreign trade indicators. The visualization of forecasting results (Figure 5) provides a clear comparison of the effects of different scenarios of migration flow changes on trade. a) b) Figure 5: Forecasts of Poland’s Trade Indicators (Import (a) and Export (b)) with and without Consideration of Ukrainian Asylum Applicants for 2024–2026 Using Gradient Boosting These graphs clearly depict how accounting for migration processes influences forecast changes. Such visual representation is especially important as it helps to better understand potential economic consequences and make informed decisions for strategic planning and economic management. The evaluation of forecasting model effectiveness, considering or not considering the impact of Ukrainian refugee migration flows on Poland’s foreign trade, was conducted using MAE and MSE metrics. The results (Table 2) showed that models incorporating data on the number of migrants provide significantly higher accuracy compared to models that do not account for this factor. Table 2 Performance Metrics of Forecasting Models for Poland’s Trade Indicators with and without Ukrainian Asylum Applicants for 2024–2026 Using Gradient Boosting Import MAE MSE With Ukrainian Asylum Applicants 22,460.06 536,387,434.68 Without Ukrainian Asylum Applicants 25,760.54 685,141,890.08 Export MAE MSE With Ukrainian Asylum Applicants 12,625.92 173,615,087.23 Without Ukrainian Asylum Applicants 13,269.75 195,286,812.11 Incorporating the external variable into the forecasting model leads to a reduction in both the mean absolute error and mean squared error for both imports and exports. This analysis allowed for the assessment of how including migration information impacts the accuracy of forecasting trade indicators for the host country, using Poland as an example, in the context of the significant increase in the number of Ukrainian refugees due to the Russia-Ukraine war. 5. Conclusions The war in Ukraine has acted as a catalyst for one of the largest migration waves in history, significantly impacting neighboring countries, particularly Poland. The influx of Ukrainian migrants has far-reaching socio-economic consequences, reflected in changes in Poland’s foreign economic relations. As of August 2024, Poland has taken in around one million Ukrainian refugees, creating new challenges for the country’s economic system that require in- depth analysis. At the same time, the influx of Ukrainian labor and the spending of migrants within Poland are stimulating economic growth, particularly in the production of goods and services, due to increased consumer demand. The changes in Poland’s economy resulting from migration are not limited to direct effects, such as filling vacancies and increased consumer demand. It is also important to consider indirect effects, particularly on foreign trade and macroeconomic stability. Migration flows can alter the structure of imports and exports, affecting the competitiveness of local businesses and creating new opportunities for international trade. The non-linear relationships between migration and Poland’s foreign economic indicators highlight the importance of using advanced analytical methods to gain a deeper understanding of these processes. Analyzing Poland’s foreign trade indicators in the context of migration processes, particularly using machine learning methods, allows for the identification of complex non- linear dependencies that traditional models may not capture. Specifically, the use of machine learning methods such as Gradient Boosting, XGBoost, CatBoost, and others has demonstrated effectiveness in modeling these dependencies, providing high forecasting accuracy and uncovering subtle patterns in the data. Our study demonstrates an integrative approach to analyzing the impact of large-scale migration on the economic indicators of host countries, specifically Poland. This approach not only expands the horizons of existing models but also reveals subtle and complex relationships between migration flows and foreign economic indicators. The use of various machine learning algorithms, such as Gradient Boosting, XGBoost, and CatBoost, provides deep and accurate analysis. In particular, the application of Gradient Boosting for modeling dependencies has shown its unique capability for precise forecasting, resulting in reliable predictive models for Poland’s imports and exports. Gradient Boosting’s ability to handle non-linear relationships and reduce the impact of noise has proven to be the most effective in forecasting. The developed forecasting model for the periods 2024–2026, taking into account the impact of migration processes, confirms that incorporating information about Ukrainian migrants significantly improves forecasting accuracy. This approach ensures the relevance and accuracy of results, opening new opportunities for developing political and economic strategies aimed at optimizing the benefits of migration processes and ensuring macroeconomic stability in the host country. The research not only expands the understanding of the economic consequences of the war in Ukraine but also provides tools for effectively managing these consequences in the future. It sets new standards in the analysis of migration effects and demonstrates a profound intellectual approach to using data and technology to address complex economic issues. This creates a valuable contribution to the development of political and economic strategies, fostering more effective management of the economic impacts of migration processes. Acknowledgements The author expresses gratitude to the French Research Center in Humanities and Social Sciences – CEFRES, Na Florenci 3, 110 00 Prague 1, Czech Republic (CEFRES, UAR 3138 CNRS–MEAE) for providing funding and support for this research project. References [1] “Situation Ukraine Refugee Situation”. Operational Data Portal. Application date: August 24, 2024. [Online]. Available at : https://data.unhcr.org/en/situations/ukraine/location/10781. [2] National Bank of Ukraine. “The influence of Ukrainian migrants on the economies of recipient countries”. National Bank of Ukraine. Application date: August 24, 2024. [Online]. Available at : https://bank.gov.ua/ua/news/all/vpliv-ukrayinskih-migrantiv-na- ekonomiki-krayin-retsipiyentiv. [3] Sîrbu, A., Andrienko, G., Andrienko, N. et al. Human migration: the big data perspective. Int J Data Sci Anal 11, 341–360 (2021).https://doi.org/10.1007/s41060-020-00213-5. [4] Kwilinski, A.; Lyulyov, O.; Pimonenko, T.; Dzwigol, H.; Abazov, R.; Pudryk, D. International Migration Drivers: Economic, Environmental, Social, and Political Effects. Sustainability 2022, 14, 6413. https://doi.org/10.3390/su14116413. [5] Urbański, M. Comparing Push and Pull Factors Affecting Migration. Economies 2022, 10, 21. https://doi.org/10.3390/economies10010021. [6] Portes, J., & Springford, J. (2023). The impact of the post-Brexit migration system on the UK labour market. Contemporary Social Science, 18(2), 132–149. https://doi.org/10.1080/21582041.2023.2192516. [7] Ducu, V., Lever, J. J., Rone, J., & Telegdi-Csetri, Á. (2024). Beyond ‘Those Who Leave and Those Who Stay’: the simultaneous impacts of co-agency in migration. Journal of Ethnic and Migration Studies, 1–26. https://doi.org/10.1080/1369183X.2024.2357827. [8] Iwan Harsono, Himawan Sutanto, Ridwan Sya’rani. “Migration Patterns and Social Change in Kalimantan Region: A Quantitative Study of The Impact of Migration in Changing Social and Economic Structures”, SNHSS, vol. 1, no. 01, pp. 14–24, Feb. 2024, doi: 10.58812/eccg7g18. [9] Richard Bräuer, Felix Kersting, Trade Shocks, Labour Markets and Migration in the First Globalisation, The Economic Journal, Volume 134, Issue 657, January 2024, Pages 135–164, https://doi.org/10.1093/ej/uead068. [10] Yuan Tian; International Trade Liberalization and Domestic Institutional Reform: Effects of WTO Accession on Chinese Internal Migration Policy. The Review of Economics and Statistics 2024; 106 (3): 794–813. doi: https://doi.org/10.1162/rest_a_01175. [11] Jérôme Adda, Christian Dustmann, Joseph-Simon Görlach, The Dynamics of Return Migration, Human Capital Accumulation, and Wage Assimilation, The Review of Economic Studies, Volume 89, Issue 6, November 2022, Pages 2841–2871, https://doi.org/10.1093/restud/rdac003. [12] Qi H, Bircan T (2023) Modelling and predicting forced migration. PLOS ONE 18(4): e0284416. https://doi.org/10.1371/journal.pone.0284416. [13] Charlot, O., Naiditch, C. & Vranceanu, R. Smuggling of forced migrants to Europe: a matching model. J Popul Econ 37, 18 (2024). https://doi.org/10.1007/s00148-024-00993-1. [14] Shao, Chujian, International Trade, Immigration and Macroeconomic Dynamics (April 25, 2024). Available at SSRN: https://ssrn.com/abstract=4807929 or http://dx.doi.org/10.2139/ssrn.4807929. [15] Aoga, J.O.R., Bae, J., Veljanoska, S. et al. Impact of Weather Factors on Migration Intention Using Machine Learning Algorithms. Oper. Res. Forum 5, 8 (2024). https://doi.org/10.1007/s43069-023-00271-y. [16] Serhii Kozlovskyi, Tetiana Kulinich, Ihor Vechirko, Ruslan Lavrov, Ivan Zayukov and Hennadii Mazur (2024). Relationship between net migration and economic development of European countries: Empirical conclusions. Problems and Perspectives in Management, 22(1), 605-618. doi:10.21511/ppm.22(1).2024.48. [17] Eurostat: https://ec.europa.eu/eurostat.