A method for assigning geochemical element content based on adaptive k-nearest neighbor

By using the adaptive k-nearest neighbor method in the land quality geochemical evaluation, the weight of geological factors and the sample similarity is calculated, the problem of missing values ​​of unknown samples is solved, and high-precision and intelligent assignment effects are achieved.

CN115114577BActive Publication Date: 2025-03-21HUBEI GEOLOGICAL SURVEY INST +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210856253.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-13
Publication Date
2025-03-21
Estimated Expiration
2042-07-13

AI Technical Summary

Technical Problem

In the land quality geochemical evaluation, the prior art has failed to effectively solve the problem of missing geochemical element values ​​in unknown samples, especially when intelligent and high-precision assignment is required.

Method used

Using an adaptive k-nearest neighbor method, the k-nearest neighbor algorithm and an adaptive calculation method for adaptively determining the k-nearest neighbor algorithm and factor weights is calculated, the weights of four factors: geological background, soil type, land use type, and altitude are calculated, and the similarity between the k-nearest neighbor sample and the unknown sample is calculated, and then the unknown sample is assigned.

Benefits of technology

Intelligent assignment of unknown samples is realized, the accuracy and reliability of assignment is improved, the influence of outliers is avoided, and it can ensure that unknown samples can find k nearest neighbor samples without specifying distance range.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115114577B_ABST
    Figure CN115114577B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for assigning geochemical element contents based on adaptive k-nearest neighbors, comprising the following steps: using an adaptive weight algorithm of factors to calculate the weights of influencing factors; using an adaptive k-nearest neighbor algorithm to calculate the k-nearest neighbors of unknown samples; using an adaptive similarity algorithm of k-nearest neighbor samples to calculate the similarity between k-nearest neighbor known samples and unknown samples; assigning values ​​to unknown samples. The present invention proposes an adaptive weight algorithm of factors to effectively distinguish the control strength of factors affecting changes in chemical elements; and proposes an adaptive similarity algorithm of k-nearest neighbor samples, the more similar the k-nearest neighbor known samples are to the unknown samples, the smaller the similarity distance is; the similarity between the k-nearest neighbor known samples and the unknown samples is calculated based on the similarity distance, the smaller the similarity distance is, the greater the similarity is, and the degree of influence of the k-nearest neighbor known samples on the assignment of unknown samples is effectively distinguished, and the method has a high tolerance for abnormal known samples and good noise resistance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a geochemical element content assignment method based on adaptive k nearest neighbors. Background Art

[0002] Geochemical evaluation of land quality refers to the use of geochemical elements and other indicators to rate land. It is an essential task to rationally plan and utilize land resources, avoid waste of land resources, and reduce environmental pollution. However, there are objective reasons that lead to the missing geochemical element values ​​of some samples. For example, natural conditions restrict researchers from reaching certain areas for sampling. Therefore, a method for assigning geochemical element content is needed to assign values ​​to unknown samples in order to complete the geochemical evaluation of land quality.

[0003] In areas with complex backgrounds, clear and strong control factors of chemical elements, the three-factor assignment method is usually used to assign values ​​to unknown samples. This method combines the three factors of geological background, soil type, and land use type within the range of the two-dimensional Euclidean distance specified by the unknown sample, and calculates the average value of chemical elements of the effective samples to assign values ​​to the unknown samples. This method follows the principle of close distance and similar geological properties, conforms to the law of geological evolution, and can obtain better assignment results. However, this method requires specifying the distance range for selecting effective samples for unknown samples, and the degree of intelligence is not high. In addition, actual investigations have found that the three factors of geological background, soil type, and land use type have different degrees of influence on the changes in chemical element content, but this method regards known samples with the same three-factor values ​​as unknown samples as effective samples, without distinguishing the degree of control of the three factors on the changes in chemical elements. Moreover, if effective samples cannot be screened out within the specified range, the unknown samples cannot be assigned values. When assigning values, the degree of influence of different effective samples on the assignment of unknown samples is not distinguished, and it is easily affected by outliers, and the assignment accuracy needs to be improved.

[0004] Therefore, a method for assigning geochemical element content based on adaptive k-nearest neighbors needs to be proposed urgently. Summary of the invention

