Introduction

The perception of fairness plays a critical role in fostering human cooperation and maintaining social order (Blake et al., 2015; Zhu et al., 2020). Generally, it is believed that those who gain more from social distribution perceive higher levels of fairness (Mezulis et al., 2004; Kluegel and Smith, 2017). However, within the context of China’s urban-rural dual structure, this logic does not fully apply. Some studies have found that, despite urban areas benefiting more from social development in terms of resources and opportunities, their residents do not necessarily exhibit stronger perceptions of fairness. In contrast, rural areas, which lag significantly behind in economic development, often report higher levels of perceived fairness (Zhou and Jin, 2018; Li, 2016; Wang and Liu, 2023; Li et al., 2023). This phenomenon challenges certain core assumptions of traditional fairness theories, suggesting that the factors shaping fairness perceptions in urban and rural areas may be more complex than previously understood.

Some scholars argue that fairness perception is not merely derived from a static observation of social distribution but results from a dynamic process of social comparison. For instance, the Tunnel Effect theory posits that fairness perception arises from comparisons with other lane groups (Hirschman and Rothschild, 1973; Davison and Bing, 2008). When low-status groups observe upward mobility among others, they develop positive psychological expectations(Ambrose and Kulik, 2001; Long and Feng, 2015). This partially explains why Chinese rural residents acknowledge the significant disparity between urban and rural development but still consider such inequality “tolerable” (Whyte and Im, 2014; Xie et al., 2012). Their fairness perception may be relatively high due to efforts to improve their lives and comparisons with their past or peers(Long and Feng, 2015). The impact of the tunnel effect on urban populations is more complex. Some scholars argue that they are less likely to compare themselves with the “slow lane” or groups in worse conditions than themselves, and are more influenced by the “tunnel environment,” the broader context of social development (Zhang, 2024). Consequently, even though they possess more resources, they may experience “fairness anxiety” due to slowing social development and intense social competition (Li, 2016). However, other scholars suggest that individual differences within urban areas are more pronounced, and lower and middleclass urban residents may still feel motivated and develop a stronger sense of fairness when comparing themselves to upper-class residents (Whyte and Im, 2014).

These urban-rural differences in fairness perception reflect a broader context of societal inequality, particularly in China, where the urban-rural divide has been institutionalized through the household registration (hukou) system. Existing studies on fairness perceptions highlight significant contextual differences between China and Western countries. Research in developed Western countries often focuses on the impact of macro external factors, such as distribution policies, welfare systems, income inequality, social mobility, and cultural values (Ugur, 2021; Hufe et al., 2022; Mengel and Weidenholzer, 2023; Tucker and Xu, 2023). However, these studies tend to overlook structural dimensions like urban-rural disparities. In contrast, China, once characterized by strong egalitarian arrangements, now ranks among the most unequal countries globally in terms of income distribution (Mu, 2022). This inequality is particularly evident in the urban-rural divide (Luo et al., 2019). The hukou system not only institutionalizes the division between urban and rural populations but also affects access to education, healthcare, employment, and social security (Wu and Treiman, 2004). As a result, urban and rural residents experience significant disparities in opportunity and distributive fairness, leading to differing perceptions of fairness (Huai, 2009; Li, 2016). Understanding these differences and their influencing factors is essential, as it enables developing targeted policies to enhance fairness perceptions across both urban and rural areas.

A detailed understanding of fairness perception is closely related to two fundamental principles of fairness: the “equity principle” and the “equality principle.” The former suggests that fairness should align with an individual’s input or contribution, reflecting procedural justice (opportunity fairness), while the latter emphasizes that social resources should be distributed equally or according to need among society’s members, reflecting distributive justice (outcome fairness). These two principles correspond to sense of opportunity fairness (SOpF) and outcome fairness (SOtF) (Jiang et al., 2023; Zhang et al., 2023). SOpF refers to the cognitive evaluation of procedural justice in the resource allocation process, emphasizing that an individual’s eligibility for social resources should depend solely on their abilities, not on inherent factors such as gender, race, or family background (Friedman and Friedman, 1979). SOtF, on the other hand, focuses on judgments regarding the equality of resource distribution outcomes, assessing whether the final allocation of explicit resources such as income and wealth aligns with fairness criteria (Hochschild, 1981). Many studies have found that socialist countries, including China, prioritize outcome fairness by allocating resources based on averages or social needs (Milton and Friedman, 1980; Parish, 1981) However, with China’s market reforms breaking down urban-rural barriers and strengthening the role of human capital, the openness of the social opportunity structure has significantly improved, leading to a shift towards pursuing opportunity fairness (Gijsberts, 2002). Education has become a key variable in predicting perceptions of opportunity fairness, while income levels primarily influence outcome fairness judgments (Xu et al., 2020). Notably, rural residents in China place more importance on SOpF than SOtF(Zheng and Huang, 2020). At the same time, increased information transparency brought about by the internet has intensified intergroup comparisons (Helsper, 2017), posing greater challenges to SOtF.

This research uses data from five waves (2013, 2015, 2017, 2019, and 2021) of the Chinese Social Survey (CSS) and applies principal component analysis to operationalize fairness into SopF and SOtF. We use the tunnel effect theory as the theoretical framework to categorize influencing factors into personal characteristics, family environment, social environment, and internet use. The study analyzes changes in perceptions between urban and rural areas in China and employs machine learning algorithms to explore these influencing factors. Figure 1 shows the analysis framework. The findings reveal that, (1) a positive tunnel effect exists in China’s urban and rural population, with rural residents exhibiting higher SOpF and SOtF than urban residents. Geographically, both SOpF and SOtF are higher in the western regions compared to the central regions. (2) Urban residents’ SOpF are mainly influenced by personal characteristics and social environment. In contrast, rural residents’ SOpF are influenced by personal characteristics, family environment, social environment and internet use. (3) For SOtF, urban people are influenced more by personal characteristics, family environment and social environment. However, rural people’s influencing factors are more diverse. This study identifies the factors influencing perceptions of fairness across urban and rural populations and provides targeted recommendations. It offers insights for policy optimization to enhance fairness perceptions among diverse groups in the future.

Fig. 1
figure 1

Analysis framework.

