A census clustering method oriented to fairness and balance constraint optimization
By combining the Cuckoo Search algorithm and weighted Euclidean distance to optimize the initial cluster centers, and introducing a K-means clustering algorithm with fairness and balance constraints, the problem of uneven distribution of sensitive attributes in population census using the K-means clustering algorithm is solved, achieving efficient and fair clustering results and improving the accuracy and stability of data analysis.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANJING UNIV OF INFORMATION SCI & TECH
- Filing Date
- 2025-03-05
- Publication Date
- 2026-06-09
AI Technical Summary
Existing K-means clustering algorithms fail to effectively consider the distribution balance of sensitive attributes and sample imbalance in population censuses, leading to biased clustering results and unfair decision-making. In particular, the fairness, accuracy and stability of clustering results are insufficient in complex datasets and sensitive data analysis.
By combining the Cuckoo Search algorithm, weighted Euclidean distance, and K-means clustering algorithm with fairness and balance constraints, the accuracy and stability of clustering are improved by optimizing the initial cluster centers, selecting the optimal K value, and introducing fairness and balance constraints.
It significantly improves the fairness and stability of population census data clustering, ensures the balanced distribution of sensitive attributes and the balance of sample clusters, and enhances the impartiality of data analysis and its decision support capabilities.
Smart Images