[0005] In order to solve the defects of the prior art, the present invention provides a method for assigning geochemical element content based on adaptive k-nearest neighbors.

[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0007] The present invention provides a geochemical element content assignment method based on adaptive k-nearest neighbor, comprising the following steps:

[0008] Step 1: Use the adaptive calculation method of factor weights to calculate the weights of the four influencing factors of geological background, soil type, land use type, and altitude; the adaptive calculation method of factor weights is referred to as the adaptive weight algorithm of factors; specifically, the following steps are included:

[0009] Step 11: Randomly select 100 known samples, denoted as x i , i = 1, 2, ..., 100; if the number of known samples is less than 100, select all known samples; let n j =0, j=1,2,…,4, which respectively represent the number of samples whose chemical element contents are mainly controlled by geological background, the number of samples whose chemical element contents are mainly controlled by soil type, the number of samples whose chemical element contents are mainly controlled by land use type, and the number of samples whose chemical element contents are mainly controlled by altitude;

[0010] Step 12: For the selected sample x i , among other known samples, use the adaptive k-nearest neighbor algorithm to calculate x i k nearest neighbors; for all selected samples with k value equal to 0, set the k value equal to the average k value of other selected samples;

[0011] Step 13: Record the k nearest neighbor samples with x i The sample with the smallest difference in chemical element content is a i ,i=1,2,…,k;k nearest neighbor samples are similar to x i There may be multiple samples with the smallest difference in chemical element content, with a minimum of 1 and a maximum of k;

[0012] Step 14: Statistics a i , i=1,2,…,k, and x i The number of samples with the same geological background is denoted as m1 and x i The number of samples with the same soil type is recorded as m2, which is the same as x i The number of samples with the same land use type is denoted as m3, which is the same as x i The altitude difference is exactly the number of samples with the smallest difference among the k nearest neighbor samples, denoted as m4, then n j =n j +m j , j = 1, 2, ..., 4;

[0013] Step 15: Calculate the weights w of the four influencing factors: geological background, soil type, land use type, and altitude j , j=1,2,…,4:

[0014]

[0015] Step 2: For unknown samples, use the adaptive k-nearest neighbor algorithm to calculate its k-nearest neighbors among all known samples; for all unknown samples with k value equal to 0, set the k value equal to the average of the k values ​​of other unknown samples;

[0016] In step 2 and step 12, in the sample set, the k nearest neighbors of the sample x0 are calculated using the adaptive k nearest neighbor algorithm; the algorithm autonomously learns in the sample set to obtain the k nearest neighbor samples that are most similar to the geological properties of x0 and closest to the two-dimensional space distance, and the degree of intelligence is high; wherein, the k nearest neighbors of the sample x0 are calculated using the adaptive k nearest neighbor algorithm, including the following steps:

[0017] Step 21: Initialize k=1;

[0018] Step 22: Let the kth nearest neighbor sample of x0 in the two-dimensional Euclidean distance in the sample set be b, and determine whether b is different from x0 in terms of geological background, soil type, and land use type. If they are all different, execute step 24, otherwise execute step 23;

[0019] Step 23: k=k+1, execute step 22;

[0020] Step 24: k=k-1, determine k nearest neighbors;

[0021] Step 3: Calculate the similarity between the k-nearest neighbor known sample and the unknown sample using the adaptive calculation method of the similarity between the k-nearest neighbor known sample and the unknown sample; wherein the adaptive calculation method of the similarity between the k-nearest neighbor known sample and the unknown sample is referred to as the adaptive similarity algorithm of the k-nearest neighbor sample; comprising the following steps:

[0022] Step 31: Calculate the similarity distance D between the k nearest neighbor known sample and the unknown sample:

[0023]

[0024] Among them, w j ∈[0, 1], j = 1, 2, ..., 4 are the weights of the four influencing factors of geological background, soil type, land use type, and altitude calculated in step 1. Different weights effectively distinguish the control strength of the four factors on the change of chemical element content; d j ∈[0,1], j=1,2,...,4 are the geological background distance, soil type distance, land use type distance, and altitude distance from the known sample to the unknown sample respectively;