We made significant contributions to existing research in terms of perspective, content, and methodology.

Firstly, in perspective, while previous studies on fairness perceptions have addressed urban and rural populations (Zhou and Jin, 2018; Li, 2016; Wang and Liu, 2023; Li et al., 2023), they lack a systematic comparative perspective on urban and rural. Fairness perceptions are largely shaped by people’s subjective comparisons (Li, 2004; Huai, 2009), and socioeconomic disparities and structural changes make urban-rural comparisons a key dimension for understanding fairness perceptions in China. This research not only reveals the heterogeneity in fairness perceptions across different social groups but also enriches existing theoretical frameworks on social fairness.

Secondly, in content, previous research on fairness perceptions has often focused on the macro level, such as overall societal fairness (Wright and Merritt, 2020; Zhu et al., 2020), or specific micro-level domains, such as price fairness (Alderighi et al., 2022) and education fairness (Darabi Bazvand and Rasooli, 2022; Rezai et al., 2022). However, there has been a lack of systematic exploration of the internal structure of fairness perceptions. By distinguishing between two core dimensions—opportunity fairness and distributive fairness—this study addresses this gap and delves into the key influencing factors of different types of fairness perceptions.

Finally, in methodology, this research is the first to apply machine learning models to analyze fairness perceptions, introducing methodological innovation. Traditional research methods, such as regression analysis, often face limitations in variable selection and biases from model assumptions. Machine learning allows for a more comprehensive exploration of the complex impacts of multiple variables on fairness perceptions, improving both predictive accuracy and explanatory power.

Theory and literature review

Theoretical background

The tunnel effect theory (Hirschman and Rothschild, 1973) suggests that groups of different social statuses are like cars stuck in two lanes of a tunnel. When lower-status groups observe others moving upward, they interpret this as a positive signal of their own potential to improve their lives rather than feeling unfairly treated. This leads them to tolerate inequality in the short term, known as the positive tunnel effect. However, if the slow lane remains blocked for too long, frustration and a strong sense of unfairness emerge, which is referred to as the negative tunnel effect (Knight, 2013). The manifestation of the tunnel effect is influenced by various factors, particularly expectations of social mobility, social cognition, and reference groups.

First, the expectation of social mobility is the core premise of the tunnel effect. Social mobility expectations refer to individuals’ psychological anticipation of future class mobility, shaped by their personal circumstances and the broader societal environment. These expectations are influenced by both individual factors and institutional factors (Chen and Zhang, 2018). Cross-national studies show that even in highly unequal countries, a strong sense of fairness can persist because low-income groups believe they can improve their lives through effort (Ugur, 2021). However, when social mobility declines, this belief weakens, leading to reduced perceptions of fairness. Furthermore, declining social mobility is closely linked to a sense of unfairness. For instance, researchers have found that in the U.S., the influence of parents’ education and occupation on the next generation’s income has significantly increased, indicating a growing impact of family background on opportunity fairness, exacerbating social stratification and lowering individuals’ fairness perceptions (Hufe et al., 2022), Similar findings have been observed in South Korea, where lower-status individuals experience heightened relative deprivation and significantly reduced fairness perceptions when they perceive limited opportunities for mobility (Cho and Kim, 2024).

Second, social cognition and cultural context also affect the tunnel effect. Studies indicate that in societies that emphasize individual effort, low-income groups are more likely to view inequality as motivation to improve their status, making them more tolerant of existing inequalities (Ugur, 2021). In contrast, in European countries with higher transparency and a greater emphasis on distributive equality, social inequality tends to provoke stronger feelings of unfairness (Alesina et al., 2004). Additionally, different cultural traditions shape perceptions of fairness and tolerance for inequality. Confucian ethics emphasize harmony and responsibility within groups, viewing certain degrees of favoritism as an expression of fairness. Meanwhile, Western ethics focus on equal value for individuals and impartiality (Palais, 1984; Asma, 2012). This cultural difference results in higher tolerance for inequality in countries influenced by Confucian traditions, while Western societies are more likely to experience a loss of fairness perception due to inequality.

Furthermore, reference groups are an important factor influencing the tunnel effect, with their mechanisms differing significantly depending on the type of reference. For example, when individuals use internal wage levels as a reference, this can signal positive expectations for future income growth (Mohrenweiser and Pfeifer, 2023), thereby triggering the tunnel effect and enhancing workers’ satisfaction. In contrast, when individuals compare themselves to external wage levels, a sense of relative deprivation tends to increase significantly, reducing perceptions of fairness. This phenomenon has also been validated in specific social contexts. For instance, during the COVID-19 pandemic, people who compared themselves to those more severely affected were more likely to feel relatively advantaged, which enhanced their perceptions of social fairness and encouraged more prosocial behaviors (Syropoulos and Markowitz, 2021).

Some research on China has also confirmed the existence of the tunnel effect. The theory presents unique characteristics in the context of China’s urban-rural dual system and the urbanization process. Unlike the classic tunnel effect in Western societies, which is based on income mobility, China’s household registration system has placed urban and rural residents into separate “fast lanes” and “slow lanes.” This structural social stratification leads to a fundamental division in the fairness perception mechanisms between urban and rural groups: although urban residents have more abundant material conditions, the cost of maintaining their status is higher, and their fear of downward mobility is stronger (Lui and Liu, 2019). This makes them more likely to experience relative deprivation and a lower sense of fairness (Li, 2016). In contrast, the rural population, despite objectively facing significant disparities in urban-rural development levels, tends to view this inequality as “tolerable” (Whyte and Im, 2014; Xie et al., 2012). Moreover, rural residents have access to land resources, which makes them more likely to perceive the existence of mobility channels, such as increasing income and improving living conditions through migrant work. It is important to note that the household registration system is not an insurmountable barrier; in the process of marketization, rural residents can acquire urban status through measures such as improving their educational level or purchasing urban property (Cuihong et al., 2023), thus entering the “fast lane.” Therefore, rural residents tend to interpret the current inequality as a necessary cost for upward mobility, continuously reinforcing their belief in the effectiveness of mobility channels and maintaining a high level of perceived fairness (Xiao et al., 2024).

Based on this, we propose Hypothesis 1:

H1: Rural residents have a stronger sense of fairness compared to urban residents.

Factors influencing urban-rural fairness sense

Based on existing literature and the theory of the tunnel effect, the influencing factors of fairness perception can be categorized into four types: personal characteristics, family environment, social environment, and internet usage. Among these, personal characteristics and family environment serve as the starting resources for individuals entering the “tunnel,” the social environment provides the macro-context of the tunnel, and internet usage acts as a critical tool for increasing the tunnel’s transparency.

Personal characteristics

Personal characteristics as one of the “initial conditions” for individuals entering society, which influence individuals’ expectations regarding social change (Gavrilets 2021). Which means that individuals’ perceptions of fairness are affected by comparisons with those around them. Personal characteristics (e.g., education level, age, gender) determine their position in social comparisons and their ability to improve their situation through social mobility (e.g., education or career advancement).

Previous research has shown that individual characteristics, such as age (Li, 2016), education (Della Fave, 1980; Wu, 2011), and gender (Ye et al., 2016), significantly impact perceptions of fairness. For example, scholars have demonstrated that age plays a crucial role in how people assess social fairness. Different age groups represent different social experiences and life stages. Studies have found that children as young as three understand the concept of fairness and show a strong aversion to inequality (Huang et al., 2023). As they age, they tend to consider inequality more comprehensively. Generally, older individuals tend to be more tolerant, easily satisfied, and have a stronger sense of fairness (Li, 2016).

Moreover, existing research generally suggests that people’s level of education is closely related to their perceived sense of fairness (Della Fave, 1980; Wu, 2009; Sha et al., 2024). However, scholars differ in their views on the specific impact of education. Some argue that the disparity in education quality between urban and rural areas in China, along with the institutional barriers of hukou, puts rural residents at a disadvantage (Zhang, 2017). The hukou system strictly limits rural children from attending public schools in urban areas. Furthermore, studies have found that a 1% increase in urban-rural education inequality leads to a 6.4% increase in income inequality between urban and rural areas (Wen, 2007). Therefore, due to inequalities in educational access and outcomes, rural residents tend to perceive higher levels of unfairness compared to urban residents.

However, other scholars hold opposing views. Their research shows that urban residents have 40% higher educational expectations than rural residents (Lei and Shen, 2015), which can lead to stronger feelings of unfairness among urban residents. According to the theory of the socialization of education, those with higher education levels, who have a richer knowledge base and stronger cognitive abilities, have a more direct and deeper understanding of overall social inequalities across regions, sectors, and demographics. In contrast, those with lower education levels, due to limited knowledge and cognitive capacity, may underestimate the actual extent of social inequalities (Zhang and Li, 2024). Therefore, under the influence of education, urban residents may perceive less fairness compared to rural residents.

This research draws on these individual characteristic factors from existing literature and incorporates additional potential factors, such as the survey respondents’ generational cohort, marital status, party membership, residential area type, homeownership, employment status, and social security situation. These personal attributes can also influence perceptions of fairness between urban and rural areas, a topic that has received limited attention in current literature.

The above research demonstrates the impact of personal characteristics on the fairness perception of urban and rural hukou populations. Based on this, we propose the following hypotheses:

H2a: Personal characteristics are the main influence on the fairness sense of urban hukou populations.

H2b: Personal characteristics are the main influence on the fairness sense of rural hukou populations.

Family environment

The family environment, as another “initial condition” for individuals entering society, plays a significantly different role in shaping perceptions of opportunity fairness and outcome fairness, particularly in the context of urban-rural disparities. It also directly impacts “horizontal comparisons” in the tunnel effect. Existing research divides the family environment into economic capital and cultural capital.

First, economic capital is reflected in a family’s socioeconomic status (SES) and income levels. A family’s economic condition affects individuals’ perceptions of their social status. If a family is economically affluent, individuals are more likely to perceive fairness in opportunities; conversely, poverty may lead individuals to attribute unfairness to structural issues in society. For example, some studies have found growing up in a low SES environment often requires more effort to sustain daily life, which can lead to a heightened sense of unfairness (Bauer et al., 2014). Similarly, household income levels affect fairness perceptions; children from low-income families are more likely to feel a sense of unfairness (Mu, 2022). Statistics show that the income level in urban areas of China is 2.69 times that of rural areas (Xiao and Zhong, 2020; Zhao et al., 2021). This substantial income gap may lead rural residents to question social equity and express dissatisfaction, especially when they see urban residents enjoying more resources and opportunities, which could further amplify feelings of unfairness.

Second, cultural capital highlights the importance of family educational background. Well-educated parents are more likely to instill values of fairness in their children (Huang et al., 2023). Additionally, parents’ educational attainment can shape children’s expectations (Lei and Shen, 2015), potentially leading them to hold higher expectations and demands for social fairness. Urban families typically have higher education levels, meaning they are more likely to pass on values of fairness and justice to their children. In contrast, due to limited educational resources and the influence of traditional culture, parents in rural areas may have relatively lower education levels, making it challenging to impart a strong sense of fairness to their children. Therefore, educational disparities between urban and rural areas may lead to differences in children’s perceptions and attitudes towards fairness.

Moreover, some scholars have also focused on the impact of family size on perceptions of fairness. Compared to single-child families, families with siblings create more opportunities for internal competition, leading children in these families to be more concerned with fairness (Lu and Chang, 2018). In China, urban areas, which have strictly enforced the one-child policy, typically consist of nuclear families with a single child, while rural areas have traditionally favored multi-child families. This structural difference in family composition may also influence perceptions of fairness between urban and rural areas to some extent.

In this research, we consider family size, parental education levels, household income, and socioeconomic status (including current, past, and expected SES) as family factors to explore how these factors affect perceptions of fairness between urban and rural people.

The above research shows that various factors within the family environment significantly affect the fairness sense of urban and rural hukou populations. Accordingly, we propose the following hypotheses:

H3a: The family environment is the main influence on the fairness sense of urban hukou populations.

H3b: The family environment is the main influence on the fairness sense of rural hukou populations.

Social environment

