# A K-Means Clustering Algorithm for Early Warning of Financial Risks in Agricultural Industry

Authors: Xue-Tong Li; Xiao-Hua Duan
Journal: Security and Communication Networks
 (2022)

---

## Abstract

As the primary industry, agricultural industry is the basis of guaranteeing people’s basic life and national economic development. Agricultural industrial finance/financial is a weak link in the financial system, which seriously hinders the emergence of agricultural scale effect and the improvement in agricultural production efficiency. In order to find the financial risk of agricultural industry in time, this article proposes an agricultural industry financial risk early warning system based on improved K-means clustering algorithm. Because the traditional K-means algorithm is easy to fall into local optimization in the clustering process, the clustering effect is not reliable. In this article, the idea of immune cloning and particle swarm optimization location update is added to the grey wolf optimization algorithm. Grey wolf optimization algorithm and K-means algorithm are combined to solve the problem that K-means algorithm is easy to fall into local optimization. In the experimental part, through comparative verification, it can be found that the prediction performance of this system is superior to other models. Its practical application value is higher. Therefore, choosing this system for early warning of agricultural industry finance can effectively improve the accuracy of early warning and provide guarantee for the economic development of agricultural industry.


---

## Body

## 1. Introduction

Agricultural industry finance is a relatively weak link in China’s financial system. The financial demand in rural areas mainly includes the demand for productive loans, including planting, breeding, animal husbandry, deep processing of agricultural products, etc. It has long cycle and low income and is greatly affected by natural factors. Agriculture-related loans have instability risk and high service cost. The supply of rural formal finance is insufficient, and the structural contradiction is more prominent. Its financial ecology is fragile and the risk of guarantee chain is large. At the same time, the insufficient supply of rural formal finance provides space for the development of underground finance. Some individuals are engaged in insurance and deposit business under the guise of Internet finance and farmer cooperatives, so that illegal fundraising problems often occur. Therefore, the study of rural financial risk has very important practical significance.There are four main causes of rural financial risk in China [1]. First, the uncertainty of agricultural economy. At present, there are some problems in China’s agricultural economy, such as scattered scale, ineffective formation of production chain, low level of agricultural science and technology, and unpredictable natural disasters. Therefore, farmers’ production and income are reduced, their ability to repay loans is weakened, and the risk of small agricultural loans is formed. Second, the resource allocation of agricultural financial institutions is unreasonable. The cost and income of financial service supply are upside down. Some state-owned commercial banks are shrinking in rural areas, and the service object and scope of policy banks are relatively single. The governance mechanism of rural credit cooperatives has not been fundamentally solved. The level of internal control management is relatively low, the electronization of rural banks and the construction of core business system are backward, and the quality of employees needs to be improved. Third, the rural credit environment is imperfect and lacks an effective punishment mechanism for dishonesty. Intermediary services are not standardized, providing false credit certificates. Meanwhile, fraudulent loans and malicious evasion of debts occur from time to time. Fourth, the construction of risk early warning system and prevention mechanism of rural financial institutions is not in place, so it is difficult to find and warn rural financial risks in time.In order to predict the agricultural industry finance, domestic and overseas scholars at home and abroad have made positive contributions [2]. As for the risk of accounts receivable financing, some scholars have proposed that most of the customers of global accounts receivable financing are small and medium-sized enterprises, and there are hidden risks in the international accounts receivable factoring business [3]. The longer the maturity time of accounts receivable, the higher the risk. The provider of accounts receivable financing funds should also pay attention to the risk of changes in the value of suppliers’ accounts receivable [4]. Meanwhile, there are some problems in accounts receivable financing, such as legal supervision, bank enterprise information asymmetry, etc [5]. The smooth implementation of accounts receivable financing of commercial banks needs to reduce the moral hazard of core enterprises and carry out dynamic risk monitoring of financing enterprises [6]. Because China is a large agricultural country, the development of agricultural industry is largely limited by the supply chain transportation industry. Therefore, the development of supply chain finance business affects agricultural finance business. As for the research on risk assessment with supply chain financial business as a whole, scholars choose the assessment indicators of supply chain financial risk from the aspects of core enterprises, financing enterprises, financing projects, and supply chain operation [7]. At the same time, the methods of supply chain financial risk assessment mainly include objective methods, support vector machine (SVM), fuzzy comprehensive evaluation method, game model, entropy weight TOPSIS model [8–11]. Due to the different methods, indicators and samples used by scholars in the research of supply chain financial risk, there are some differences in the composition and evaluation results of supply chain financial risk. However, it is generally believed that it is necessary to pay attention to the possible risks in the supply chain financial business and take corresponding preventive measures. Under different supply chain financial models, the focus of risk evaluation indicators may be different. Therefore, this article takes agricultural listed enterprises of small and medium-sized enterprises as an example and establishes a risk evaluation index system of accounts receivable financing of small and medium-sized enterprises based on fully considering the characteristics of accounts receivable financing mode. In this way, the credit risk of accounts receivable financing of small and medium-sized enterprises can be truly reflected and the decision-making basis can be provided for the practice of accounts receivable financing of small and medium-sized enterprises.In order to improve the early warning ability of agricultural financial risk, this article improves the problem that K-means clustering algorithm is easy to local optimal solution and proposes an agricultural financial risk early warning system based on improved K-means clustering. The innovations and contributions of this article are listed below:(1)
The elite individuals in the iterative process of grey wolf optimization algorithm are deeply mined to improve the in-depth exploration ability of grey wolf optimization algorithm and avoid the premature convergence of grey wolf optimization algorithm.(2)
In order to expand the scope of prey search in the field of elite individuals and give full play to the residual value of elite individuals, the idea of monomer position update of particle swarm optimization algorithm is combined with the original grey wolf position update. The improved grey wolf optimization algorithm is combined with the classical K-means algorithm to solve the problem that K-means algorithm is easy to fall into local optimization.(3)
The financial risk early warning experiment of agricultural industry is carried out to verify the effectiveness of this system.The rest of the article is organized as follows: Section 2 details the financial risk prediction model of agricultural industry based on K-means clustering algorithm, Section 3 illustrates the system design, Section 4 is about experimental simulation and analysis, and Section 5 is the final concluding section of the article.