[0025] If the geological background of the known sample and the unknown sample is the same, the geological background distance from the known sample to the unknown sample is 0, otherwise it is 1; if the soil type of the known sample and the unknown sample is the same, the soil type distance from the known sample to the unknown sample is 0, otherwise it is 1; if the land use type of the known sample and the unknown sample is the same, the land use type distance from the known sample to the unknown sample is 0, otherwise it is 1; the calculation process of the altitude distance d4 from the k nearest neighbor known sample to the unknown sample is as follows:

[0026] Step 311: Calculate the absolute value d′4 of the difference between the altitudes of the k nearest neighbor known samples and the unknown samples:

[0027] d′4=|h1-h2|,

[0028] Among them, h1 is the altitude of the k nearest neighbor known samples, and h2 is the altitude of the unknown samples;

[0029] Step 312: Determine whether the minimum value of d′4 in step 311 is equal to the maximum value of d′4. If yes, execute step 313; otherwise, execute step 314.

[0030] Step 313: Calculate the altitude distance d4 from the k nearest neighbor known sample to the unknown sample:

[0031] d4=[0,0,...,0],

[0032] Among them, the number of elements of d4 is k;

[0033] Step 314: Normalize d′4 to its maximum and minimum values ​​to obtain the altitude distance d4 from the k nearest neighbor known sample to the unknown sample:

[0034]

[0035] Among them, min(d′4) is the minimum value of d′4, and max(d′4) is the maximum value of d′4;

[0036] Step 32: Calculate the similarity v between the k nearest neighbor known samples and the unknown samples i :

[0037]

[0038] Among them, D i is the similarity distance of the i-th nearest neighbor known sample;

[0039] Step 4: Assign values ​​to unknown samples based on the k nearest neighbor known samples and their similarity to the unknown samples.

[0040] Furthermore, in step 4, the unknown sample is assigned a value R:

[0041]

[0042] Among them, v i is the similarity between the known sample of the i-th nearest neighbor and the unknown sample. Different similarities can effectively distinguish the influence of the k-nearest neighbor known samples on the unknown sample assignment; r i is the chemical element content of the i-th nearest known sample.

[0043] Compared with the prior art, the present invention has the following beneficial effects:

[0044] (1) The present invention proposes an adaptive k-nearest neighbor algorithm, which searches for known samples with the same three-factor values ​​as the unknown sample from near to far according to the two-dimensional Euclidean distance, and determines the k-nearest neighbors, so that the unknown sample can definitely search for the k-nearest neighbor known samples and then obtain the assignment; in addition, no parameters need to be specified, and the degree of intelligence is high;

[0045] (2) The present invention proposes an adaptive calculation method for factor weights (abbreviated as adaptive factor weight algorithm). The algorithm autonomously learns from known samples and calculates the weights of factors that affect the changes of chemical elements for different chemical elements. A larger weight is assigned to factors that have a greater impact on the changes of chemical elements, which effectively distinguishes the control strength of factors that affect the changes of chemical elements, and is more scientific and reasonable.

[0046] (3) The present invention proposes an adaptive calculation method for the similarity between k-nearest neighbor known samples and unknown samples (abbreviated as adaptive similarity algorithm for k-nearest neighbor samples), defines a similarity distance formula, calculates the similarity distance of k-nearest neighbor known samples, and measures the similarity between k-nearest neighbor known samples and unknown samples. The more similar the k-nearest neighbor known samples are to the unknown samples, the smaller the similarity distance is. The similarity between the k-nearest neighbor known samples and the unknown samples is calculated based on the similarity distance. The smaller the similarity distance is, the higher the similarity is. The method effectively distinguishes the influence of k-nearest neighbor known samples on the assignment of unknown samples, has a high tolerance for abnormal known samples, and has good noise resistance.

[0047] (4) Actual investigations have found that when the geological background, soil type, and land use type are the same, the chemical element content varies greatly at different altitudes. The present invention considers altitude as one of the influencing factors; comprehensively considers the geological background, soil type, land use type, and altitude to calculate the similarity between the unknown sample and the k-nearest neighbor known sample, thereby further improving the assignment accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 It is a workflow diagram of a geochemical element content assignment method based on adaptive k-nearest neighbors of the present invention;

[0049] Figure 2 It is a workflow diagram of the adaptive weight algorithm of factors in the present invention;

[0050] Figure 3 It is a workflow diagram of using the adaptive k-nearest neighbor algorithm to calculate the k-nearest neighbors of an unknown sample in the present invention;