Figure CN120180164B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of data mining and machine learning, and in particular to a population census clustering method optimized for fairness and balance constraints. Background Technology
[0002] K-means clustering is a common clustering algorithm in data analysis due to its high computational efficiency and simplicity. However, traditional K-means clustering algorithms are highly sensitive to the selection of initial cluster centers and the K-value. In real-world applications, K-means clustering often fails to adequately consider the impact of sensitive attributes (such as gender and age) on the clustering results. Especially in fields like population censuses and sociological research, the balanced distribution of sensitive attributes is crucial. If the clustering algorithm does not consider the balance of these sensitive attributes, some groups may be over-clustered or ignored, leading to data bias and affecting the fairness of the analysis results. For example, in population censuses, failure to ensure a balanced distribution among different genders, age groups, or groups can affect the fairness and accuracy of decision-making. Furthermore, sample imbalance is also a major challenge faced by traditional K-means clustering algorithms. The K-means clustering algorithm lacks a built-in mechanism to address the sample imbalance problem between clusters, which often leads to some clusters having too many samples while others have too few. This not only affects the clustering results but may also impact subsequent data analysis and decision support.
[0003] To address these issues, many researchers have improved the traditional K-means clustering algorithm in recent years. For example, some researchers have proposed an algorithm combining particle swarm optimization (PSO) and K-means clustering, using PSO to solve the cluster center initialization problem in K-means clustering. Other researchers have used Fair Clustering with Sensitive Attributes (FCSN) to handle the sensitive attributes of samples, introducing fairness constraints during optimization to ensure that the clustering results are not biased by sensitive attributes. Furthermore, to address the issues of sensitive attributes and imbalanced samples in the data, some studies have proposed Balanced Fair K-Means (BFKM) clustering to ensure that each cluster in the clustering results has a relatively balanced number of samples and to eliminate data bias.
[0004] While these improvements have enhanced the clustering results of census data to some extent, they still have many shortcomings, especially in the analysis of complex datasets and sensitive data. How to better optimize the initial cluster centers, rationally select the number of clusters K, and effectively handle fairness and balance constraints remains a hot topic and a challenge in current research. Particularly in data analysis involving sensitive group characteristics, such as censuses, the fairness, accuracy, and stability of clustering results are crucial for decision support. Therefore, innovative algorithms are urgently needed to overcome the limitations of existing methods, improve the fairness assurance and reliability of results in the census data clustering process, and thus provide a more accurate and impartial basis for policy making and socio-economic analysis. Summary of the Invention
[0005] Purpose of the invention: The technical problem to be solved by the present invention is to address the shortcomings of the existing technology by providing a population census clustering method optimized for fairness and balance constraints. Specifically, it is a clustering optimization method that combines the Cuckoo Search algorithm, weighted Euclidean distance, and K-means clustering algorithm with fairness and balance constraints, aiming to improve the clustering accuracy, fairness, and stability of population census data analysis.
[0006] The method of the present invention includes the following steps:
[0007] Step 1: Obtain the census sampling dataset X;
[0008] Step 2: Optimize using the Cuckoo Search algorithm to select initial population cluster centers;
[0009] Step 3: Within the K value selection range, perform the silhouette coefficient comparison method to select the optimal K value for population survey clustering;
[0010] Step 4: Perform weighted Euclidean distance optimization iteration;
[0011] Step 5: Introduce fairness and balance constraints;
[0012] Step 6: Iterate until the convergence condition is met.
[0013] Step 2 includes:
[0014] Step 2-1: Initialize num_nest nests. Within each nest, randomly generate K candidate initial population cluster centers. The formula for num_nest is:
[0015]
[0016] Where n is the number of samples in the census sampling dataset;
[0017] Calculate the sum of squared errors (SSE) for each nest as the fitness:
[0018]
[0019] Where, x j μ represents the population survey sample point in the i-th cluster. i Let C be the population cluster center of the i-th cluster. i For the i-th cluster;
[0020] Step 2-2: First, randomly select a nest 'a', then randomly select two different nests 'C'. i and C j Two different nests C i and C j Linear combination forms a new nest C new1 Comparing the new nest C new1 The fitness of nest a, if the new nest C new1 If the fitness of nest C is less than that of nest a, then new nest C is used. new1 Replace 'a', otherwise do not replace it.
[0021] The formula for the linear combination is:
[0022] C new1 =αC i +(1-α)C j (3)
[0023] Where α is the random step size factor, which takes a value from 0 to 1;
[0024] Steps 2-3 involve performing a Levy flight on each nest. Each nest undergoes a Levy random search with a probability of 0.25 to increase diversity. In this invention, a probability value of 0.25 is chosen for the Levy random search to increase diversity during the search process. This probability value has been experimentally verified, balancing exploration and utilization efficiency while ensuring global search capability and avoiding excessive computational overhead caused by frequent Levy flights. By controlling the probability of Levy flights, this method effectively improves the algorithm's convergence speed and computational efficiency, making it particularly suitable for high-dimensional optimization problems. Of course, the probability value of 0.25 in this technical solution is not the only choice; other probability values can also be used to achieve similar effects. The specific choice should be optimized based on the actual application scenario and experimental results.
[0025] C new2 =C old +L(β) (4)
[0026] Where β is the Levy distribution parameter, C old It is the initial nest for Levy's flight, C new2 It is C oldThe newly synthesized nest after Levy flight, where L(β) is the step size of Levy flight;
[0027] The formula for calculating the step size of the Levy distribution is:
[0028]
[0029] Where u and v are random variables generated from a normal distribution, u ~ N(0,δ) 2 ), v ~ N(0,1), δ is a parameter of the Levy distribution, usually used to adjust the distribution characteristics of the step size; Γ is the gamma function, used to represent the factorial in mathematics;
[0030] To prevent newly generated solutions from exceeding the data range, the following boundary handling strategy is used:
[0031] C new2 =max(min(C) new2 ,max(X)),min(X)) (7);
[0032] Where max(X) is the upper bound of the census sampling dataset X, and min(X) is the lower bound of the census sampling dataset X.
[0033] Steps 2-4 are repeated from 2-1 to 2-3 for iteration until the maximum number of iterations is reached, at which point the optimal initial cluster centers are output. After multiple experimental comparisons, the maximum number of iterations in this invention is set to 150.
[0034] Step 3 includes:
[0035] Step 3-1, calculate the intra-class distance a(i) of the i-th census sample:
[0036]
[0037] Among them, l i Let i be the cluster number to which the i-th census sample belongs. Let i be the cluster to which the i-th census sample belongs. X is the number of samples in the cluster to which the i-th census sample belongs. i and X j Let X represent the i-th census sample and the j-th census sample, respectively; i and X j They belong to the same cluster;
[0038] Step 3-2, calculate the inter-class distance b(i) of the nearest cluster in the census data analysis:
[0039]
[0040] Among them, Cc This indicates the cluster whose number is equal to c;
[0041] Step 3-3: Calculate the silhouette coefficient for each census sample;
[0042] Steps 3-4: For the current K value, calculate the average profile coefficient S. k ;
[0043] Steps 3-5: Select the K value with the largest average profile coefficient as the cluster number, and proceed to step 4.
[0044] Step 3-3 includes: The formula for calculating the profile coefficient s(i) of the i-th census sample is as follows:
[0045]
[0046] Steps 3-4 include: calculating the average profile coefficient S using the following formula. k :
[0047]
[0048] Step 4 includes:
[0049] Step 4-1, calculate the standard deviation σ of the m-th feature. m :
[0050]
[0051] Among them, X im μ is the m-th feature value of the i-th census sample in the census sampling dataset X, where n is the total number of census samples. m This represents the mean of all samples for the m-th feature;
[0052] Step 4-2, when calculating the weight w, the weight is determined by the standard deviation of each feature:
[0053] w m =1 / σ m (13)
[0054] Where w m This represents the weight of the m-th feature;
[0055] Step 4-3: Calculate the weighted Euclidean distance.
[0056] In step 4-3, the weighted Euclidean distance is calculated using the following formula:
[0057]
[0058] Among them, D ij C is the weighted Euclidean distance between the i-th census sample and the j-th census sample.jm It is the m-th feature of the j-th cluster center, and M is the total number of features in the census sample.
[0059] Step 5 includes:
[0060] By using an indicator matrix, the fairness of population-sensitive attributes can be represented as:
[0061]
[0062] Where F represents the indicator matrix of sensitive attributes of population sampling data, and Y represents the indicator matrix of cluster labels, the indicator matrix is used to indicate the existence of certain features, attributes, or categories in this invention. The elements in the matrix are only 0 or 1, where 1 indicates that a specific condition is met or a feature exists, and 0 indicates that the condition is not met or the feature does not exist. In the prior art, the indicator matrix can be generated through automated data processing techniques;
[0063] When considering the balance constraints in population data analysis, in order to ensure that the size of each cluster is roughly the same, this method uses the arithmetic mean inequality, when E h=n / k E1+E2+E3+...+E k When = n, we get:
[0064]
[0065] Among them, E h This represents the size of the h-th cluster, and k represents the total number of clusters;
[0066] Using an indicator matrix, equation (16) can be expressed as:
[0067] tr((Y T Y) -1 (17)
[0068] Where tr represents the trace of the matrix;
[0069] The objective cost function is derived using the Lagrange multiplier method.
[0070]
[0071] Among them, cost c D represents the target cost when distributed in the c-th cluster. ic Let h represent the weighted Euclidean distance from the i-th population sample to the centroid of the c-th cluster. c and h take values from 1 to k.
[0072] Finally, appropriate penalty terms p1 and p2 are manually selected based on the actual situation, and the cost function is iterated continuously until the change value during the iteration is less than the preset threshold (0.001 in this method) or the number of iterations exceeds the set maximum number (250 in this method). The threshold and maximum number of iterations will be set differently for different datasets and need to be determined according to the actual situation.
[0073] The present invention also provides an electronic device, including a processor and a memory, the memory storing program code that, when executed by the processor, causes the processor to perform the steps of the method.
[0074] The present invention also provides a storage medium storing a computer program or instructions that, when the computer program or instructions are run on a computer, execute the steps of the method described.
[0075] Beneficial effects: The method of this invention overcomes the problem of initial cluster center selection by combining the Cuckoo Search algorithm, significantly improving the clustering effect. At the same time, this method combines weighted Euclidean distance, fairness, and balance constraints with the traditional K-means clustering algorithm, effectively improving the distribution balance of sensitive population data and the uniformity of sample cluster distribution. Attached Figure Description
[0076] Figure 1 This is the overall flowchart of the method of the present invention.
[0077] Figure 2 This is a diagram showing the clustering results of the Lloyd algorithm on the 2d-4c-no0 synthetic dataset.
[0078] Figure 3 This is a diagram showing the fair clustering effect considering sensitive attributes on the 2d-4c-no0 synthetic dataset.
[0079] Figure 4 This is a graph showing the effect of balanced fair K-means clustering on the 2d-4c-no0 synthetic dataset.
[0080] Figure 5 This is a clustering effect diagram of the present invention on the 2d-4c-no0 synthetic dataset. Detailed Implementation
[0081] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments, and the advantages of the present invention in the above and / or other aspects will become clearer.
[0082] This invention provides a population census clustering method optimized for fairness and balance constraints, comprising the following steps:
[0083] Step 1: Obtain the census sampling dataset X;
[0084] Step 2: Optimize using the Cuckoo Search algorithm to select initial population cluster centers;
[0085] Step 3: Within the K value selection range, perform the silhouette coefficient comparison method to select the optimal K value for population survey clustering;
[0086] Step 4: Perform weighted Euclidean distance optimization iteration;
[0087] Step 5: Introduce fairness and balance constraints;
[0088] Step 6: Iterate until the convergence condition is met.
[0089] Step 2 includes:
[0090] Step 2-1: Initialize num_nest nests. Within each nest, randomly generate K candidate initial population cluster centers. The formula for num_nest is:
[0091]
[0092] Where n is the number of samples in the census sampling dataset;
[0093] Calculate the sum of squared errors (SSE) for each nest as the fitness:
[0094]
[0095] Where, x j μ represents the population survey sample point in the i-th cluster. i Let C be the population cluster center of the i-th cluster. i For the i-th cluster;
[0096] Step 2-2: First, randomly select a nest 'a', then randomly select two different nests 'C'. i and C j Two different nests C i and C j Linear combination forms a new nest C new1 Comparing the new nest C new1 The fitness of nest a, if the new nest C new1 If the fitness of nest C is less than that of nest a, then new nest C is used. new1 Replace 'a', otherwise do not replace it.
[0097] The formula for the linear combination is:
[0098] C new1 =αC i +(1-α)Cj (3)
[0099] Where α is the random step size factor, which takes a value from 0 to 1;
[0100] Steps 2-3 involve performing a Levy flight on each nest. Each nest undergoes a Levy random search with a probability of 0.25 to increase diversity. In this invention, a probability value of 0.25 is chosen for the Levy random search to increase diversity during the search process. This probability value has been experimentally verified, balancing exploration and utilization efficiency while ensuring global search capability and avoiding excessive computational overhead caused by frequent Levy flights. By controlling the probability of Levy flights, this method effectively improves the algorithm's convergence speed and computational efficiency, making it particularly suitable for high-dimensional optimization problems. Of course, the probability value of 0.25 in this technical solution is not the only choice; other probability values can also be used to achieve similar effects. The specific choice should be optimized based on the actual application scenario and experimental results.
[0101] C new2 =C old +L(β) (4)
[0102] Where β is the Levy distribution parameter, C old It is the initial nest for Levy's flight, C new2 It is C old The newly synthesized nest after Levy flight, where L(β) is the step size of Levy flight;
[0103] The formula for calculating the step size of the Levy distribution is:
[0104]
[0105] Where u and v are random variables generated from a normal distribution, u ~ N(0,δ) 2 ), v ~ N(0,1), δ is a parameter of the Levy distribution, usually used to adjust the distribution characteristics of the step size; Γ is the gamma function, used to represent the factorial in mathematics;
[0106] To prevent newly generated solutions from exceeding the data range, the following boundary handling strategy is used:
[0107] C new2 =max(min(C) new2 ,max(X)),min(X)) (7);
[0108] Where max(X) is the upper bound of the census sampling dataset X, and min(X) is the lower bound of the census sampling dataset X.
[0109] Steps 2-4 are repeated from 2-1 to 2-3 for iteration until the maximum number of iterations is reached, at which point the optimal initial cluster centers are output. After multiple experimental comparisons, the maximum number of iterations in this invention is set to 150.
[0110] Step 3 includes:
[0111] Step 3-1, calculate the intra-class distance a(i) of the i-th census sample:
[0112]
[0113] Among them, l i Let i be the cluster number to which the i-th census sample belongs. Let i be the cluster to which the i-th census sample belongs. X is the number of samples in the cluster to which the i-th census sample belongs. i and X j Let X represent the i-th census sample and the j-th census sample, respectively; i and X j They belong to the same cluster;
[0114] Step 3-2, calculate the inter-class distance b(i) of the nearest cluster in the census data analysis:
[0115]
[0116] Among them, C c This indicates the cluster whose number is equal to c;
[0117] Step 3-3: Calculate the silhouette coefficient for each census sample;
[0118] Steps 3-4: For the current K value, calculate the average profile coefficient S. k ;
[0119] Steps 3-5: Select the K value with the largest average profile coefficient as the cluster number, and proceed to step 4.
[0120] Step 3-3 includes: The formula for calculating the profile coefficient s(i) of the i-th census sample is as follows:
[0121]
[0122] Steps 3-4 include: calculating the average profile coefficient S using the following formula. k :
[0123]
[0124] Step 4 includes:
[0125] Step 4-1, calculate the standard deviation σ of the m-th feature.m :
[0126]
[0127] Among them, X im μ is the m-th feature value of the i-th census sample in the census sampling dataset X, where n is the total number of census samples. m This represents the mean of all samples for the m-th feature;
[0128] Step 4-2, when calculating the weight w, the weight is determined by the standard deviation of each feature:
[0129] w m =1 / σ m (13)
[0130] Where w m This represents the weight of the m-th feature;
[0131] Step 4-3: Calculate the weighted Euclidean distance.
[0132] In step 4-3, the weighted Euclidean distance is calculated using the following formula:
[0133]
[0134] Among them, D ij C is the weighted Euclidean distance between the i-th census sample and the j-th census sample. jm It is the m-th feature of the j-th cluster center, and M is the total number of features in the census sample.
[0135] Step 5 includes:
[0136] By using an indicator matrix, the fairness of population-sensitive attributes can be represented as:
[0137]
[0138] Where F represents the indicator matrix of sensitive attributes of population sampling data, and Y represents the indicator matrix of cluster labels, the indicator matrix is used to indicate the existence of certain features, attributes, or categories in this invention. The elements in the matrix are only 0 or 1, where 1 indicates that a specific condition is met or a feature exists, and 0 indicates that the condition is not met or the feature does not exist. In the prior art, the indicator matrix can be generated through automated data processing techniques;
[0139] When considering the balance constraints in population data analysis, in order to ensure that the size of each cluster is roughly the same, this method uses the arithmetic mean inequality, when E h=b / k E1+E2+E3+...+E k When = n, we get:
[0140]
[0141] Among them, E h This represents the size of the h-th cluster, and k represents the total number of clusters;
[0142] Using an indicator matrix, equation (16) can be expressed as:
[0143] tr((Y T Y) -1 (17)
[0144] Where tr represents the trace of the matrix;
[0145] The objective cost function is derived using the Lagrange multiplier method.
[0146]
[0147] Among them, cost c D represents the target cost when distributed in the c-th cluster. ic Let h represent the weighted Euclidean distance from the i-th population sample to the centroid of the c-th cluster. c and h take values from 1 to k.
[0148] Finally, appropriate penalty terms p1 and p2 are manually selected based on the actual situation, and the cost function is iterated continuously until the change value during the iteration is less than the preset threshold (0.001 in this method) or the number of iterations exceeds the set maximum number (250 in this method). The threshold and maximum number of iterations will be set differently for different datasets and need to be determined according to the actual situation.
[0149] The present invention also provides an electronic device, including a processor and a memory, the memory storing program code that, when executed by the processor, causes the processor to perform the steps of the method.
[0150] The present invention also provides a storage medium storing a computer program or instructions that, when the computer program or instructions are run on a computer, execute the steps of the method described.
[0151] like Figure 1 As shown, in this embodiment, the experimental results were verified by using the synthetic datasets Elliptical, DS-577, 2d-4c-no0, and the sampling data Census1990 from the 1990 U.S. Census, which are commonly used in clustering research.
[0152] Table 1
[0153]
[0154] Table 1 shows the parameter sizes of the penalty terms p1 and p2 used in the experiment, as well as the size of each dataset. When dealing with different datasets, the penalty terms for fairness and balance constraints need to be adjusted according to the dataset size and actual conditions to ensure that the algorithm can achieve optimized clustering results on different datasets.
[0155] like Figure 2 , Figure 3 , Figure 4 and Figure 5 As shown, the clustering results of different algorithms on the 2d-4c-no0 synthetic dataset are presented. Different colors represent different clusters, and different shapes represent sensitive attributes. By comparing with the other three algorithms, it is clear that the algorithm of this invention successfully achieves good clustering fairness while ensuring clustering effectiveness.
[0156] This experiment compares the algorithm of this invention with three other clustering algorithms: Lloyd's algorithm, fair clustering considering sensitive attributes, and balanced fair K-means clustering. Lloyd's algorithm is a traditional K-means clustering algorithm. Fair clustering considering sensitive attributes is a fairness optimization method based on spectral clustering. Balanced fair K-means clustering introduces fairness and cluster size balance constraints on the standard K-means clustering algorithm. This experiment uses three evaluation metrics to measure clustering performance: sum of squared errors, weighted fairness gap, and fairness ratio. The sum of squared errors measures the sum of squared Euclidean distances between cluster centers and sample points; a lower value indicates a denser distribution of samples within clusters and better clustering results. The weighted fairness gap reflects the evenness of the distribution of sensitive attributes across clusters; a lower value means a more uniform distribution of sensitive attributes among clusters. The fairness ratio measures whether the distribution of sensitive attributes in the dataset meets the fairness objective; a fairness ratio close to 1 indicates optimal fairness, while 0 indicates that fairness constraints have not been considered. In summary, the sum of squared errors focuses on the density of clusters, the weighted fairness gap assesses fairness bias, and the fairness ratio measures the overall fairness level. Together, these three constitute a comprehensive evaluation system for clustering algorithms in this experiment.
[0157] Table 2
[0158] Sum of squared errors ↓ Weighted fairness gap ↓ Fairness ratio ↑ Lloyd's Algorithm 206.2982 0.494 0 Fair clustering considering sensitive attributes 343.964 0.048 0.8845 Balanced fair K-means clustering 351.109 0.0472 0.9005 Algorithm of this invention 329.0549 0 1
[0159] Table 3
[0160] Sum of squared errors ↓ Weighted fairness gap ↓ Fairness ratio ↑ Lloyd's Algorithm 71.0134 0.4183 0 Fair clustering considering sensitive attributes 361.4299 0.1496 0 Balanced fair K-means clustering 516.0655 0.0319 0.8042 Algorithm of this invention 514.4775 0.0290 0.8405
[0161] Table 4
[0162]
[0163]
[0164] Table 5
[0165] Sum of squared errors ↓ Weighted fairness gap ↓ Fairness ratio ↑ Lloyd's Algorithm 1760.4 0.0671 0.5129 Fair clustering considering sensitive attributes 1821.9 0.047 0.7418 Balanced fair K-means clustering 1852 0.0141 0.9169 Algorithm of this invention 1722 0.0135 0.9516
[0166] As shown in Tables 2, 3, 4, and 5, the experimental results demonstrate that the algorithm of this invention achieves the best balance between fairness and clustering quality, exhibiting significant advantages. First, the algorithm of this invention performs best in terms of fairness. In all datasets, the fairness ratio of the algorithm of this invention reaches or approaches 1.0, far exceeding fair clustering considering sensitive attributes and balanced fair K-means clustering. For example, on the Elliptical dataset, the algorithm of this invention achieves a fairness ratio of 1.0, i.e., completely fair cluster partitioning, while on the Census1990 dataset, it achieves a fairness ratio of 0.9516, demonstrating extremely high fairness optimization capability. In contrast, Lloyd's algorithm does not consider fairness, and its fairness ratio is always 0. While fair clustering considering sensitive attributes and balanced fair K-means clustering show improvement on some datasets, they still cannot match the optimization effect of the algorithm of this invention. Second, the algorithm of this invention performs best in terms of weighted fairness gap. The weighted fairness gap reflects the degree of distribution balance of sensitive attributes in different clusters in the dataset; the lower the value, the higher the fairness. The weighted fairness gap values of the algorithm in this invention are significantly lower than those of other methods across all datasets. This result demonstrates that the algorithm effectively reduces the imbalanced distribution of sensitive attributes across different datasets, achieving optimal fairness control. Finally, the algorithm balances cluster compactness with a reasonable sum of squared errors. While Lloyd's algorithm performs best in terms of sum of squared errors, it completely disregards fairness, leading to severe data bias. In contrast, the algorithm in this invention optimizes fairness while maintaining a low sum of squared errors, avoiding the excessive impact of fairness optimization on clustering quality. For example, on the Elliptical dataset, the sum of squared errors of the algorithm of this invention is 329.0549, which is lower than that of balanced fair K-means clustering (351.109) and fair clustering considering sensitive attributes (343.964), indicating that its clustering quality is still superior. On the Census1990 dataset, the sum of squared errors of the algorithm of this invention is 1722.0, which is also better than that of balanced fair K-means clustering (1852.0) and fair clustering considering sensitive attributes (1821.9), further demonstrating its stability on large-scale data.
[0167] In summary, the algorithm of this invention demonstrates optimal fairness performance across all datasets, while maintaining high clustering quality while ensuring fairness. This makes the algorithm highly applicable to the analysis of census data where fairness is a critical requirement.
[0168] This invention provides a population census clustering method optimized for fairness and balance constraints. Many methods and approaches exist for implementing this technical solution; the above description is merely a preferred embodiment. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this invention, and these improvements and modifications should also be considered within the scope of protection of this invention. All components not explicitly stated in this embodiment can be implemented using existing technologies.
Claims
1. A population census clustering method oriented towards fairness and balance constraints optimization, characterized in that, Includes the following steps: Step 1: Obtain the census sampling dataset X; Step 2: Optimize using the Cuckoo Search algorithm to select initial population cluster centers; Step 3: Within the K value selection range, perform the silhouette coefficient comparison method to select the optimal K value for population survey clustering; Step 4: Perform weighted Euclidean distance optimization iteration; Step 5: Introduce fairness and balance constraints; Step 6: Iterate until the convergence condition is met; Step 2 includes: Step 2-1: Initialize num_nest nests. Within each nest, randomly generate K candidate initial population cluster centers. The formula for num_nest is: (1), Where n is the number of samples in the census sampling dataset; Calculate the sum of squared errors (SSE) for each nest as the fitness: (2), in, This represents the population survey sample point in the i-th cluster. Let i be the population cluster center of the i-th cluster. For the i-th cluster; Step 2-2: First, randomly select one nest 'a', then randomly select two different nests. and Two different nests and Linear combination to form a new nest Comparing new nests The fitness of nest a, if the new nest If the fitness of nest a is less than that of nest a, then a new nest should be used. Replace 'a', otherwise do not replace it. The formula for the linear combination is: (3), in, This is a random step size factor, with a value ranging from 0 to 1; Steps 2-3 involve performing Levy flights on each nest and conducting random Levy searches within each nest to increase diversity. (4), in These are the parameters of the Levy distribution. It was the initial nest for Levy's flight. yes The newly synthesized nest after Levy's flight It is the stride length of Levy's flight; The formula for calculating the step size of the Levy distribution is: (5), (6), in, and Random variables generated from a normal distribution ) (0,1), It is a parameter of the Levy distribution; It is a gamma function; Use the following boundary handling strategy: (7); in, It is the upper limit of the census sampling dataset X. It is the lower bound of the census sampling dataset X; Step 2-4: Repeat steps 2-1 to 2-3 for iteration until the maximum number of iterations is reached, and output the optimal initial cluster centers.
2. The method according to claim 1, characterized in that, Step 3 includes: Step 3-1: Calculate the intra-class distance of the i-th census sample. : (8), in, Let i be the cluster number to which the i-th census sample belongs. Let i be the cluster to which the i-th census sample belongs. It is the number of samples in the cluster to which the i-th census sample belongs. and Let i and j represent the i-th and j-th census samples, respectively. and They belong to the same cluster; Step 3-2: Calculate the inter-class distance of the nearest cluster in the census data analysis. : (9), in, This indicates the cluster whose number is equal to c; Step 3-3: Calculate the silhouette coefficient for each census sample; Steps 3-4: For the current K value, calculate the average profile coefficient. ; Steps 3-5: Select the K value with the largest average profile coefficient as the cluster number, and proceed to step 4.
3. The method according to claim 2, characterized in that, Step 3-3 includes: the profile coefficient of the i-th census sample. The calculation formula is: (10)。 4. The method according to claim 3, characterized in that, Steps 3-4 include: calculating the average profile coefficient using the following formula. : (11)。 5. The method according to claim 4, characterized in that, Step 4 includes: Step 4-1: Calculate the standard deviation of the m-th feature. : (12), in, It is the m-th feature value of the i-th census sample in the census sampling dataset X, where n is the total number of census samples. This represents the mean of all samples for the m-th feature; Step 4-2, when calculating the weight w, the weight is determined by the standard deviation of each feature: (13), in This represents the weight of the m-th feature; Step 4-3: Calculate the weighted Euclidean distance.
6. The method according to claim 5, characterized in that, In step 4-3, the weighted Euclidean distance is calculated using the following formula: (14), in, It is the weighted Euclidean distance between the i-th census sample and the j-th census sample. It is the m-th feature of the j-th cluster center, and M is the total number of features in the census sample.
7. The method according to claim 6, characterized in that, Step 5 includes: By using an indicator matrix, the fairness of population-sensitive attributes can be represented as: (15), Where F represents the indicator matrix of sensitive attributes of population sampling data, and Y represents the indicator matrix of cluster labels; Using the arithmetic mean inequality, when At that time, we obtained: (16), in, This represents the size of the h-th cluster, and k represents the total number of clusters; Using an indicator matrix, equation (16) can be expressed as: (17), Where tr represents the trace of the matrix; The objective cost function is derived using the Lagrange multiplier method. (18), in, This represents the target cost when distributed in the c-th cluster. Let represent the weighted Euclidean distance from the i-th population sample to the centroid of the c-th cluster.
8. An electronic device, characterized in that, It includes a processor and a memory, the memory storing program code that, when executed by the processor, causes the processor to perform the steps of the method as described in any one of claims 1 to 7.
9. A storage medium, characterized in that, It stores a computer program or instructions that, when run on a computer, perform the steps of the method as described in any one of claims 1 to 7.