The social environment forms the core backdrop of the tunnel effect. In China, discrepancies between individuals’ hukou registration and their actual place of residence have become increasingly prevalent. A large number of rural hukou holders migrate to urban areas in search of economic opportunitiesFootnote 1 (Wu et al., 2019; Xu et al., 2023) meaning they are more influenced by social environments outside rural areas, especially economic development levels and employment conditions. The social environment refers to the broad context of survival and development (Liu et al., 2023), with regional economic prosperity and employment conditions being critical considerations. Some evidence suggests that economically developed regions offer more job opportunities but also involve more intense competition. Rural populations, due to factors such as hukou, language, and cultural habits, are more likely to experience social exclusion, resulting in lower perceptions of fairness (Wu et al., 2019; Zuo and Huang, 2025). However, other researchers argue that compared to urban residents, rural residents may hold stronger expectations for social mobility, enabling them to tolerate current inequalities and maintain a higher level of fairness perception (Huntington, 2006; Whyte and Im, 2014). For urban residents, the influx of rural populations into economically developed areas may crowd out job opportunities, triggering dissatisfaction and a sense of unfairness (Yi and Li, 2022).

In this research, regional GDP and unemployment rates are used to measure the social environment.

Existing studies indicate the significant role of the social environment in shaping the fairness sense of urban and rural hukou populations. Based on this, we propose the following hypotheses:

H4a: The social environment is the main influence on the fairness sense of urban hukou populations.

H4b: The social environment is the main influence on the fairness sense of rural hukou populations.

Internet use

The tunnel effect theory posits that information asymmetry can influence a group’s perception of fairness. Internet usage significantly expands the breadth and depth of information access, thereby altering fairness perceptions. Internet use has significantly influenced individuals’ perceptions of fairness (Van Praag, 2011). Internet users generally perceive lower social fairness than non-users (Wu, 2009; Zhang et al., 2023), with this effect differing between urban and rural people (Zhu et al., 2020). According to data from the China Internet Network Information Center (CNNIC), internet penetration in Chinese cities surged from 10.5% in 2006 to 83.1% in 2022, while rural areas saw an increase from 3.1% to 61.9%. Scholars have noted that the impact of digital internet on urban residents’ sense of fairness is more pronounced, primarily because the internet facilitates social comparisons through information browsing, leading to feelings of relative deprivation and frustration, which in turn diminish their sense of fairness (Stutzer, 2004). Although rural residents also experience social comparisons from internet information, they use the internet less frequently than urban residents. More importantly, the internet has increased their social interactions with friends and relatives, especially with family members who stay at home, such as wives, the elderly, and children (Ye et al., 2016). This enhances rural residents’ social identity and sense of belonging, thus improving their sense of fairness by addressing higher-level needs in Maslow’s hierarchy (Stoyanov, 2017; Zhu et al., 2020).

The above research suggests that internet use impacts the fairness sense of urban and rural hukou populations. Consequently, we propose the following hypotheses:

H5a: Internet use is the main influence on the fairness sense of urban hukou populations.

H5b: Internet use is the main influence on the fairness sense of rural hukou populations.

Data and methods

Data source

This research utilizes CSS data conducted in 2013, 2015, 2017, 2019, and 2021, which have been widely used by scholars to investigate the sense of fairness in China (Li, 2019; Zhu et al., 2020; Lu and Zhang, 2021; Zhang et al., 2023).

Variable selection and construction

Dependent variables

In this research, fairness perception measured by the CSS questionnaire items: “How fair do you think the following aspects of social life are currently?” (4-point scale: 1 = very unfair, 2 = somewhat unfair, 3 = relatively fair, 4 = very fair). This question includes 8 sub-dimensions. According to the research by Zhang et al. (2023), SOpF emphasizes equal rights and opportunities for everyone to achieve success, which reflected in people’s actual enjoyment of political rights, judicial and law enforcement, job and employment opportunities, and the college entrance examination system. In contrast, SOtF focuses on the relative equal distribution of resources such as property and income. pertains to disparities in rights and treatment between urban and rural areas, wealth and income distribution, public healthcare, and access to pensions and other social security benefits. Therefore, we first categorize data into the same category. Secondly, we applied the Principal Component Analysis (PCA) method to assign weights to SOpF and SOtF. The KMO values for SOpF and SOtF are 0.745 and 0.763, with both Bartlett’s P-values being less than 0.001, indicating suitability for PCA. When both fairness perceptions only exceed a Cumulative Contribution Rate (CCR) of 0.8 after the inclusion of the first three subdimension variables, the cumulative contribution rate for each type of fairness exceeds 0.8. Therefore, we select the first three variables for SOpF and SOtF. See Table 1 for details.

Table 1 Subdimension variable and CCR value of SOpf and SOtF.

Predictive variables

Following the research of Sha et al. (2024), Zhu et al. (2020), Lin and Xiao (2021), and Chen (2023), twenty predictive variables were included in the aspects of individual characteristics, family environment, social environment, and internet use.

Table 2 shows the abbreviations and the operational definition of all variables, and Appendix Table 1 shows the basic information of these variables.

Table 2 The abbreviations and the operational definition of all variables.

Research method

Data cleaning and processing

This research conducted separate cleaning procedures for the dependent and predictor variables.

For the dependent variable, since this research focuses on perceptions of opportunity fairness and outcome fairness among urban and rural hukou populations, data from CSS 2013, 2015, 2017, 2019, and 2021 were retained based on specific CSS survey items. The processing of the dependent variables involved two steps. First, each type of fairness perception consisted of four items, and samples with missing data for these items were removed (responses marked as “uncertain” were also excluded). Second, cases with missing hukou information or responses marked as “not applicable” were eliminated. As a result, 4254 samples were removed in 2013, leaving 5952; 3,123 samples were removed in 2015, leaving 7120; 2934 samples were removed in 2017, leaving 7209; 2797 samples were removed in 2019, leaving 7486; and 2,211 samples were removed in 2021, leaving 7647. In total, 35,414 samples were retained, comprising 12,620 urban hukou cases and 22,794 rural hukou cases. Detailed data distribution is provided in Appendix Table 2.