[0051] Figure 4 It is a workflow diagram of the adaptive similarity algorithm of k nearest neighbor samples in the present invention;

[0052] Figure 5 It is a workflow diagram of the method for calculating the altitude distance d4 from the k nearest neighbor known sample to the unknown sample in the present invention. DETAILED DESCRIPTION

[0053] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0054] like Figures 1 to 5 As shown, this embodiment provides a method for assigning geochemical element content based on adaptive k-nearest neighbors, comprising the following steps:

[0055] Step 1: Use the adaptive calculation method of factor weights to calculate the weights of the four influencing factors of geological background, soil type, land use type, and altitude. The adaptive calculation method of factor weights is referred to as the adaptive weight algorithm of factors. According to different chemical elements, weights are assigned to the four influencing factors of geological background, soil type, land use type, and altitude, and the influence of the four factors on the changes in chemical element content is effectively distinguished. Figure 2 As shown, the specific steps include:

[0056] Step 11: Randomly select 100 known samples, denoted as x i , i = 1, 2, ..., 100; if the number of known samples is less than 100, select all known samples; let n j =0, j=1,2,…,4, which respectively represent the number of samples whose chemical element contents are mainly controlled by geological background, the number of samples whose chemical element contents are mainly controlled by soil type, the number of samples whose chemical element contents are mainly controlled by land use type, and the number of samples whose chemical element contents are mainly controlled by altitude;

[0057] Step 12: For the selected sample x i , among other known samples, use the adaptive k-nearest neighbor algorithm to calculate x i k nearest neighbors; for all selected samples with k value equal to 0, set the k value equal to the average k value of other selected samples;

[0058] Step 13: Record the k nearest neighbor samples with x i The sample with the smallest difference in chemical element content is a i,i=1,2,…,k;k nearest neighbor samples are similar to x i There may be multiple samples with the smallest difference in chemical element content, with a minimum of 1 and a maximum of k;

[0059] Step 14: Statistics a i , i=1,2,…,k, and x i The number of samples with the same geological background is denoted as m1 and x i The number of samples with the same soil type is recorded as m2, which is the same as x i The number of samples with the same land use type is denoted as m3, which is the same as x i The altitude difference is exactly the number of samples with the smallest difference among the k nearest neighbor samples, denoted as m4, then n j =n j +m j , j = 1, 2, ..., 4;

[0060] Step 15: Calculate the weights w of the four influencing factors: geological background, soil type, land use type, and altitude j , j=1,2,…,4:

[0061]

[0062] Step 2: For unknown samples, use the adaptive k-nearest neighbor algorithm to calculate their k-nearest neighbors among all known samples; for all unknown samples with k values ​​equal to 0, set the k value equal to the average of the k values ​​of other unknown samples; in the step 2 and step 12, use the adaptive k-nearest neighbor algorithm to calculate the k-nearest neighbors of sample x0 in the sample set; the algorithm autonomously learns in the sample set to obtain the k-nearest neighbor samples that are most similar to the geological attributes of x0 and have the closest two-dimensional space distance, and has a high degree of intelligence; wherein, using the adaptive k-nearest neighbor algorithm to calculate the k-nearest neighbors of sample x0 includes the following steps:

[0063] Step 21: Initialize k=1;

[0064] Step 22: Let the kth nearest neighbor sample of x0 in the two-dimensional Euclidean distance in the sample set be b, and determine whether b is different from x0 in terms of geological background, soil type, and land use type. If they are all different, execute step 24, otherwise execute step 23;

[0065] Step 23: k=k+1, execute step 22;

[0066] Step 24: k=k-1, determine k nearest neighbors;

[0067] Step 3: Use the adaptive calculation method of the similarity between the k-nearest neighbor known samples and the unknown samples to calculate the similarity between the k-nearest neighbor known samples and the unknown samples; where, Figure 4As shown, the adaptive similarity algorithm of k nearest neighbor samples specifically includes the following steps:

[0068] Step 31: Calculate the similarity distance D between the k nearest neighbor known sample and the unknown sample:

[0069]