## 2. Financial Risk Prediction Model of Agricultural Industry Based on K-Means Clustering Algorithm

### 2.1. Grey Wolf Optimization Algorithm (GWO)

GWO algorithm is a mathematical expression of social hierarchy and predation behaviour in grey wolf population. The hierarchy of GWO algorithm is divided into four, namelyα, β, δ, and ω Wolf. Let the grey wolf population with population size n be: I=i1,i2,…,iT. The best value of the candidate solution in the grey wolf population is taken as α Wolf, second best value as β Wolf, the third best value as δ Wolf, the remaining candidate solutions are set to ω Wolf. In GWO algorithm, by α, β, and δ as a leader, the wolf searches for the optimal solution within the specified range, and ω under the leadership of the three wolves, the wolves updated their positions. The mathematical model of GWO algorithm is as follows:In the process of grey wolf searching prey, the distance between each wolf and prey can be expressed by the following formula:(1)D=C⋅Iun−In,(2)In+1=Iun−G⋅D,where Iun represents the position vector of prey, In represents the position vector of grey wolf, D represents the distance vector between grey wolf and prey, and N represents the number of iterations. The calculation formulas of coefficients G and C are as follows:(3)G=2g⋅r1−g,(4)C=2⋅r2.In the process of encirclement, the value ofg linearly from 2 to 0, and r1 and r2 are random vectors in [0, 1].Grey wolves have the ability to judge the location of prey and surround prey. Preservationα, β, and δ wolves are the first three best solutions obtained in the population. And force other search agents (ω (Wolf) according to α, β, δ the wolf’s position updates its position. Other search agents and α, β, δ the wolf distance can be expressed by the following formula:(5)Dα=C1⋅Iα−I,Dβ=C2⋅Iβ−I,Dδ=C3⋅Iδ−I.After the distance of each wolf is obtained, the individual position of grey wolf is updated through the following formulas:(6)I1=Iα−G1⋅Dα,I2=Iβ−G2⋅Dβ,I3=Iδ−G3⋅Dδ,(7)In+1=I1+I2+I33.Although GWO algorithm has strong search ability, the population diversity is decreasing with the increase of iteration times. The difference between individuals is getting smaller and smaller, and the optimal value cannot be found in the search space. Premature convergence may occur, which will affect the performance of GWO algorithm. Therefore, GWO algorithm is improved based on immune cloning theory and particle swarm optimization position update idea. Immune cloning selects elite individuals from the population and performs cloning and mutation operation on them to increase the diversity of the population and avoid premature convergence of the algorithm. Then, the position change idea of a single grey wolf is introduced to increase a certain mutation ability to the change of grey wolf position, so as to improve the global search ability of the algorithm.


### 2.2. Immune Clone Selection Operation

The essence of immune clonal selection is to select elite individuals from the population according to individual fitness value, and clone and mutate the elite individuals to form a new species group. Then elite individuals are selected from the new population to enter the next iteration until the maximum iteration number of immune clone selection is reached. Applying it to the grey wolf optimization algorithm is a more in-depth exploration of the elite individuals in the original grey wolf population, so as to expand the search scope and improve the population diversity. The detailed steps of clone selection are as follows:Step 1: selectm individuals with good fitness from the grey wolf population according to the fitness function value to form an elite population (set the m value to 1/4 of the number of grey wolf individuals).Step 2: clone all grey wolf individuals in the elite population. The clone size is directly proportional to the numberm of the selected elite population to form a temporary population T with the size of NC. The calculation of NC is as follows:(8)Tc=∑x=1wroundλwx+h.The round () function is a rounding function.λ is a random number between [0, 1]. H is an integer constant and h ≥ 1. Compared with the original population t, the size of Tc is positively correlated with the value of h, which can ensure that each individual in the elite population has a certain number of clones.In step 3, high-frequency mutation is implemented for each individual in the population to obtain better candidate solutions near elite individuals. The variation operation is shown in the following formulas:(9)nxnew=nx+u⋅η⋅nx⋅r4−u⋅η⋅nx⋅r5,(10)u=1,r6⩽0.5,0,other,(11)η=1−1/exp1−1×expx/xmax−1−1,  where nx is the individual of the xth iteration of population n; nxnew is a new individual produced by nx after mutation operation; r4,r5,r6 are random numbers between [0, 1]; X stands for iteration x; xmax represents the maximum number of iterations of immune cloning operation; and η is a clonal variation parameter. It can be seen from formula (11) that the number of iterations is negatively correlated with the clone variation parameter η. η is close to 1 at the beginning, with a wide range of variation. At this point, a global range search is performed to ensure population diversity. As the number of iterations increases, the value of η gets closer and closer to 0, indicating that local searches are performed within a small range to increase fine-tuning capability and ensure the accuracy of the search.Step 4: selectw better individuals from N as the elite individual population for the next iteration until the maximum number of iterations of immune cloning operation is reached.


### 2.3. Particle Swarm Location Update Idea

In the grey wolf optimization algorithm, it can be seen from formula (5) that the position change of grey wolf is mainly to explore the prey position according to the position of three wolves. Then, three wolves (α, β, and δ) led the position update. Because we are now facing the elite population, the information contained in the prey search results of each elite individual may have an impact on the search results of the final location of the prey. Therefore, it is necessary to consider the location information of a single elite individual, so as to maximize the utilization rate of elite individuals and expand the search range of prey around elite individuals.This article is inspired by the idea of location update of particle swarm optimization algorithm. It introduces the position change idea of a single grey wolf into the grey wolf position update to avoid premature convergence of the algorithm. Adjust the update strategy of formula (7) accordingly as follows.(12)In+1=I1+I2+I33+qn,where the position change qn of a single grey wolf is expressed as the following formula:(13)qn+1=mqn+C1⋅r7I1−In+C2⋅r8I2−In+C3⋅r9I3−In,where m is the random number between [0, 1]. After many simulation experiments, when the value of m is between [0.6, 1], the algorithm has better search performance and more accurate optimization results. When m is large, it has better global search ability. When w is small, the local search ability is strong, which can effectively avoid premature convergence. r6,r7,r8 are random numbers between [0, 1]. C1, C2, C3 are obtained from formula (4). I1,I2,I3 are obtained from formula (6). In represents the current position of the grey wolf.


### 2.4. Clustering Algorithm Based on GWO and K-Means

Because the input data of agricultural financial risk is usually in the format of text document, and the text document belongs to unstructured data, this article needs to preprocess the text document before text clustering. Convert text data type to data that can be input by GWO K-means algorithm. The basic steps of text preprocessing are text word segmentation, removal of stop words, text feature selection, and text vectorization.This article uses Jieba word segmentation in Python to segment text documents and remove stop words. Commonly used text representation models mainly include Boolean space model (BM) [12], suffix tree model (STM) [13], vector space model (VSM) [14], and probabilistic retrieval model (PM) [15]. In this article, the most classical text vector model (VSM) is used for text vectorization. For document D, it is represented by nf−xdf1,nf−xdf2,…,nf−xdft. The calculation formula of nf−xdf is as follows:(14)nf−xdfn,D=lhnfn,D+0.1×lhT/tx∑x=1tlhnfn,D+0.1×lhT/tx2,where tx is the number of documents containing the word nx, T is the total number of documents, and nfn,d indicates the number of times the word nx appears in document D.In this article, GWO and K-means algorithm are used for text clustering analysis. Specifically, GWO algorithm is used to find a group of optimal clustering centres to minimize the distance from all texts in each category to the group of clustering centres, that is, the similarity of each document is the largest. In GWO algorithm, the fitness function is the goal of grey wolf to find the optimal solution. In K-means algorithm, the sum of intraclass distances is an important index to measure the advantages and disadvantages of clustering algorithm. The smaller the value, the better the clustering performance. The purpose of the combination of GWO and K-means algorithm is to use the powerful optimization ability of GWO algorithm to accurately find the optimal clustering centre. Text documents are classified by the clustering centre. This article selects the sum of the intraclass distances between text documents as the fitness evaluation function of GWO algorithm. As shown in formula:(15)Y=∑y=1Z∑∀sx∈cydsx,cy2,where z stands for clustering category.


## 2.1. Grey Wolf Optimization Algorithm (GWO)

GWO algorithm is a mathematical expression of social hierarchy and predation behaviour in grey wolf population. The hierarchy of GWO algorithm is divided into four, namelyα, β, δ, and ω Wolf. Let the grey wolf population with population size n be: I=i1,i2,…,iT. The best value of the candidate solution in the grey wolf population is taken as α Wolf, second best value as β Wolf, the third best value as δ Wolf, the remaining candidate solutions are set to ω Wolf. In GWO algorithm, by α, β, and δ as a leader, the wolf searches for the optimal solution within the specified range, and ω under the leadership of the three wolves, the wolves updated their positions. The mathematical model of GWO algorithm is as follows:In the process of grey wolf searching prey, the distance between each wolf and prey can be expressed by the following formula:(1)D=C⋅Iun−In,(2)In+1=Iun−G⋅D,where Iun represents the position vector of prey, In represents the position vector of grey wolf, D represents the distance vector between grey wolf and prey, and N represents the number of iterations. The calculation formulas of coefficients G and C are as follows:(3)G=2g⋅r1−g,(4)C=2⋅r2.In the process of encirclement, the value ofg linearly from 2 to 0, and r1 and r2 are random vectors in [0, 1].Grey wolves have the ability to judge the location of prey and surround prey. Preservationα, β, and δ wolves are the first three best solutions obtained in the population. And force other search agents (ω (Wolf) according to α, β, δ the wolf’s position updates its position. Other search agents and α, β, δ the wolf distance can be expressed by the following formula:(5)Dα=C1⋅Iα−I,Dβ=C2⋅Iβ−I,Dδ=C3⋅Iδ−I.After the distance of each wolf is obtained, the individual position of grey wolf is updated through the following formulas:(6)I1=Iα−G1⋅Dα,I2=Iβ−G2⋅Dβ,I3=Iδ−G3⋅Dδ,(7)In+1=I1+I2+I33.Although GWO algorithm has strong search ability, the population diversity is decreasing with the increase of iteration times. The difference between individuals is getting smaller and smaller, and the optimal value cannot be found in the search space. Premature convergence may occur, which will affect the performance of GWO algorithm. Therefore, GWO algorithm is improved based on immune cloning theory and particle swarm optimization position update idea. Immune cloning selects elite individuals from the population and performs cloning and mutation operation on them to increase the diversity of the population and avoid premature convergence of the algorithm. Then, the position change idea of a single grey wolf is introduced to increase a certain mutation ability to the change of grey wolf position, so as to improve the global search ability of the algorithm.


## 2.2. Immune Clone Selection Operation

The essence of immune clonal selection is to select elite individuals from the population according to individual fitness value, and clone and mutate the elite individuals to form a new species group. Then elite individuals are selected from the new population to enter the next iteration until the maximum iteration number of immune clone selection is reached. Applying it to the grey wolf optimization algorithm is a more in-depth exploration of the elite individuals in the original grey wolf population, so as to expand the search scope and improve the population diversity. The detailed steps of clone selection are as follows:Step 1: selectm individuals with good fitness from the grey wolf population according to the fitness function value to form an elite population (set the m value to 1/4 of the number of grey wolf individuals).Step 2: clone all grey wolf individuals in the elite population. The clone size is directly proportional to the numberm of the selected elite population to form a temporary population T with the size of NC. The calculation of NC is as follows:(8)Tc=∑x=1wroundλwx+h.The round () function is a rounding function.λ is a random number between [0, 1]. H is an integer constant and h ≥ 1. Compared with the original population t, the size of Tc is positively correlated with the value of h, which can ensure that each individual in the elite population has a certain number of clones.In step 3, high-frequency mutation is implemented for each individual in the population to obtain better candidate solutions near elite individuals. The variation operation is shown in the following formulas:(9)nxnew=nx+u⋅η⋅nx⋅r4−u⋅η⋅nx⋅r5,(10)u=1,r6⩽0.5,0,other,(11)η=1−1/exp1−1×expx/xmax−1−1,  where nx is the individual of the xth iteration of population n; nxnew is a new individual produced by nx after mutation operation; r4,r5,r6 are random numbers between [0, 1]; X stands for iteration x; xmax represents the maximum number of iterations of immune cloning operation; and η is a clonal variation parameter. It can be seen from formula (11) that the number of iterations is negatively correlated with the clone variation parameter η. η is close to 1 at the beginning, with a wide range of variation. At this point, a global range search is performed to ensure population diversity. As the number of iterations increases, the value of η gets closer and closer to 0, indicating that local searches are performed within a small range to increase fine-tuning capability and ensure the accuracy of the search.Step 4: selectw better individuals from N as the elite individual population for the next iteration until the maximum number of iterations of immune cloning operation is reached.


## 2.3. Particle Swarm Location Update Idea

In the grey wolf optimization algorithm, it can be seen from formula (5) that the position change of grey wolf is mainly to explore the prey position according to the position of three wolves. Then, three wolves (α, β, and δ) led the position update. Because we are now facing the elite population, the information contained in the prey search results of each elite individual may have an impact on the search results of the final location of the prey. Therefore, it is necessary to consider the location information of a single elite individual, so as to maximize the utilization rate of elite individuals and expand the search range of prey around elite individuals.This article is inspired by the idea of location update of particle swarm optimization algorithm. It introduces the position change idea of a single grey wolf into the grey wolf position update to avoid premature convergence of the algorithm. Adjust the update strategy of formula (7) accordingly as follows.(12)In+1=I1+I2+I33+qn,where the position change qn of a single grey wolf is expressed as the following formula:(13)qn+1=mqn+C1⋅r7I1−In+C2⋅r8I2−In+C3⋅r9I3−In,where m is the random number between [0, 1]. After many simulation experiments, when the value of m is between [0.6, 1], the algorithm has better search performance and more accurate optimization results. When m is large, it has better global search ability. When w is small, the local search ability is strong, which can effectively avoid premature convergence. r6,r7,r8 are random numbers between [0, 1]. C1, C2, C3 are obtained from formula (4). I1,I2,I3 are obtained from formula (6). In represents the current position of the grey wolf.


## 2.4. Clustering Algorithm Based on GWO and K-Means

Because the input data of agricultural financial risk is usually in the format of text document, and the text document belongs to unstructured data, this article needs to preprocess the text document before text clustering. Convert text data type to data that can be input by GWO K-means algorithm. The basic steps of text preprocessing are text word segmentation, removal of stop words, text feature selection, and text vectorization.This article uses Jieba word segmentation in Python to segment text documents and remove stop words. Commonly used text representation models mainly include Boolean space model (BM) [12], suffix tree model (STM) [13], vector space model (VSM) [14], and probabilistic retrieval model (PM) [15]. In this article, the most classical text vector model (VSM) is used for text vectorization. For document D, it is represented by nf−xdf1,nf−xdf2,…,nf−xdft. The calculation formula of nf−xdf is as follows:(14)nf−xdfn,D=lhnfn,D+0.1×lhT/tx∑x=1tlhnfn,D+0.1×lhT/tx2,where tx is the number of documents containing the word nx, T is the total number of documents, and nfn,d indicates the number of times the word nx appears in document D.In this article, GWO and K-means algorithm are used for text clustering analysis. Specifically, GWO algorithm is used to find a group of optimal clustering centres to minimize the distance from all texts in each category to the group of clustering centres, that is, the similarity of each document is the largest. In GWO algorithm, the fitness function is the goal of grey wolf to find the optimal solution. In K-means algorithm, the sum of intraclass distances is an important index to measure the advantages and disadvantages of clustering algorithm. The smaller the value, the better the clustering performance. The purpose of the combination of GWO and K-means algorithm is to use the powerful optimization ability of GWO algorithm to accurately find the optimal clustering centre. Text documents are classified by the clustering centre. This article selects the sum of the intraclass distances between text documents as the fitness evaluation function of GWO algorithm. As shown in formula:(15)Y=∑y=1Z∑∀sx∈cydsx,cy2,where z stands for clustering category.


## 3. System Design of This Article

The structure of agricultural industry financial risk early warning system should be considered from three aspects. It includes acquisition system, which is used for data acquisition and input. It specifically includes macro financial data, risk event data, etc. There is also a database system for inductive analysis of data. And the most critical early warning system for risk prediction and monitoring (as shown in Figure1).Figure 1
The structure diagram of agricultural industry financial risk early warning system.In the process of information collection, it is necessary to adopt the means of data mining, assisted by manual intervention to collect and sort out the data. The direction of data mining can include crawler technology and scanning monitoring technology, such as risk event crawler and scanning monitoring of risk indicators. The architecture of the acquisition system is shown in Figure2.Figure 2
Acquisition system architecture diagram.The amount of data collected is huge and comes from a wide range of sources, which cannot be measured by a unified standard. Therefore, further induction and analysis are needed, and the rationality and function of the database system are highlighted. By means of improved K-means clustering algorithm, the early warning model is trained through a large number of data to improve the early warning of agricultural financial risk early warning system. The system architecture is shown in Figure3.Figure 3
The database system architecture.Early warning system is the explicit output part of the whole agricultural industry financial risk early warning system. Its coverage include risk analysis, prediction analysis, and early warning tracking. Considering that there may be some deviation between the predicted results and the actual results, it is necessary to introduce technical means such as improved K-means clustering algorithm in this article. The predicted results and the actual results are constantly compared and analyzed, and the results are constantly optimized through a large amount of data training. Finally, the prediction results are constantly improved, and the scientificity and accuracy of the results are also improved. Considering that there are many sudden risk factors in financial activities, it is necessary to rely on human intervention. Moreover, the changes of financial activities are very fast and are constantly updated and iterated. Therefore, the early warning system should also be accompanied by a correction algorithm. Continuously iterate and upgrade to optimize the system. The architecture of the early warning system is shown in Figure4. In the training stage, the model is implemented by human participation. In the experimental testing stage, it is learned and corrected by the model itself.Figure 4
Architecture of early warning system.


## 4. Experiment and Analysis

### 4.1. Data Collection and Sorting

A total of 3,812 enterprise data sets of listed companies from 2,000 to 2,020 were extracted from Cathay Pacific and other databases. After data cleaning, enterprise data sets are divided according to whether they are in ST (special treatment) state, and 472 ST enterprise data sets and 3,167 normal enterprise data sets are obtained. In addition, according to the company information recorded in the data set, we sorted out the high-dimensional feature collection based on the financial characteristics of agricultural industry and nonagricultural industry. This study divides the characteristics of enterprises by agricultural industrial financial indicators and nonagricultural industrial financial indicators. The training set and test set are obtained by multilevel division based on business ability, profitability, growth ability, and management structure.


### 4.2. Characteristic Causal Analysis

In the ST enterprise data set, if the company is repeatedly in ST within the time range studied in this article, the timeline of being in ST for the first time shall prevail. According to the timeline of ST for the first time or the timeline recorded in the normal data set, the stability of ST data set and normal data set is tested. After the stationarity test is completed, the code is constructed according to the dimensionality reduction steps of the model in this study, and the low-dimensional feature collection corresponding to the high-dimensional feature table is obtained through iterative training.


### 4.3. Integrated Classifier Training

As shown in Figure2, the low-dimensional feature collection (including nonagricultural industrial financial low-dimensional feature collection and agricultural industry financial low-dimensional feature collection) is used as the first training data set to train the integrated classifier. By monitoring the function value objectK of the objective function, the curve between the function value and the training times is constructed. At the same time, in order to compare the excellence of low-dimensional feature collection with high-dimensional feature collection in the training process of integrated classifier, high-dimensional feature collection (including nonagricultural industrial finance high-dimensional feature collection and agricultural industrial finance high-dimensional feature collection) is taken as the second training data set. The integrated classifier is trained to get the training comparison diagram of low-dimensional feature collection and high-dimensional feature collection in the integrated classifier (see Figure 5).Figure 5
Training of high-dimensional and low-dimensional integrated classifier.According to Figure3, when using low-dimensional feature collection to train the integrated classifier, the training times reach 700, the change range of the target value tends to be stable. The average value of the target value is 0.0519, and the training of the integrated classifier is completed. When using high-dimensional feature collection to train the integrated classifier, the change range of the target value tends to be stable after 900 times of training. And the average value of the target value is 0.0636. It can be seen that the low-dimensional feature collection obtained by using the feature causal analysis in this model is more conducive to the training of integrated classifiers in terms of training times, target value, and stability.Literature [16] and literature [17] are relatively typical models with feature analysis and financial early warning function of agricultural industry. In order to explore the comparative results of this model with literature [16] and [17] model, data enrichment was performed on the second training data set above to obtain the third training data set. Proposed model, literature [16] model, and literature [17] model were successively trained to obtain the comparison figure (see Figure 6).Figure 6
Training comparison of proposed model.According to Figure6, in the training cycle, the model cycle in this study is the longest, and the objective function value needs to reach about 1,500 times before it tends to be stable. Literature [17] takes the second place, and it takes about 1,000 training times for the value of the objective function to stabilize. Literature [16] is at least 1,000 times. In terms of objective function value, when the training of each model is completed, the objective function value of the model in this study is the smallest, with an average value of 0.055. In literature [17], the mean value of objective function is 0.081 and in literature [16] it is 0.067. The model in this study has the best adaptability to the third training data set and the highest early warning accuracy.


### 4.4. Comparative Analysis of Financial Risk Models

After the model training is completed, this study selects the comparison model based on machine learning and deep learning. Among them, the machine learning model selects the literature [18] model with simple model structure and fast training speed and adds the literature [16] model with stationarity test to improve the robustness of the model. The literature [17] model of dimension reduction operation is added under the low-dimensional feature set. Literature [19] model with excellent performance is added under high-dimensional feature collection. For the in-depth learning model, the typical literature [20] model is selected. Through comparison, the actual early warning performance of this model is further evaluated.First, the test data set including 83 dimensions is divided into three groups, and the accuracy of each group is tested by each model (as shown in Table1).Table 1
The accuracy of each model.
ModelTraining accuracy (%)Test accuracy (%)Average accuracy (%)Group 1Group 2Group 3Literature [18]80.0271.2870.2869.3570.30Literature [16]87.0277.4478.9480.1478.84Literature [19]91.9281.2780.6783.5781.84Literature [20]89.2179.9581.0281.4580.81Literature [17]94.7184.285.285.5284.97Proposed96.5986.3886.6487.2986.77Combined with the performance of each model in Table2, we can see the difference between machine learning and deep learning. Compared with machine learning, deep learning has obvious advantages in image and natural language [39, 40]. However, in the direction of corporate agricultural industry financial early warning, the early warning performance of the early warning model based on machine learning is not necessarily worse than that of the deep learning model. For example, in literature [17], its training accuracy and test accuracy are obviously superior to literature [20]. The early warning model constructed by a single improved K-means clustering algorithm generally does not have the function of feature screening, such as literature [18]. However, the shortcomings of not having feature screening can be overcome by combining models, such as literature [16], literature [17], etc. Moreover, the early warning performance of the combined model can generally be further improved.Table 2
Test accuracy of each model under ratio removal characteristics.
Model0% test accuracy25% test accuracy50% test accuracy75% test accuracyRange of accuracy changeLiterature [18]70.1272.1573.473.23.96Literature [16]78.6679.0878.3776.912.85Literature [19]81.6683.6483.1279.854.47Literature [20]80.6378.0472.7471.729.59Literature [17]84.7986.8785.9582.942.76Proposed86.5987.9683.9980.957.69Combined with (1) and (2), in terms of corporate agricultural industry financial early warning, compared with the deep learning model, the clustering algorithm proposed in this article has a better early warning performance. This further verifies the feasibility of combining the grey Wolf optimization algorithm with K-means algorithm for cluster analysis.From the perspective of the specific performance of each model, the six groups of models can realize the role of agricultural industry financial early warning. However, compared with the other five groups of models, the accuracy of this model is higher. On the premise that each group of models is trained 2000 times, the training accuracy of this model reaches the highest 96.59%, which is superior to the second best performance literature [17]. In addition, this model also has better feature screening ability. Compared with other models that also have feature screening, such as literature [20], literature [17], literature [16], etc., the model test accuracy of this study is ahead of other groups of models, reaching 86.77%. Therefore, generally speaking, proposed model has strong feature screening ability and effectively improve the accuracy of the company’s agricultural industry financial early warning.The impact of changes in feature dimensions on the early warning performance of the model in the enterprise dataset will be further explored. Based on the principle of removing features in proportion, 83 groups of features in the above test data set are removed. If 25%, 50%, and 75% features in the test data set are removed in turn, 25%, 50%, and 75% test data sets are obtained respectively. The corresponding original test data set is abbreviated as 0% test data set, indicating that feature removal is not performed. Thereafter, four groups of test data sets of 0%, 25%, 50%, and 75% were used successively. The early warning performance of the above six groups of models is evaluated and shown in Table2.With the continuous reduction of feature dimensions in the test data set, the accuracy of different models also varies greatly. Among them, the change of feature dimension has the least impact on the test accuracy of literature [17] and literature [16], and the change range is no more than 2.5%. The change of feature dimension has the greatest impact on the accuracy of proposed model and literature [20]. With the decreasing of feature dimension, the accuracy of convolution neural network and long-term and short-term memory network decreases.In order to further explore the impact of the change of feature dimension on the early warning performance of the model, this study adopts the method of reducing each group of test data sets by 5%. Then, a total of 18 test data sets can be obtained, namely 0%, 5%, 10%, …, 80%, 85%. Among them, 0% of the test data sets still represent the features not removed and 85% of the test data sets represent the data sets after 85% of the features have been removed.The accuracy of each model in the above 18 groups of test data sets is summarized, and a dotted line diagram of the accuracy and feature removal ratio is constructed (see Figures7 and 8).Figure 7
Point line relationship between test accuracy of each model and feature removal ratio.Figure 8
Fitting curve of test accuracy and feature removal ratio of each model.Further, the fourth-order polynomial is used to fit each point line in Figure7 to obtain the fitting curve of accuracy and feature removal ratio (see Figure 8).As can be seen from the overall performance of each fitting curve in Figure8, the accuracy of proposed model and machine learning models such as literature [18] and literature [17] will fluctuate in a small range and tend to decline gently as the enterprise feature dimension decreases. The accuracy of literature [20] represented by deep learning will drop sharply without fluctuation. Therefore, the model and machine model in this study have stronger model stability and robustness than literature [20].Importantly, each set of models corresponds to the feature optimal dimension. That is, compared with the performance of the model in the nonoptimal dimension, the early warning performance under the optimal dimension is often the best. Among them, the feature optimal dimension of the model in this study is about [63, 82] (corresponding to thex-axis [0, 23] in Figure 8). At this point, the test accuracy is as high as 87.26%, which is obviously better than other models. When the feature number removal ratio is greater than 23%, the early warning performance of this model gradually declines. In the interval [47, 63] (corresponding to the x-axis [23, 42] in Figure 8), the early warning performance of the model in this study is reversed by literature [17], that is [47, 63] becomes the feature optimal dimension of literature [17]. In other words, compared with other models, the model in this study has a larger feature optimal dimension (e.g., the test data set given in this study, the optimal dimension of agricultural industry financial features is [63, 82]). Then, it is concluded that the model in this study has the same performance for agricultural industry financial early warning with low-dimensional features. But it has obvious advantages in high-dimensional features, and the accuracy of early warning is much higher than that of other models.


## 4.1. Data Collection and Sorting

A total of 3,812 enterprise data sets of listed companies from 2,000 to 2,020 were extracted from Cathay Pacific and other databases. After data cleaning, enterprise data sets are divided according to whether they are in ST (special treatment) state, and 472 ST enterprise data sets and 3,167 normal enterprise data sets are obtained. In addition, according to the company information recorded in the data set, we sorted out the high-dimensional feature collection based on the financial characteristics of agricultural industry and nonagricultural industry. This study divides the characteristics of enterprises by agricultural industrial financial indicators and nonagricultural industrial financial indicators. The training set and test set are obtained by multilevel division based on business ability, profitability, growth ability, and management structure.


## 4.2. Characteristic Causal Analysis

In the ST enterprise data set, if the company is repeatedly in ST within the time range studied in this article, the timeline of being in ST for the first time shall prevail. According to the timeline of ST for the first time or the timeline recorded in the normal data set, the stability of ST data set and normal data set is tested. After the stationarity test is completed, the code is constructed according to the dimensionality reduction steps of the model in this study, and the low-dimensional feature collection corresponding to the high-dimensional feature table is obtained through iterative training.


## 4.3. Integrated Classifier Training

As shown in Figure2, the low-dimensional feature collection (including nonagricultural industrial financial low-dimensional feature collection and agricultural industry financial low-dimensional feature collection) is used as the first training data set to train the integrated classifier. By monitoring the function value objectK of the objective function, the curve between the function value and the training times is constructed. At the same time, in order to compare the excellence of low-dimensional feature collection with high-dimensional feature collection in the training process of integrated classifier, high-dimensional feature collection (including nonagricultural industrial finance high-dimensional feature collection and agricultural industrial finance high-dimensional feature collection) is taken as the second training data set. The integrated classifier is trained to get the training comparison diagram of low-dimensional feature collection and high-dimensional feature collection in the integrated classifier (see Figure 5).Figure 5
Training of high-dimensional and low-dimensional integrated classifier.According to Figure3, when using low-dimensional feature collection to train the integrated classifier, the training times reach 700, the change range of the target value tends to be stable. The average value of the target value is 0.0519, and the training of the integrated classifier is completed. When using high-dimensional feature collection to train the integrated classifier, the change range of the target value tends to be stable after 900 times of training. And the average value of the target value is 0.0636. It can be seen that the low-dimensional feature collection obtained by using the feature causal analysis in this model is more conducive to the training of integrated classifiers in terms of training times, target value, and stability.Literature [16] and literature [17] are relatively typical models with feature analysis and financial early warning function of agricultural industry. In order to explore the comparative results of this model with literature [16] and [17] model, data enrichment was performed on the second training data set above to obtain the third training data set. Proposed model, literature [16] model, and literature [17] model were successively trained to obtain the comparison figure (see Figure 6).Figure 6
Training comparison of proposed model.According to Figure6, in the training cycle, the model cycle in this study is the longest, and the objective function value needs to reach about 1,500 times before it tends to be stable. Literature [17] takes the second place, and it takes about 1,000 training times for the value of the objective function to stabilize. Literature [16] is at least 1,000 times. In terms of objective function value, when the training of each model is completed, the objective function value of the model in this study is the smallest, with an average value of 0.055. In literature [17], the mean value of objective function is 0.081 and in literature [16] it is 0.067. The model in this study has the best adaptability to the third training data set and the highest early warning accuracy.


## 4.4. Comparative Analysis of Financial Risk Models

After the model training is completed, this study selects the comparison model based on machine learning and deep learning. Among them, the machine learning model selects the literature [18] model with simple model structure and fast training speed and adds the literature [16] model with stationarity test to improve the robustness of the model. The literature [17] model of dimension reduction operation is added under the low-dimensional feature set. Literature [19] model with excellent performance is added under high-dimensional feature collection. For the in-depth learning model, the typical literature [20] model is selected. Through comparison, the actual early warning performance of this model is further evaluated.First, the test data set including 83 dimensions is divided into three groups, and the accuracy of each group is tested by each model (as shown in Table1).Table 1
The accuracy of each model.
ModelTraining accuracy (%)Test accuracy (%)Average accuracy (%)Group 1Group 2Group 3Literature [18]80.0271.2870.2869.3570.30Literature [16]87.0277.4478.9480.1478.84Literature [19]91.9281.2780.6783.5781.84Literature [20]89.2179.9581.0281.4580.81Literature [17]94.7184.285.285.5284.97Proposed96.5986.3886.6487.2986.77Combined with the performance of each model in Table2, we can see the difference between machine learning and deep learning. Compared with machine learning, deep learning has obvious advantages in image and natural language [39, 40]. However, in the direction of corporate agricultural industry financial early warning, the early warning performance of the early warning model based on machine learning is not necessarily worse than that of the deep learning model. For example, in literature [17], its training accuracy and test accuracy are obviously superior to literature [20]. The early warning model constructed by a single improved K-means clustering algorithm generally does not have the function of feature screening, such as literature [18]. However, the shortcomings of not having feature screening can be overcome by combining models, such as literature [16], literature [17], etc. Moreover, the early warning performance of the combined model can generally be further improved.Table 2
Test accuracy of each model under ratio removal characteristics.
Model0% test accuracy25% test accuracy50% test accuracy75% test accuracyRange of accuracy changeLiterature [18]70.1272.1573.473.23.96Literature [16]78.6679.0878.3776.912.85Literature [19]81.6683.6483.1279.854.47Literature [20]80.6378.0472.7471.729.59Literature [17]84.7986.8785.9582.942.76Proposed86.5987.9683.9980.957.69Combined with (1) and (2), in terms of corporate agricultural industry financial early warning, compared with the deep learning model, the clustering algorithm proposed in this article has a better early warning performance. This further verifies the feasibility of combining the grey Wolf optimization algorithm with K-means algorithm for cluster analysis.From the perspective of the specific performance of each model, the six groups of models can realize the role of agricultural industry financial early warning. However, compared with the other five groups of models, the accuracy of this model is higher. On the premise that each group of models is trained 2000 times, the training accuracy of this model reaches the highest 96.59%, which is superior to the second best performance literature [17]. In addition, this model also has better feature screening ability. Compared with other models that also have feature screening, such as literature [20], literature [17], literature [16], etc., the model test accuracy of this study is ahead of other groups of models, reaching 86.77%. Therefore, generally speaking, proposed model has strong feature screening ability and effectively improve the accuracy of the company’s agricultural industry financial early warning.The impact of changes in feature dimensions on the early warning performance of the model in the enterprise dataset will be further explored. Based on the principle of removing features in proportion, 83 groups of features in the above test data set are removed. If 25%, 50%, and 75% features in the test data set are removed in turn, 25%, 50%, and 75% test data sets are obtained respectively. The corresponding original test data set is abbreviated as 0% test data set, indicating that feature removal is not performed. Thereafter, four groups of test data sets of 0%, 25%, 50%, and 75% were used successively. The early warning performance of the above six groups of models is evaluated and shown in Table2.With the continuous reduction of feature dimensions in the test data set, the accuracy of different models also varies greatly. Among them, the change of feature dimension has the least impact on the test accuracy of literature [17] and literature [16], and the change range is no more than 2.5%. The change of feature dimension has the greatest impact on the accuracy of proposed model and literature [20]. With the decreasing of feature dimension, the accuracy of convolution neural network and long-term and short-term memory network decreases.In order to further explore the impact of the change of feature dimension on the early warning performance of the model, this study adopts the method of reducing each group of test data sets by 5%. Then, a total of 18 test data sets can be obtained, namely 0%, 5%, 10%, …, 80%, 85%. Among them, 0% of the test data sets still represent the features not removed and 85% of the test data sets represent the data sets after 85% of the features have been removed.The accuracy of each model in the above 18 groups of test data sets is summarized, and a dotted line diagram of the accuracy and feature removal ratio is constructed (see Figures7 and 8).Figure 7
Point line relationship between test accuracy of each model and feature removal ratio.Figure 8
Fitting curve of test accuracy and feature removal ratio of each model.Further, the fourth-order polynomial is used to fit each point line in Figure7 to obtain the fitting curve of accuracy and feature removal ratio (see Figure 8).As can be seen from the overall performance of each fitting curve in Figure8, the accuracy of proposed model and machine learning models such as literature [18] and literature [17] will fluctuate in a small range and tend to decline gently as the enterprise feature dimension decreases. The accuracy of literature [20] represented by deep learning will drop sharply without fluctuation. Therefore, the model and machine model in this study have stronger model stability and robustness than literature [20].Importantly, each set of models corresponds to the feature optimal dimension. That is, compared with the performance of the model in the nonoptimal dimension, the early warning performance under the optimal dimension is often the best. Among them, the feature optimal dimension of the model in this study is about [63, 82] (corresponding to thex-axis [0, 23] in Figure 8). At this point, the test accuracy is as high as 87.26%, which is obviously better than other models. When the feature number removal ratio is greater than 23%, the early warning performance of this model gradually declines. In the interval [47, 63] (corresponding to the x-axis [23, 42] in Figure 8), the early warning performance of the model in this study is reversed by literature [17], that is [47, 63] becomes the feature optimal dimension of literature [17]. In other words, compared with other models, the model in this study has a larger feature optimal dimension (e.g., the test data set given in this study, the optimal dimension of agricultural industry financial features is [63, 82]). Then, it is concluded that the model in this study has the same performance for agricultural industry financial early warning with low-dimensional features. But it has obvious advantages in high-dimensional features, and the accuracy of early warning is much higher than that of other models.


## 5. Conclusion

Agricultural industry finance is a weak link in China’s financial system. In order to improve the risk warning ability of agricultural industry, this article proposes an agricultural industry financial risk warning system based on improved K-means clustering algorithm. In order to solve the problem that K-means algorithm cannot jump out of the local optimal solution in the clustering process, this study combines the grey Wolf optimization algorithm with K-means algorithm for clustering analysis. In the iterative process of grey Wolf optimization algorithm, the elite individuals in grey Wolf population were cloned and mutated. In this way, elite individuals can be deeply mined, the depth exploration ability of grey Wolf optimization algorithm can be improved, and the local extremum of grey Wolf optimization algorithm can be avoided. At the same time, the algorithm is applied to cluster analysis and cosine distance similarity is used to calculate the similarity between data samples. The effectiveness of the proposed algorithm is verified by comparing the prediction results of different algorithms on agricultural financial risks. The next research direction is to systematically analyze the performance consumption of the algorithm and optimize the performance of the algorithm on the premise of ensuring the accuracy of financial risk prediction.



---

*Source: 3751539-2022-04-28.xml*