For predictor variables, to prevent bias caused by excessive missing data, missing values were imputed following existing research. Numerical features were filled with mean values, while categorical features were imputed using mode values (Zhu and Wu, 2025). This targeted imputation method helps reduce bias and ensures the robustness and accuracy of subsequent analyses. The missing values for each predictor variable are detailed in Appendix Table 3. Additionally, extreme values within the variables were identified and removed using a machine learning model.

Gradient boosting regression model

The core variable of this research, fairness perception, is a psychological and sociological concept with complex, non-linear influencing factors. Moreover, sense of fairness is a continuous variable derived from principal component analysis, rather than a binary variable. Therefore, mainstream classification models in machine learning are not suitable; instead, regression models are appropriate. This study uses the Gradient Boosting Regression Model (GBR), an ensemble learning method widely used for regression problems. The GBR model can model potential non-linear relationships in the data and explain interactions between different variables. Additionally, the GBR model has a built-in feature selection mechanism that handles interaction effects among variables. Factors such as age and gender do not influence fairness perception independently but interact and work together, and the GBR model effectively manages these complex interactions. Lastly, the GBR model is robust in handling outliers and missing values, ensuring stable results.

The experimental steps for the GBR model are as follows: Initially, the base model predicts the training data, and the residuals (errors) between the actual and predicted values are calculated. The residuals are then used as a new target variable to fit another base model. This process is repeated, with each successive model aiming to capture the residuals that the previous model could not explain. Each model in the sequence attempts to correct the errors of the previous model. Finally, the predictions of all base models are summed, with each model’s prediction scaled by the learning rate to minimize its impact.

To assess the prediction accuracy of the Gradient Boosting Regression Model, we employ 10-fold cross-validation, which involves multiple validations on different training and testing datasets. In this study, we use an 80:20 split strategy, training the model on 80% of the data and testing it on the remaining 20%. The number of decision trees is set to 100, meaning the model will iterate 100 times, with a learning rate of 0.1. The maximum depth of each tree is limited to 3 to prevent overfitting. The minimum number of samples required for a node split is 2, and the minimum number of samples in a leaf node is 1, avoiding overly complex tree models. Evaluation metrics include Mean Squared Error (MSE), Root Mean Squared Error (RMSE), and Mean Absolute Error (MAE). The calculations for these metrics are as follows:

$$MAE=\frac{1}{n}\mathop{\sum}\limits_{M+1}^{M+n}\mathop{\sum}\limits_{\ast}|{\mathop{x}\limits^{\frown}}_{t}^{\ast}-{x}_{t}^{\ast }|$$
$$MSE=\frac{1}{n}\mathop{\sum }\limits_{M+1}^{M+n}\mathop{\sum}\limits_{\ast }|{{\mathop{x}\limits^{\frown {}}}_{t}^{\ast }-{x}_{t}^{\ast }|}^{2}$$
$$RMSE=\sqrt{\frac{1}{n}\mathop{\sum }\nolimits_{M+1}^{M+n}\sum _{\ast }{|{\mathop{x}\limits^{\frown}}_{t}^{\ast }-{x}_{t}^{\ast }|}^{2}}$$

M and n represent the number of in-sample and out-of-sample estimates, respectively. \({\hat{{x}_{t}}}^{* }\) denotes the predicted values, while \({{x}_{t}}^{* }\) represents the actual values. The three metrics measure the deviation between predicted and actual results; smaller deviations indicate that the model can effectively predict outcomes. Tables 4 and 5 in Appendix show basic parameters of the GBR model. All analyses were conducted in the Python 3.9 statistical computing environment. In this study, we tested the MAE, MSE, and RMSE for data on perceived fairness of opportunities and outcomes in both urban and rural areas across different years and then consolidated the annual data for a comprehensive test. Across all datasets, the maximum MAE is 0.474, the maximum MSE is 0.616, and the maximum RMSE is 0.785, all within acceptable ranges. This indicates that the Gradient Boost model performs well across the datasets, suggesting that selecting the GBR Model for this dataset is reasonable.

SHAP model

Although the GBR model has strong predictive power, its “black-box” nature often makes the interpretation of its outputs challenging. In addressing social issues, it is critical to present complex analysis results clearly to the public and policymakers. SHAP (SHapley Additive exPlanations) provides a visual and interpretable explanation for GBM results. SHAP can handle continuous data and accurately quantify the marginal contribution of each variable. SHAP model is an interpretable machine learning model used to explain model predictions by quantifying the contribution of each feature to the model’s output, based on Shapley theory. The SHAP principle is as follows: for a given set, calculating the Shapley values requires considering all possible permutations of feature subsets. SHAP proposes an approximate calculation method based on local contributions by creating a virtual dataset similar to the target sample, perturbing each feature, and calculating each feature’s local contribution to derive the Shapley values. This method not only ensures high computational efficiency but also guarantees the accuracy of local features and global consistency. In this study, we used SHAP values to create SHAP plots to further illustrate the specific effects of independent variables on the dependent variable. The contribution rate of different variables was measured by the proportion of each factor’s SHAP value to the total SHAP value. The formula for calculating the SHAP value of each individual is as follows:

$${\varphi }_{{\rm{i}}}=\mathop{\sum}\limits_{S\subseteq N\backslash \{i\}}\frac{|S|!(|N|-|S|-1)!}{|N|!}(\nu (S\cup \{i\}))-\nu (S)$$

Among them, N represents a dataset, \(|N|\) denotes the number of individuals in the dataset, and S represents the combination of individuals. \(S\subseteq N\backslash \{i\}\) denotes the entire subset obtained after removing features i from N. \(\nu (S\cup \{i\})-\nu (S)\) represents the average marginal contribution of including i relative to excluding it, which occurred \(S|(!|N|-|S|-1)!\) times in total.

Results and analysis

Spatial-temporal differences in senses of fairness between urban and rural areas

This research first employs a T-test to examine the temporal dimension of differences in perceptions of fairness between urban and rural areas in China (results shown in Table 3). Next, spatial distribution maps are used to analyze differences across the spatial dimension (results shown in Fig. 2)Footnote 2.

Table 3 T-test results for urban and rural fairness sense.
Fig. 2
figure 2

Distribution of sense of fairness in urban and rural hukou.