[0070] Among them, w j ∈[0, 1], j = 1, 2, ..., 4 are the weights of the four influencing factors of geological background, soil type, land use type, and altitude calculated in step 1. Different weights effectively distinguish the control strength of the four factors on the change of chemical element content; d j ∈[0,1], j=1,2,...,4 are the geological background distance, soil type distance, land use type distance, and altitude distance from the known sample to the unknown sample respectively;

[0071] If the geological background of the known sample and the unknown sample is the same, the geological background distance from the known sample to the unknown sample is 0, otherwise it is 1; if the soil type of the known sample and the unknown sample is the same, the soil type distance from the known sample to the unknown sample is 0, otherwise it is 1; if the land use type of the known sample and the unknown sample is the same, the land use type distance from the known sample to the unknown sample is 0, otherwise it is 1; Figure 5 As shown, the calculation process of the altitude distance d4 from the k nearest neighbor known sample to the unknown sample is as follows:

[0072] Step 311: Calculate the absolute value d′4 of the difference between the altitudes of the k nearest neighbor known samples and the unknown samples:

[0073] d′4=|h1-h2|,

[0074] Among them, h1 is the altitude of the k nearest neighbor known samples, and h2 is the altitude of the unknown samples;

[0075] Step 312: Determine whether the minimum value of d′4 in step 41 is equal to the maximum value of d′4. If yes, execute step 313; otherwise, execute step 314.

[0076] Step 313: Calculate the altitude distance d4 from the k nearest neighbor known sample to the unknown sample:

[0077] d4=[0,0,...,0],

[0078] Among them, the number of elements of d4 is k;

[0079] Step 314: Normalize d′4 to its maximum and minimum values ​​to obtain the altitude distance d4 from the k nearest neighbor known sample to the unknown sample:

[0080]

[0081] Among them, min(d′4) is the minimum value of d′4, and max(d′4) is the maximum value of d′4.

[0082] Step 32: Calculate the similarity v between the k nearest neighbor known samples and the unknown samples i :

[0083]

[0084] Among them, D i is the similarity distance of the i-th nearest neighbor known sample.

[0085] Step 4: Assign values ​​to unknown samples based on the k nearest neighbor known samples and their similarity with the unknown samples, and assign R to the unknown samples:

[0086]

[0087] Among them, v i is the similarity between the known sample of the i-th nearest neighbor and the unknown sample. Different similarities can effectively distinguish the influence of the k-nearest neighbor known samples on the unknown sample assignment; r i is the chemical element content of the i-th nearest known sample.

[0088] This embodiment takes the surface soil data of a certain region as an example to illustrate the geochemical element content assignment method based on adaptive k-nearest neighbors:

[0089] Table 1 is the surface soil data of a certain area, among which S01, S02, ..., S07 are known samples, S08, S09, S10 are unknown samples, and the N content of the unknown samples needs to be assigned.

[0090] Table 1, surface soil data of a certain area

[0091]

[0092]

[0093] The present invention is used to search for k nearest neighbor known samples of unknown samples for assignment:

[0094] Step 1: For the N element, use the adaptive weight algorithm of factors to assign weights to the four influencing factors of geological background, soil type, land use type, and altitude:

[0095] 1.1 Initialize n i =0, i=1, 2, ..., 4; since the number of known samples is less than 100, an adaptive weight algorithm of factors is used on all known samples;

[0096] 1.2 Determine the k nearest neighbors of known samples;

[0097] For example, determine the k nearest neighbors of sample S05:

[0098] Initialize k=1;

[0099] Calculate the two-dimensional Euclidean distance to all other known samples, as shown in Table 2:

[0100] Table 2, 2D Euclidean distance from sample S05 to all other known samples

[0101]

[0102] The order of increasing two-dimensional Euclidean distance is: S07, S01, S06, S03, S02, S04;

[0103] Since the soil type and land use type of samples S07 and S05 are the same, k = k + 1;

[0104] Since the soil type and land use type of samples S01 and S05 are the same, k = k + 1;

[0105] Since the soil type and land use type of samples S06 and S05 are the same, k = k + 1;

[0106] Since the land use type of samples S03 and S05 is the same, k = k + 1;

[0107] Since the land use type of samples S02 and S05 is the same, k = k + 1;

[0108] Since the geological background, soil type, and land use type of samples S04 and S05 are different, k = k-1;

[0109] At this time, k=5, and the k nearest neighbors of sample S05 are determined: samples S07, S01, S06, S03, and S02.

[0110] For example, determine the k nearest neighbors of sample S04:

[0111] Initialize k=1;

[0112] Calculate the two-dimensional Euclidean distance to all other known samples, as shown in Table 3:

[0113] Table 3, 2D Euclidean distance from sample S04 to all other known samples

[0114]

[0115] The order of increasing two-dimensional Euclidean distance is: S02, S03, S05, S07, S01, S06;

[0116] Since the geological background, soil type, and land use type of samples S02 and S04 are different, k = k-1;

[0117] At this time, k = 0, and the k value is set to the average k value of other known samples, that is, In this embodiment, round down, that is, set k=3;

[0118] Then, determine the k nearest neighbors of sample S04: samples S02, S03, and S05.

[0119] Similarly, determine the k nearest neighbors of known samples, as shown in Table 4:

[0120] Table 4. Determining the k nearest neighbors of a known sample

[0121]

[0122] 1.3 Statistics n i , i=1,2,...,4

[0123] For example, for sample S05:

[0124] Among the k nearest neighbors of sample S05, the sample S07 has the smallest difference in N element content from sample S05;

[0125] Since the geological backgrounds of samples S07 and S05 are different, but their soil types and land use types are the same, among the k nearest neighbors of sample S05, the sample with the smallest altitude difference from sample S05 is sample S02, not sample S07; thus,

[0126] n1=n1+0,

[0127] n2=n2+1,

[0128] n3=n3+1,

[0129] n4=n4+0

[0130] Similarly, statistics n i , i = 1, 2, ..., 4, as shown in Table 5:

[0131] Table 5, n i , i=1,2,...,4Statistical results

[0132]

[0133] 1.4 Calculate the weights w of the four influencing factors: geological background, soil type, land use type, and altitude i , i = 1, 2, ..., 4, as shown in Table 6:

[0134] Table 6, weight w i , i=1,2,...,4Calculation results

[0135]

[0136] Step 2: Determine the k nearest neighbors of the unknown sample

[0137] For example, determine the k nearest neighbors of sample S09:

[0138] Initialize k=1;

[0139] Calculate the two-dimensional Euclidean distance from it to all other known samples, as shown in Table 7:

[0140] Table 7, 2D Euclidean distance from sample S09 to known samples

[0141]

[0142] The order of increasing two-dimensional Euclidean distance is: S05, S07, S01, S06, S03, S02, S04;

[0143] Since the land use type of samples S05 and S09 is the same, k = k + 1;

[0144] Since the land use type of samples S07 and S09 is the same, k = k + 1;

[0145] Since the geological background and land use type of samples S01 and S09 are the same, k = k + 1;

[0146] Since the land use type of samples S06 and S09 is the same, k = k + 1;

[0147] Since the geological background, soil type, and land use type of samples S03 and S09 are the same, k = k + 1;

[0148] Since the geological background, soil type, and land use type of samples S02 and S09 are the same, k = k + 1;

[0149] Since the geological background, soil type, and land use type of samples S04 and S09 are different, k = k-1;

[0150] At this time, k=6, and the k nearest neighbors of sample S09 are determined: samples S05, S07, S01, S06, S03, and S02.

[0151] For example, determine the k nearest neighbors of sample S10:

[0152] Initialize k=1;

[0153] Calculate the two-dimensional Euclidean distance to all other known samples, as shown in Table 8:

[0154] Table 8, 2D Euclidean distance from sample S10 to known samples

[0155]

[0156] The order of increasing two-dimensional Euclidean distance is: S01, S06, S07, S05, S03, S02, S04;

[0157] Since the geological background, soil type, and land use type of samples S01 and S10 are different, k = k-1;

[0158] At this time, k=0, and the k value is set to the average k value of other known samples, that is, k=6;

[0159] Then, determine the k nearest neighbors of sample S10: samples S01, S06, S07, S05, S03, and S02.

[0160] Similarly, determine the k nearest neighbors of the unknown sample, as shown in Table 9:

[0161] Table 9, Determining the k nearest neighbors of unknown samples

[0162]

[0163] Step 3: Calculate the similarity between the k nearest neighbor known samples and the unknown samples

[0164] For example, calculate the similarity between samples S05 and S09:

[0165] Calculate the geological background distance, soil type distance, and land use type distance of samples S05 to S09:

[0166] Since the geological background distance and soil type distance of samples S05 and S09 are different, but the land use type is the same,

[0167] d1=1,

[0168] d2=1,

[0169] d3=0;

[0170] Calculate the altitude distance from the k nearest neighbor known samples of sample S09 to S09:

[0171] First, the absolute value of the difference between the altitude of sample S09 and its k nearest known samples is calculated, as shown in Table 10:

[0172] Table 10. Absolute value of the difference between the altitude of sample S09 and its k nearest known samples

[0173]

[0174] Since the maximum absolute value of the altitude difference in Table 10 is 907.9 and the minimum absolute value is 7.8, the two are not equal;

[0175] Therefore, the absolute values ​​of the altitude differences in Table 10 are normalized to the maximum and minimum values, and the altitude distance d4 from the k nearest neighbor known samples of sample S09 to S09 is obtained, as shown in Table 11:

[0176] Table 11. Altitude distances from k nearest neighbors of sample S09 to S09

[0177] Sample No. S05 S07 S01 S06 S03 S02 Altitude distance 0.0076 0.4262 1.0000 0.5800 0.0008 0

[0178] Then the similarity distance D between samples S05 and S09 is:

[0179]

[0180] Among them, w i ∈[0, 1], i=1, 2, ..., 4 are the weights of the four influencing factors of geological background, soil type, land use type and altitude calculated in step 1. Different weights effectively distinguish the control strength of the four factors on the change of N content; d i ∈[0,1], i=1,2,...,4 are the geological background distance, soil type distance, land use type distance, and altitude distance from sample S05 to sample S09 respectively;

[0181] Calculate the similarity v between samples S05 and S09:

[0182]

[0183] Among them, D is the similarity distance between samples S05 and S09, D i is the similarity distance between the i-th neighbor sample of sample S09 and S09.

[0184] Similarly, the similarity of the k nearest neighbor known samples of the unknown sample is calculated, as shown in Table 12:

[0185] Table 12. Similarity between k nearest neighbor known samples and unknown samples

[0186]

[0187] Step 4: Assign values ​​to unknown samples

[0188] For example, assign a value to sample S09

[0189]

[0190] Among them, v i is the similarity of the i-th nearest neighbor known sample of sample S09. Different similarities effectively distinguish the influence of the k nearest neighbor known samples of sample S09 on its assignment; r iis the N element content of the i-th nearest known sample of sample S09.

[0191] Similarly, assign values ​​to unknown samples, as shown in Table 13:

[0192] Table 13, the results of assigning values ​​to the unknown sample N elements

[0193] Sample No. S08 S09 S10 N(μg / g) 2.0457e+03 1.5905e+03 1.6610e+03