As shown in Table 3, our experimental data from 2013 to 2021 indicate that both SOpF and SOtF are significantly higher in rural areas than in urban areas and confirm H1. This finding further supports further supporting the existence of a positive tunnel effect on fairness perception between urban and rural populations. Rural hukou residents can tolerate current social inequalities and remain optimistic about future development (Zhou and Jin, 2018; Li, 2016; Wang and Liu, 2023; Li et al., 2023). However, it is important to note that while the positive tunnel effect may ease social dissatisfaction in the short term, if future expectations are not realized (e.g., persistent urban-rural gaps or unequal policy benefits), this “tolerance” could transform into a “negative tunnel effect,” leading to stronger perceptions of unfairness and social conflict.

Figure 2 shows the geographic distribution of SOpF and SOtF in urban and rural population of China. Overall, significant differences exist between urban and rural groups, as well as across regions. Both urban and rural residents generally have higher SOpF than SOtF. Specifically, urban residents’ SOpF exhibits a spatial pattern of “high in the periphery, low in the center,” with higher values in eastern and western regions and relatively lower values in central regions such as Anhui and Henan provinces. A similar trend is observed for rural residents, with weaker SOpF in central regions (e.g., Shanxi, Henan, Hebei, Hunan, and Hubei provinces).

In terms of SOtF, urban residents in western regions such as Qinghai and Sichuan provinces have relatively high scores, while central regions score lower. In contrast, rural residents display more pronounced regional differences in SOtF, showing a clear “high in the west, medium in the east, and low in the center” spatial pattern. Tibet scores the highest, followed by Gansu province.

Considering the economic development levels of central regions, which fall between the eastern and western regions, the eastern regions attract substantial foreign investment and high-end industries due to open policies, while the western regions benefit from special development opportunities due to national policy support. The central regions, lacking a distinct competitive advantage, have lower SOpF. Notably, fairness perception in Qinghai province (both urban and rural, and for both SOpF and SOtF) stands out as relatively high nationwide. This may result from a combination of national policy support and socio-cultural factors. Existing research suggests that in economically underdeveloped areas, policy interventions and resource allocation are critical. Redistribution can effectively enhance fairness perception (Galasso 2003), offering valuable lessons for similar regions.

Analysis of key factors influencing senses of urban-rural SOpF

We used the GBR model and generated SHAP model to analyze the factors influencing SOpF in urban and rural Hukou. In a SHAP plot, each point represents a sample, and the features assessed by the model are ranked in descending order of importance on the y-axis. The color of each point indicates the value of the feature, with red representing relatively high values and blue representing relatively low ones, and purple for mid-range values. The distance between points on the x-axis represents the magnitude of the feature’s impact on the perception of fairness, where positive values indicate a positive impact, and negative values indicate a negative impact. In this study, a positive impact means a stronger perception of fairness, while a negative impact means a weaker perception. For each subset of data, we generated SHAP mean plots and SHAP value plots, displaying the importance of various features in descending order.

Figure 3 shows the SHAP plot for the factors influencing SOpF in urban Hukou, while Fig. 4 shows the same for rural Hukou. Following convention, the top five indicators are deemed primary factors, and we analyzed in detail (Chen et al., 2023). As seen in Fig. 3, the top five factors influencing urban SOpF are personal attributes (age, generation, education, residential area type) and the social environment (GDP); H2a and H4a are preliminarily confirmed. However, the factors influencing rural hukou are more complex, including personal attributes (age, education level), internet usage, the social environment (GDP), and family factors (current socioeconomic status), which means H2b, H3b, H4b, and H5b are preliminarily confirmed.

Fig. 3
figure 3

SHAP diagram of factors influencing SOpF of urban hukou.

Fig. 4
figure 4

SHAP diagram of factors influencing SOpF of rural hukou.

Specifically, among urban residents, age contributes the most to SOpF (average contribution is 0.12) and shows a predominantly positive effect: the older the individual, the stronger their perception of opportunity fairness. This finding aligns with existing literature: according to the life-cycle theory, as people age, their social experiences and sense of control over opportunities increase, which strengthens their SOpF. The second key factor is GDP (average contribution is 0.09), also showing a positive effect. High GDP levels are generally associated with more resources and job opportunities, providing broader channels for social mobility. Urban residents in high-GDP regions may develop a positive “expectation effect” when observing the success of others, believing they can also access fair opportunities in such an environment (Hirschman and Rothschild, 1973). Conversely, in regions with low or middle-level GDP, slow economic growth can weaken urban residents’ confidence in the future, reducing their perception of opportunity fairness. The third factor is the generation (average contribution is 0.07). Similar to the age effect, individuals born in earlier generations (e.g., those born in the 1950s or 1960s) have significantly stronger perceptions of opportunity fairness compared to younger generations. This may be because they experienced eras of scarce resources and opportunities, making them more aware of social progress and the increase in opportunities over time. The fourth factor is education, which also has a complex influence (average contribution is 0.06). The overall pattern presents as a “sandwich effect” (Gong, 2010). For individuals with moderate education levels (e.g., high school, vocational schools, or technical schools), the effect on opportunity fairness is negative, while the effect is more positive for those with higher or lower education levels. Highly educated individuals signal positively in the labor market, thereby securing educational dividends that reinforce their economic position (Spence, 1978). For those with lower education levels, education serves to reproduce their original social class and cultural position (Broadfoot, 1978). Once basic education is attained, they can benefit from it and observe upward mobility opportunities. However, individuals with intermediate education levels may find themselves in a gap of perceived opportunity, where their education allows them to see potential mobility channels, but these channels are limited by scarce resources and educational barriers. Therefore, for the intermediate-educated group, “education signal failure” (Soltow, 1977), which may potentially be lowering their SOpF.

Lastly, residential area type also affects urban residents’ SOpF (average contribution is 0.05). Those living in commercial housing, upscale neighborhoods, or redeveloped communities have a higher SOpF, while residents in older, unreconstructed communities or mixed-use neighborhoods report lower SOpF. For residents in older communities, observing the rapid development of other areas may heighten their awareness of the significant disparity in living conditions, leading to a sense of unequal opportunity distribution and, consequently, lower SOpF.