[0194] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A geochemical element content assignment method based on adaptive k-nearest neighbors, characterized in that: The following steps are involved: Step 1: Use the adaptive calculation method of factor weights to calculate the weights of the four influencing factors of geological background, soil type, land use type, and altitude; the adaptive calculation method of factor weights is referred to as the adaptive weight algorithm of factors; specifically, the following steps are included: Step 11: Randomly select 100 known samples, denoted as x i , i = 1, 2, ..., 100; if the number of known samples is less than 100, select all known samples; let n j =0, j=1,2,…,4, which respectively represent the number of samples whose chemical element contents are mainly controlled by geological background, the number of samples whose chemical element contents are mainly controlled by soil type, the number of samples whose chemical element contents are mainly controlled by land use type, and the number of samples whose chemical element contents are mainly controlled by altitude; Step 12: For the selected sample x i , among other known samples, use the adaptive k-nearest neighbor algorithm to calculate x i k nearest neighbors; for all selected samples with k value equal to 0, set the k value equal to the average k value of other selected samples; Step 13: Record the k nearest neighbor samples with x i The sample with the smallest difference in chemical element content is a i ,i=1,2,…,k;k nearest neighbor samples are similar to x i There are at least 1 and at most k samples with the smallest difference in chemical element content; Step 14: Statistics a i , i=1,2,…,k, and x i The number of samples with the same geological background is denoted as m1 and x i The number of samples with the same soil type is recorded as m2, which is the same as x i The number of samples with the same land use type is denoted as m3, which is the same as x i The altitude difference is exactly the number of samples with the smallest difference among the k nearest neighbor samples, denoted as m4, then n j =n j +m j , j = 1, 2, ..., 4; Step 15: Calculate the weights w of the four influencing factors: geological background, soil type, land use type, and altitude j , j=1,2,…,4: Step 2: For unknown samples, use the adaptive k-nearest neighbor algorithm to calculate its k-nearest neighbors among all known samples; for all unknown samples with k value equal to 0, set the k value equal to the average of the k values ​​of other unknown samples; In step 2 and step 12, in the sample set, the k nearest neighbors of the sample x0 are calculated using the adaptive k nearest neighbor algorithm; the algorithm autonomously learns in the sample set to obtain the k nearest neighbor samples that are most similar to the geological attributes of x0 and have the closest two-dimensional space distance; wherein, calculating the k nearest neighbors of the sample x0 using the adaptive k nearest neighbor algorithm includes the following steps: Step 21: Initialize k=1; Step 22: Let the kth nearest neighbor sample of x0 in the two-dimensional Euclidean distance in the sample set be b, and determine whether b is different from x0 in terms of geological background, soil type, and land use type. If they are all different, execute step 24, otherwise execute step 23; Step 23: k=k+1, execute step 22; Step 24: k=k-1, determine k nearest neighbors; Step 3: Calculate the similarity between the k-nearest neighbor known sample and the unknown sample using the adaptive calculation method of the similarity between the k-nearest neighbor known sample and the unknown sample; wherein the adaptive calculation method of the similarity between the k-nearest neighbor known sample and the unknown sample is referred to as the adaptive similarity algorithm of the k-nearest neighbor sample; comprising the following steps: Step 31: Calculate the similarity distance D between the k nearest neighbor known sample and the unknown sample: Among them, w j ∈[0, 1], j = 1, 2, ..., 4 are the weights of the four influencing factors of geological background, soil type, land use type, and altitude calculated in step 1. Different weights effectively distinguish the control strength of the four factors on the change of chemical element content; d j ∈[0,1], j=1,2,...,4 are the geological background distance, soil type distance, land use type distance, and altitude distance from the known sample to the unknown sample respectively; If the geological background of the known sample and the unknown sample is the same, the geological background distance from the known sample to the unknown sample is 0, otherwise it is 1; if the soil type of the known sample and the unknown sample is the same, the soil type distance from the known sample to the unknown sample is 0, otherwise it is 1; if the land use type of the known sample and the unknown sample is the same, the land use type distance from the known sample to the unknown sample is 0, otherwise it is 1; the calculation process of the altitude distance d4 from the k nearest neighbor known sample to the unknown sample is as follows: Step 311: Calculate the absolute value d′4 of the difference between the altitudes of the k nearest neighbor known samples and the unknown samples: d′4=|h1-h2|, Among them, h1 is the altitude of the k nearest neighbor known samples, and h2 is the altitude of the unknown samples; Step 312: Determine whether the minimum value of d′4 in step 311 is equal to the maximum value of d′4. If yes, execute step 313; otherwise, execute step 314. Step 313: Calculate the altitude distance d4 from the k nearest neighbor known sample to the unknown sample: d4=[0,0,...,0], Among them, the number of elements of d4 is k; Step 314: Normalize d′4 to its maximum and minimum values ​​to obtain the altitude distance d4 from the k nearest neighbor known sample to the unknown sample: Among them, min(d′4) is the minimum value of d′4, and max(d′4) is the maximum value of d′4; Step 32: Calculate the similarity v between the k nearest neighbor known samples and the unknown samples i : Among them, D i is the similarity distance of the i-th nearest neighbor known sample; Step 4: Assign values ​​to unknown samples based on the k nearest neighbor known samples and their similarity to the unknown samples.

2. The geochemical element content assignment method based on adaptive k-nearest neighbor according to claim 1 is characterized in that: In step 4, assign R to the unknown sample: Among them, v i is the similarity between the known sample of the i-th nearest neighbor and the unknown sample. Different similarities can effectively distinguish the influence of the k-nearest neighbor known samples on the unknown sample assignment; r i is the chemical element content of the i-th nearest known sample.