For rural hukou residents, age is also a key factor influencing SOpF (average contribution is 0.25), with a similar effect to that seen in urban samples: older individuals have stronger SOpF, while younger individuals perceive it as weaker. This finding reaffirms existing studies, which suggest that older rural residents are more likely to view social changes and economic development as signs of expanded fair opportunities, demonstrating a significant tunnel effect. Secondly, internet use has a relatively greater impact on rural residents’ SOpF (average contribution is 0.1), with a negative effect. Although the internet provides abundant information resources, rural residents generally have lower digital literacy due to differences in access, content selection, and interpretation abilities. As a result, they may struggle to effectively use the internet to access education, training, or employment opportunities, leading to a sense of unequal opportunities. Third, education (average contribution is 0.09) shows a similar pattern to urban samples. Individuals with moderate education levels negatively affect SOpF, while those with low or high education levels contribute positively. Fourth, GDP (average contribution is 0.07) has a more complex influence, particularly in regions with moderate GDP levels. These regions often face both development potential and structural contradictions. On the one hand, economic growth may bring more resource investment and policy support, improving opportunities for rural residents in employment and education, thereby enhancing fairness perception. On the other hand, economic imbalances may exacerbate regional disparities in resource distribution and opportunity access, weakening SOpF. Lastly, current socioeconomic status has an overall positive effect (average contribution is 0.06): the higher a rural resident’s socioeconomic status, the stronger their SOpF. Higher-status groups benefit from more favorable positions in resource allocation, reinforcing their SOpF.

Analysis of key factors influencing senses of urban-rural SOtF

Figures 5 and 6 illustrate the SHAP plots for the influencing factors of SOtF in urban and rural Hukou, respectively. Figure 5 indicates that personal characteristic (generation), family environment (current and expected socioeconomic status), and social environment (unemployment rate) are the primary factors affecting SOtF in urban hukou population. H2a and H4a are confirmed again, while H3a is preliminarily confirmed, showing that personal characteristics and social environment are the main stable factors influencing the sense of fairness among urban populations (including SOpF and SOtF), but family environment has a greater impact on SOtF. For the rural hukou population, the situation differs slightly. Figure 6 shows that personal characteristics (generation), family environment (current and expected socioeconomic status), social environment (GDP), and internet use are all the dominant influence factors of rural hukou population’s SOtF. H2b, H3b, H4b, and H5b are confirmed again, which also indicates that for rural residents, the main influencing factors of both SOpF and SOtF are more diverse. Notably, there is a lack of evidence to support H5a, indicating that internet use has minimal impact on the fairness perception of urban hukou population.

Fig. 5
figure 5

SHAP diagram of factors influencing SOtF of urban hukou.

Fig. 6
figure 6

SHAP diagram of factors influencing SOtF of rural hukou.

In the urban sample, the top five factors influencing outcome fairness perception include two economic-related factors: current socioeconomic status (average contribution is 0.087, ranked first) and expected socioeconomic status (average contribution is 0.055, ranked third). Both factors have a positive effect when they are at a moderate level, highlighting the importance of middle-level socioeconomic status in enhancing urban residents’ SOtF. The middle socioeconomic status group is also known as the “social stabilizer” (Tian, 2021). They are typically in a favorable position for mobility, as they do not face as many structural barriers as the lower socioeconomic status group, nor do they have overly high expectations of existing resources and opportunities like the higher socioeconomic status group. They can derive satisfaction from downward comparisons (with low-income groups) while maintaining moderate mobility expectations through upward comparisons (with high-income groups) (Whyte, 2010). Ranked second is the generation of the respondents. The middle generation (born in the 1970s) has a more noticeable suppressive effect on SOtF. The 1980s and 1990s generations exhibit polarization, with most showing negative effects and a few showing positive effects, while the 1950s and 1960s generations mainly show positive effects. The 1970s generation, as the group that experienced the transition from a planned economy to a market economy during the reform era, may feel a strong mismatch between expectations and reality. Additionally, we found a negative relationship between unemployment rate (average contribution is 0.05) and urban residents’ SOtF. Higher unemployment rates correspond to higher SOtF. Although this seems counterintuitive, in an environment of high unemployment, urban residents may lower their expectations for “economic outcomes” and thus pay less attention to fairness in distribution. In other words, their focus shifts to basic economic survival rather than “who gets more.” Meanwhile, governments may introduce more subsidies, reemployment support, or welfare policies targeting unemployed groups, improving perceptions of distribution fairness through resource redistribution (Senghaas et al., 2023). The fifth factor is residential area type (average contribution is 0.045). Similar to its effect on SOpF, better living conditions in a community lead to stronger SOtF.

The top three factors influencing rural residents’ SOtF all involve economic aspects, indicating that economic factors play a crucial role in shaping SOtF. Specifically, current socioeconomic status (average contribution of ~0.095) and expected socioeconomic status (average contribution of about 0.07) have a positive impact on rural residents’ SOtF, with rural populations at a moderately high socioeconomic level being more likely to perceive. The effect of GDP (average contribution of about 0.065) is more complex; lower GDP levels can result in either higher or lower SOtF. This phenomenon may reflect that rural populations in low-GDP regions focus more on relative fairness within their immediate surroundings rather than overall macroeconomic development. In other words, rural residents might prioritize their relative social status over the absolute level of regional economic development. From a generational perspective, generational factors show significant intergenerational differences in their impact on SOtF. Older generations, such as those born in the 1950s and 1960s, exhibit a positive generational effect, while younger generations, such as those born in the 1980s and 1990s, show a negative impact. This could be because older generations in rural areas experienced times of relative scarcity in economic resources, leading to lower expectations for outcomes, while younger generations grew up during periods of rapid economic development and widespread access to information, resulting in higher expectations for resource distribution. Regarding internet use, it tends to reduce rural residents’ SOtF. Some scholars suggest that the increasing prevalence of the internet expands people’s reference groups (Knight, 2013). Internet use may heighten rural residents’ awareness of the gap between themselves and urban residents, thereby reinforcing perceptions of inequality.

Summary and discussion

This research uses data from five waves of the CSS surveys from 2013 to 2021 and adopts machine learning models to systematically analyze the factors influencing SOpF and SOtF among urban and rural hukou population. It reveals the differences in perceptions of fairness and the complex mechanisms influencing these perceptions in urban and rural China. Overall, this study confirms the presence of a “positive tunnel effect” in China’s urban and rural society. The key findings are as follows:

First of all, rural residents have significantly higher level of both SOpF and SOtF compared to urban residents, showing a stronger positive tunnel effect. This suggests that rural residents maintain “optimistic expectations,” making them more likely to perceive fairness. In terms of spatial distribution, there are clear regional differences: fairness perceptions are weaker in the central region (regardless of urban or rural hukou), while both SOpF and SOtF are higher in the western region.

Secondly, for urban residents, personal characteristics and social environment are the primary factors influencing their SOpF. In contrast, rural residents’ SOpF is shaped by a wider variety of factors, including personal characteristics, family environment, social environment, and internet use. In detail, age, education, and GDP are important factors influencing SOpF for both urban and rural populations. Urban residents are also influenced by generation and residential area type, while rural residents are impacted by internet use and current socioeconomic status. Older age or belonging to older generations with higher SOpF for both urban and rural populations. While education shows a “sandwich effect,” where individuals with intermediate education levels report lower SOpF, while those with lower or higher education levels report stronger SOpF. This finding suggests that there is an “education threshold” in the tunnel effect. Positive tunnel effects can only be activated when the success path of the reference group is replicable. The intermediate-educated group may struggle to form a positive tunnel effect due to a lack of clear, institutionalized upward mobility channels and reasonable psychological expectations. It is noteworthy that the middle socioeconomic status group has the strongest promotion of fairness, as they are in the best position for social mobility. They possess a certain socioeconomic foundation while also maintaining positive expectations for upward mobility. This group is also referred to as the “social stabilizer.” The impact of GDP differs significantly: higher GDP positively affects urban residents’ SOpF, while for rural residents, mid-to-low GDP levels have mixed effects, being either positive or negative. For urban residents, generation and residential area type play a more prominent role. The older generations and better living conditions are associated with higher SOpF. In contrast, rural residents are more influenced by internet use and socioeconomic status. Internet use decreases rural residents’ SOpF, while moderate socioeconomic status increases it.

Finally, for urban residents, personal characteristics, social environment, and family environment are the key factors influencing their SOtF. In contrast, rural residents’ SOtF, similar to their SOpF, is shaped by a more diverse range of factors. Specifically, economic factors (including current socioeconomic status, expected socioeconomic status, and regional GDP) and generation are common influences on SOtF for both urban and rural populations. In addition, unemployment rates have a more significant impact on urban residents’ SOtF, while internet use has a stronger effect on rural residents. Moderate-to-high socioeconomic status has the greatest positive impact on SOtF for both groups. Higher GDP promotes urban residents’ SOtF, but it has a dual effect on rural residents, further illustrating that perceptions of fairness of rural residents focus more on relative fairness in their immediate surroundings rather than macroeconomic development. Generational effects show slight differences between urban and rural populations. For urban residents, generational effects follow a U-shape: middle generations experience negative impacts, while younger and older generations show positive impacts. For rural residents, generational effects are mainly seen in younger (negative) and older (positive) generations. Additionally, unemployment rates have a significant negative impact on urban residents’ SOtF, while internet use negatively affects SOtF among rural residents. This finding provides a new perspective on diffusion of technology theory, suggesting that technology does not always promote fairness and may instead amplify perceptions of inequality through increased information exposure or social comparison.

Based on these findings, we propose four targeted recommendations: (1) Enhancing Perceived Fairness in Central Regions. Due to its unique geographical position, the central region is more susceptible to the “negative tunnel effect.” The government can address this challenge through various policy measures. For instance, increasing economic support for the central region, boosting regional economic development, expanding employment opportunities, and fostering positive psychological expectations among local residents. (2) Mitigating the “Sandwich Effect” of Educational Attainment. The government should strengthen employment support and psychological counseling for individuals with intermediate educational levels. On one hand, implementing more inclusive employment policies, offering career planning assistance, and providing skills training can enhance their competitiveness in the job market. On the other hand, expanding social security services and psychological counseling can ensure their access to fair social protection, providing a safety net to alleviate individual psychological stress. (3) Expanding the Middle Socioeconomic Class. The middle class plays a significant role in fostering a sense of fairness in society. Therefore, policies should aim to expand the proportion of the middle class in both urban and rural areas. Specific measures include improving income distribution mechanisms and increasing the wages of grassroots workers to optimize income structures and reduce extreme wealth disparities. (4) Improving Urban Living Conditions: The type of residential area influences urban residents’ perception of fairness. The government should focus on improving living environments by renovating urban villages and promoting the development of new communities. (5) Enhancing Digital Literacy for Rural Populations: Targeted digital literacy programs should be implemented to equip rural populations with the skills needed to effectively use the internet for education, employment, and community engagement. Additionally, the government should regulate recommendation algorithms to prioritize content that promotes skill development, rural entrepreneurship, and social inclusion while minimizing content that exacerbates inequality or reinforces perceptions of unfairness.

Limitations

This research has several limitations. First, there are numerous factors influencing SOpF and SOtF, but due to data constraints, we focused on 20 variables across four domains. Future research could consider incorporating a broader range of influencing factors. For example, at the personal characteristics level, factors such as physical health could be included. At the family environment level, elements like harmony among family members and the level of social support between key family members could be explored. At the social environment level, broader macro-level factors, such as the completeness of the local social welfare system, could be examined. For the internet use dimension, further distinctions could be made based on purposes such as entertainment, information acquisition, or work. Second, perceptions of fairness are dynamic for each individual. The existing CSS data is available only up to 2021. Future studies could benefit from more recent data and employ longitudinal panel data to better capture the evolving relationship between predictive factors and perceptions of fairness. Third, to protect respondents’ privacy, the CSS questionnaire omits city and county-level geographic information, retaining only provincial-level data. This limitation may introduce errors in analyzing the social environment. Future research could collect more detailed data under ethical guidelines to enable a more accurate analysis of regional differences in social environments. Lastly, this study has methodological limitations. We employed the GBR model and SHAP model to analyze the data, but some hyperparameter settings may affect the results. Future studies could explore alternative methodologies, compare different models, and conduct sensitivity analyses to validate findings more robustly.