Feature selection method, device, equipment and medium
By optimizing feature subsets one after another in a cyclic manner, and using the evaluation function value to determine the quality of features, the problem of low accuracy of existing feature selection algorithms is solved, and more efficient feature selection and model prediction accuracy are achieved.
Patent Information
- Application Number
- CN201910962985.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-10-11
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2039-10-11
AI Technical Summary
Existing feature selection algorithms have low accuracy and are difficult to effectively select the optimal feature subset, resulting in low prediction accuracy and low computational efficiency of the model.
Obtain the optimal feature subset of the original feature set through a loop, add or remove features one after another, and use the evaluation function value to judge the quality of the features to ensure that the selected feature subset does not contain redundant or irrelevant features, thereby improving the accuracy of feature selection. Spend.
It improves the accuracy of feature selection and the prediction accuracy of the model, reduces the possibility of dimensionality disaster, and increases the efficiency of modeling and calculation.
Smart Images

Figure CN112651416B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a feature selection method, device, equipment and medium. Background Art
[0002] Feature selection, which is usually applied to data dimensionality reduction in the modeling process, refers to selecting a subset of features from the original feature set that optimizes a certain evaluation criterion. Its purpose is to make the classification or regression model constructed by the selected optimal feature subset achieve a prediction accuracy similar to or even better than that before feature selection. This not only improves the generalization ability of the model, the comprehensibility of the model, and the computational efficiency, but also reduces the possibility of the "dimensionality disaster". In actual modeling work, it reduces the cost of modeling manpower, time, and resources, and increases the efficiency brought by modeling.
[0003] Currently, commonly used feature selection algorithms include complete search and random search, and the feature selection accuracy is low. Summary of the invention
[0004] The embodiments of the present invention provide a feature selection method, apparatus, device and medium, which can improve the accuracy of feature selection.
[0005] In a first aspect, an embodiment of the present invention provides a feature selection method, including: obtaining a current feature subset to be optimized of an original feature set; adding the first feature in the candidate feature subset of the original feature set to the current feature subset to be optimized to obtain a first feature subset, the first feature subset being better than a set obtained by adding any other feature other than the first feature in the candidate feature subset to the current feature subset to be optimized; removing the second feature from the first feature subset to obtain a second feature subset, the second feature subset being better than a set obtained by removing any other feature other than the first feature and the second feature from the first feature subset; if the second feature subset is not better than the current feature subset to be optimized, using the first feature subset as the next feature subset to be optimized, until the first feature subset meets a preset stopping criterion, and selecting the first feature subset as the optimal feature subset of the original feature set.
[0006] In the feature selection method provided in the embodiment of the present invention, the optimal feature subset of the original feature set is obtained in a cyclic manner. In the process of updating the second feature subset, since the first feature subset is better than the set obtained by adding any other feature other than the first feature in the candidate feature subset to the current feature subset to be optimized, the second feature subset is better than the set obtained by removing any other feature other than the first feature and the second feature from the first feature subset. Therefore, in the cyclic process, the first feature with the highest fit to the current feature subset to be optimized is continuously added, and it is determined whether the second feature, which is most likely to be an irrelevant feature or a redundant feature, needs to be eliminated. Therefore, as the cyclic process proceeds, the feature subset to be optimized is continuously optimized, and the accuracy of feature selection can be improved.
[0007] In an optional embodiment, the method also includes: if the second feature subset is better than the current feature subset to be optimized, the second feature subset is used as the new first feature subset, and the new second feature is eliminated from the new first feature subset to obtain a new second feature subset, until the new second feature subset is not better than the corresponding feature subset to be optimized or the number of features in the new second feature subset is less than a quantity threshold, and the new first feature subset is used as the next feature subset to be optimized.
[0008] If the second feature subset is better than the current feature subset to be optimized, the second feature subset can be used to calculate the optimal feature subset. Suspected irrelevant features or suspected redundant features can be removed from the second feature subset until the second feature cannot be further reduced in dimension. Therefore, while ensuring that the evaluation function value of the optimal feature is high, the feature dimension can be reduced as much as possible, thereby improving the selection accuracy.
[0009] In an optional embodiment, the first feature in the candidate feature subset of the original feature set is added to the current feature subset to be optimized to obtain the first feature subset, including: randomly selecting one feature in the candidate feature subset to add to the feature subset to be optimized to obtain a pending first feature subset; determining the pending first feature subset with the highest evaluation function value as the first feature subset, and determining the feature added to the first feature subset as the first feature.
[0010] Since the evaluation function value can be used as a criterion for evaluating the quality of feature sets, by constructing a pending first feature subset and taking the optimal pending first feature subset as the first feature subset, the degree of fit between each element in the candidate feature subset and the current feature subset to be optimized can be fully considered, and the features with the highest fit can be accurately selected from the candidate feature subsets and added to the current feature subset, thereby improving the accuracy of feature extraction.
[0011] In an optional embodiment, the second feature is eliminated from the first feature subset to obtain the second feature subset, including: randomly selecting any feature other than the first feature in the first feature subset and eliminating it to obtain a pending second feature subset; determining the pending second feature subset with the highest evaluation function value as the second feature subset, and determining the feature eliminated from the second feature subset as the second feature.
[0012] Since the evaluation function value can be used as a criterion for evaluating the quality of a feature set, by constructing a pending second feature subset and using the optimal pending second feature subset as the second feature subset, the second features that are most likely to be redundant features or irrelevant features can be eliminated from the first feature subset, thereby ensuring to the greatest extent that the optimal feature subset does not contain redundant features or irrelevant features, thereby improving the accuracy of feature extraction.
[0013] In an optional implementation, the method further includes: removing related features of the second feature from the candidate feature subset.
[0014] If the second feature subset is used as the next feature subset to be optimized, the second feature represents an irrelevant feature or a redundant feature. Since if a feature is related to an irrelevant feature or a redundant feature, the feature is also an irrelevant feature or a redundant feature. Therefore, the second feature can be removed from the candidate feature subset to improve the efficiency of feature selection and reduce the amount of calculation.
[0015] In an optional embodiment, the method further includes:
[0016] Among the candidate features in the candidate feature subset, features whose correlation with the second feature is greater than a second threshold are screened out as new candidate features; the first threshold is increased according to a preset growth step, and the new candidate features are screened using the increased first threshold until the number of screened candidate features is zero, and the new candidate related features are used as related features of the second feature.
[0017] By gradually increasing the first threshold, the number of candidate features is gradually reduced, and through multiple cycles, features related to the second feature are accurately found from the candidate feature subset.
[0018] In a second aspect, an embodiment of the present invention provides a device, comprising: an acquisition module, used to acquire a current feature subset to be optimized of an original feature set; a first construction module, used to add the first feature in the candidate feature subset of the original feature set to the current feature subset to be optimized, to obtain a first feature subset, the first feature subset being better than a set obtained by adding any other feature other than the first feature in the candidate feature subset to the current feature subset to be optimized; a second construction module, used to remove the second feature from the first feature subset, to obtain a second feature subset, the second feature subset being better than a set obtained by removing any other feature other than the first feature and the second feature from the first feature subset; a selection module, used to use the first feature subset as the next feature subset to be optimized if the second feature subset is not better than the current feature subset to be optimized, until the first feature subset meets a preset stopping criterion, and the first feature subset is selected as the optimal feature subset of the original feature set.
[0019] In an optional embodiment, the device further comprises:
[0020] The third construction module is used to use the second feature subset as a new first feature subset if it is better than the current feature subset to be optimized, and remove the new second feature from the new first feature subset to obtain a new second feature subset, until the new second feature subset is not better than the corresponding feature subset to be optimized or the number of features in the new second feature subset is less than the number threshold, and the new first feature subset is used as the next feature subset to be optimized.
[0021] In a third aspect, an embodiment of the present invention provides a feature selection device, the device comprising: a memory for storing programs; a processor for running the programs stored in the memory to execute the feature selection method provided in the first aspect or any optional implementation manner of the first aspect.
[0022] In a fourth aspect, an embodiment of the present invention provides a computer storage medium having computer program instructions stored thereon, and when the computer program instructions are executed by a processor, the feature selection method provided by the first aspect or any optional implementation manner of the first aspect is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the following briefly introduces the drawings required for use in the embodiment of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0024] Figure 1 is a schematic flow chart showing a feature selection method according to an embodiment of the present invention;
[0025] Figure 2 is a more detailed flow chart showing a feature selection method according to some exemplary embodiments of the present invention;
[0026] Figure 3 A schematic diagram showing the classification accuracy corresponding to various algorithms is shown;
[0027] Figure 4 A schematic diagram of the structure of a feature selection device provided according to an embodiment of the present invention is shown;
[0028] Figure 5 It is a structural diagram of an exemplary hardware architecture of a feature selection device in an embodiment of the present invention. DETAILED DESCRIPTION
[0029] The features and exemplary embodiments of various aspects of the present invention will be described in detail below. In order to make the purpose, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings and Examples. It should be understood that the specific embodiments described herein are only configured to explain the present invention and are not configured to limit the present invention. For those skilled in the art, the present invention can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present invention by illustrating examples of the present invention.
[0030] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0031] The embodiments of the present invention provide a feature extraction method, device, equipment and medium, which can be applied to the specific scenario of feature extraction in the process of data modeling. Since there are redundant features or irrelevant features in the original feature set that degrade the performance and prediction accuracy of the classifier or classification algorithm, it is necessary to filter out redundant features and irrelevant features from the original feature set before constructing the classifier and classification algorithm to obtain the optimal feature subset with the best evaluation performance.
[0032] The feature selection method provided by the embodiment of the present invention updates the current feature subset to be optimized, the first feature subset and the second feature subset in a loop. In the loop process, if the second feature subset meets the stopping criterion, the second stopping criterion is selected as the optimal feature subset of the original feature set. If the second feature subset does not meet the stopping criterion, the second feature subset is used as the current feature subset to be optimized in the next loop process.
[0033] In order to better understand the present invention, the feature selection method, device, equipment and medium according to the embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that these embodiments are not intended to limit the scope of the present invention.
[0034] Figure 1 FIG. 1 is a schematic flow chart showing a feature selection method according to an embodiment of the present invention. Figure 1 As shown, the feature selection method 100 in this embodiment may include S110 to S140. The feature selection algorithm 100 may be a cyclic process, and S110 to S140 are cyclically executed before the optimal feature subset is selected.
[0035] S110, obtaining the current feature subset to be optimized of the original feature set. If this is the kth cycle, the current feature subset to be optimized is the kth feature subset to be optimized X kRegardless of the number of cycles, the feature subset to be optimized is a subset of the original feature set, that is, all features of the feature subset to be optimized also belong to the original feature set. In the first cycle, the current feature subset to be optimized can be an empty set. For example, if the original feature set Y = [x1, x2, x3, x4, x5, x6, x7], the current feature subset to be optimized X k =[x1,x2,x3].
[0036] S120, adding the first feature in the candidate feature subset of the original feature set to the current feature subset to be optimized to obtain a first feature subset, and the first feature subset is superior to a set obtained by adding any other feature in the candidate feature subset to the current feature subset to be optimized.
[0037] The candidate feature subset includes the features that need to be screened. The candidate feature subset may include the following two implementations:
[0038] In the first implementation, the candidate feature subset contains features in the original feature set that do not belong to the current feature subset to be optimized. For example, if the original feature set Y = [x1, x2, x3, x4, x5, x6, x7], the current feature subset to be optimized X k =[x1,x2,x3], then the candidate feature subset W = [x4,x5,x6,x7].
[0039] In a second implementation, the candidate feature subset does not contain the features of the current feature subset to be optimized, and does not contain the related features of the eliminated features that are missing when the next feature subset to be optimized is compared with the current feature subset to be optimized. k =[x1,x2,x3], the next feature subset to be optimized X k =[x1,x3]. If x5 and x6 are relevant features of x2, the candidate feature subset W used in the next cycle = [x4,x7].
[0040] In S120, the first feature represents the feature in the candidate feature subset that has the highest degree of fit with the current feature subset to be optimized. Among them, the way to prove that the first feature has the highest degree of fit with the current feature subset to be optimized can be: the first feature subset is better than the first set obtained by adding any other feature in the candidate feature subset except the first feature to the current feature subset to be optimized. Optionally, the advantages and disadvantages between the first feature subset and the first set can be judged by comparing their respective evaluation functions. The evaluation function can be determined by J(X), and the higher the evaluation function, the better the set. For example, the evaluation function can be a filter or a wrapper. In other words, the evaluation function value of the first feature subset is higher than the evaluation function value of the first set.
[0041] Specifically, the specific implementation of S120 is as follows:
[0042] S121, select one feature from the candidate feature subsets and add it to the feature subset to be optimized, so as to obtain at least one first feature subset to be determined. k =[x1,x2,x3], then the candidate feature subset W = [x4,x5,x6,x7]. Then the four features of the candidate feature subset can be added to the feature subset to be optimized to construct four first feature subsets to be determined. Among them, the first feature subsets to be determined are A1 = [x1,x2,x3,x4], A2 = [x1,x2,x3,x5], A3 = [x1,x2,x3,x6], and A4 = [x1,x2,x3,x7].
[0043] S122, determine the undetermined first feature subset with the highest evaluation function value as the first feature subset, and determine the feature added to the first feature subset as the first feature. Exemplarily, if the evaluation function value of A2=[x1,x2,x3,x5] is the highest, then A2=[x1,x2,x3,x5] is the first feature subset, and x5 is the first feature.
[0044] Through S121 and S122, since the evaluation function value can be used as a criterion for evaluating the quality of the feature set, by constructing a pending first feature subset and taking the optimal first feature subset as the first feature subset, the degree of fit between each element in the candidate feature subset and the current feature subset to be optimized can be fully considered, and the features with the highest fit can be accurately selected from the candidate feature subsets and added to the current feature subset, thereby improving the accuracy of feature extraction.
[0045] In addition, after the first feature is added to the current feature subset to be optimized, the first feature can also be removed from the candidate feature subset to avoid repeated operations.
[0046] S130, removing the second feature from the first feature subset to obtain at least one second feature subset, wherein the set obtained by removing the second feature from the first feature subset is better than the set obtained by removing any other feature from the current feature subset to be optimized.
[0047] In S130, the second feature is the feature in the first feature subset that is most likely to be an irrelevant feature or a redundant feature. Considering that if a feature needs to be removed from the first feature subset, the evaluation function value may drop significantly after removing the feature with the highest fit, and the evaluation function value decreases less after removing the irrelevant feature or the redundant feature. Therefore, the feature that is most likely to be an irrelevant feature or a redundant feature can also be found from the first feature subset by calculating the evaluation function value. Specifically, the specific implementation of S130 may include:
[0048] S131, select any one feature other than the first feature in the first feature subset and remove it to obtain a pending second feature subset. For example, if the first feature subset A2 = [x1, x2, x3, x5], and the first feature is x5, then the remaining three features except x5 can be removed respectively, and the corresponding pending second feature subsets are B1 = [x2, x3, x5], B2 = [x1, x3, x5], and B3 = [x1, x2, x5].
[0049] S132, determine the undetermined second feature subset with the highest evaluation function value as the second feature subset, and determine the features eliminated from the second feature subset as the second features. Exemplarily, if J(B2) is greater than J(B1) and J(B3), then x2 is the second feature, and B2=[x1,x3,x5] is the second feature subset.
[0050] Through S131 and S132, since the evaluation function value can be used as a criterion for evaluating the quality of the feature set, by constructing a pending second feature subset and using the optimal pending second feature subset as the second feature subset, the second feature that is most likely to be a redundant feature or an irrelevant feature can be eliminated from the first feature subset, thereby ensuring to the greatest extent that the optimal feature subset does not contain redundant features or irrelevant features, thereby improving the accuracy of feature extraction.
[0051] S140, if the second feature subset is not better than the current feature subset to be optimized, the first feature subset is used as the next feature subset to be optimized, until the first feature subset meets the preset stop criteria, and the first feature subset is selected as the optimal feature subset of the original feature set. Among them, the next feature subset to be optimized can be used as the current feature subset to be optimized in the next cycle. If the evaluation function value of the second feature subset is lower than the possibility of the evaluation function value of the current feature subset to be optimized, using the second feature subset as the next feature subset to be optimized may cause the accuracy of feature selection to continue to decrease. Therefore, if the second feature subset is not better than the current feature subset to be optimized, it is proved that it is not suitable to eliminate the second feature. In order to ensure accurate precision, the first feature set can be substituted into the next cycle.
[0052] Therefore, in the process of executing S140, first, it is necessary to determine whether the first feature subset is better than the current feature subset to be optimized. Specifically, an evaluation function can be used to determine the quality of the feature set.
[0053] Secondly, after determining that the feature subset is not better than the current feature subset to be optimized, it is necessary to determine whether the first feature subset meets the preset stopping criteria. If the stopping criteria are met, the algorithm stops and the first feature subset is selected as the optimal feature subset. If the stopping criteria are not met, it is necessary to enter the next cycle and use the first feature subset as the current feature subset to be optimized in the next cycle.
[0054] The stop criterion represents the standard of feature selection and can be determined according to the needs of feature selection or actual conditions. For example, it can be one or more of the following stop criteria:
[0055] Determine the stopping criterion A: the evaluation function of the first feature subset is higher than a preset evaluation function threshold. The evaluation function threshold can be set according to actual needs and working scenarios, and is not limited thereto.
[0056] Stop criterion B: the feature dimension of the first feature subset is higher than or equal to a preset feature dimension threshold, wherein the feature dimension threshold may be an expected value set according to actual needs and working scenarios, and is not limited thereto.
[0057] In the feature selection method provided in the embodiment of the present invention, the optimal feature subset of the original feature set is obtained in a cyclic manner. In the process of updating the second feature subset, since the first feature subset is better than the set obtained by adding any other feature other than the first feature in the candidate feature subset to the current feature subset to be optimized, the second feature subset is better than the set obtained by removing any other feature other than the first feature and the second feature from the first feature subset. Therefore, in the cyclic process, the first feature with the highest fit to the current feature subset to be optimized is continuously added, and it is determined whether the second feature, which is most likely to be an irrelevant feature or a redundant feature, needs to be eliminated. Therefore, as the cyclic process proceeds, the feature subset to be optimized is continuously optimized, and the accuracy of feature selection can be improved.
[0058] In some embodiments, if the second feature subset is still better than the current feature subset to be optimized, the second feature subset can be used to calculate the optimal feature subset. At this time, after S130, the feature selection method 100 further includes:
[0059] S150, if the second feature subset is better than the current feature subset to be optimized, the second feature subset is used as the new first feature subset, and the new second feature is removed from the new first feature subset to obtain a new second feature subset, until the new second feature subset is not better than the corresponding feature subset to be optimized or is less than the quantity threshold, and the new first feature subset is used as the next feature subset to be optimized.
[0060] First, if the second feature subset is better than the feature subset to be optimized, the second feature subset needs to be used as a new first feature subset, and the new second feature is removed from the new first feature subset to obtain a new second feature subset. The method of obtaining the new second feature is the same as the relevant description of S120, which will not be repeated here.
[0061] Specifically, you can first select any one feature other than the first feature from the new first feature subset (the second feature subset before updating) and remove it to obtain a new second feature subset to be determined. And select the new second feature subset to be determined with the highest evaluation function value as the new second feature subset. Exemplarily, if the new first feature subset B2 = [x1, x3, x5], x5 is the first feature, then the new second feature subset to be determined includes C1 = [x3, x5], C2 = [x1, x5]. If J (C2) is greater than J (C1), the new second feature subset is C2 = [x1, x5].
[0062] For other specific details, please refer to the relevant description of the second feature above, which will not be repeated here.
[0063] Secondly, it is necessary to determine whether the new second feature subset is better than the feature subset to be optimized corresponding to the new second feature subset, and whether the number of features of the new second feature subset is less than a preset number threshold.
[0064] Since S150 is a small loop, if during the kth large loop (loop S110 to S140), the new second feature subset obtained during the i-th loop S150 corresponds to the feature subset to be optimized during the ki-th loop.
[0065] If the new second feature subset is not better than the corresponding feature subset to be optimized, it proves that the new second feature subset obtained after removing the new second feature does not achieve the optimization effect. Therefore, it is not suitable to continue to obtain the optimal feature subset by reducing features. The new first feature subset can be used as the next feature subset to be optimized.
[0066] If the number of features in the new second feature subset is less than the quantity threshold, since the quantity threshold represents the minimum requirement for the number of features, it is not appropriate to continue to reduce the features to obtain the optimal feature subset, and the new first feature subset can be used as the next feature subset to be optimized. The quantity threshold can be pre-set according to specific application scenarios and application requirements. For example, the value of the quantity threshold can be 2.
[0067] If the new second feature subset is better than the corresponding feature subset to be optimized and the number of features in the second feature subset is greater than or equal to the number threshold, it is proved that the third feature subset may also be obtained by reducing features to obtain the optimal feature subset. Then S150 can be continuously executed in a loop.
[0068] In some embodiments, if the candidate feature subset does not contain features of the current feature subset to be optimized, and does not contain related features of the eliminated features that are missing in the next feature subset to be optimized compared to the current feature subset to be optimized. Specifically, if the second feature subset is used as the next current feature subset to be optimized, the related features of the second feature are eliminated from the candidate feature subset. In addition, if the first feature subset is used as the next feature subset to be optimized, there is no need to screen out the related features of the second feature from the candidate feature subset.
[0069] If the second feature subset is used as the next feature subset to be optimized, the second feature represents an irrelevant feature or a redundant feature. Since if a feature is related to an irrelevant feature or a redundant feature, the feature is also an irrelevant feature or a redundant feature. Therefore, in order to improve the efficiency of feature selection and reduce the amount of calculation, the second feature can be removed from the candidate feature subset.
[0070] Specifically, the specific method of determining the related features of the second feature may be as shown in the following step 1 and step 2. It should be noted that determining the related features of the second feature may be a process of cyclically executing step 1 and step 2.
[0071] Step 1. Among the candidate features in the candidate feature subset, select the features whose correlation with the second feature is greater than the first threshold as new candidate features. The correlation between each candidate feature and the second feature can be determined by calculating the correlation coefficient between each candidate feature and the second feature. The first threshold is used to measure whether the features are related. If the correlation between two features is greater than the first threshold, the two features are related. If the correlation between the two features is not greater than the first threshold, the two features are not related. For example, if among the candidate features x1, x2, x3, and x4, the correlation between x1 and x4 and the second feature x5 is greater than the first threshold, then x1 and x4 are both related features of x5.
[0072] The initial values of the candidate features are all the features in the candidate feature subset.
[0073] Step 2: increase the first threshold according to a preset growth step Δ, and use the increased first threshold to screen new candidate features until the number of screened candidate features is zero, and use the new candidate related features as related features of the second feature.
[0074] For the first threshold, if steps 1 and 2 are executed in the jth cycle, the first threshold p before the increase in the jth cycle j =p1+(j-1)Δ. The growth step Δ and the initial value p1 of the first threshold can be set according to actual needs and specific scenarios, and the growth step Δ can be a fixed value or a variable, which is not limited.
[0075] For example, if the newly obtained candidate features in the jth cycle are x1 and x4, then the correlation between x1 and x4 and the second feature x5 is greater than p j If the correlation between x1, x4 and the second feature x5 is less than p j+1 , then x1 and x4 are related features of the second feature.
[0076] Through step one and step two, by gradually increasing the first threshold, the number of candidate features is gradually reduced, and through multiple cycles, features related to the second feature are accurately found from the candidate feature subset.
[0077] Based on the same inventive concept, Figure 2 is a more detailed flow chart showing a feature selection method according to some exemplary embodiments of the present invention. Figure 2 As shown, the feature selection method 200 includes:
[0078] S201, obtaining the current feature subset to be optimized. If this is the kth cycle, the current feature subset to be optimized is the kth feature subset to be optimized.
[0079] S202: Add the first feature in the candidate feature subset to the current feature subset to be optimized to obtain a first feature subset.
[0080] S203 , eliminating the second feature of the first feature subset to obtain a second feature subset.
[0081] S204, judging whether the second feature subset is better than the current feature subset to be optimized. If the judgment result is no, executing S205; if the judgment result is yes, executing S208.
[0082] S205: If the second feature subset is not better than the current feature subset to be optimized, determine whether the first feature subset meets the preset stop criterion. If the determination result is no, execute S206; if the determination result is yes, execute S207.
[0083] S206: If the first feature subset does not meet the preset stop criterion, the first feature subset is used as the next feature subset to be optimized, and the process returns to S201.
[0084] S207: If the first feature subset meets the preset stopping criterion, the first feature subset is used as the optimal feature subset of the original feature set, and the whole process ends.
[0085] S208. If the second feature subset is better than the current feature subset to be optimized, determine whether the number of features n(D) of the second feature subset D is greater than the number threshold d, or whether the second feature subset D is better than the corresponding feature subset to be optimized U, J(D)>J(U). If the judgment result is yes, execute S209, if the judgment result is no, execute S210.
[0086] S209: If the number of features in the second feature subset is greater than the number threshold and the second feature subset is better than the corresponding feature subset to be optimized, the second feature subset is used as a new first feature subset, and the process returns to S203.
[0087] S210: If the number of features in the second feature subset is less than or equal to the number threshold or the second feature subset is not better than the corresponding feature subset to be optimized, the first feature subset is used as the next feature subset to be optimized, and the process returns to S201.
[0088] The specific implementation of each step in the feature selection method 200 may refer to the relevant description in the feature selection method 100 .
[0089] In addition, in order to verify the effectiveness of the feature selection method 200 provided in the embodiment of the present invention. The embodiment of the present invention selects the classic binary classification data set musk in machine learning to verify the feature selection method 200. The data set describes molecules of different structures, each molecule is labeled as musk or non-musk, and the number of samples and the number of features are 476 and 166 respectively. During the test, the classification accuracy of the K-nearest neighbor algorithm is used as the evaluation function of the feature selection, and finally the classification accuracy of each algorithm is obtained.
[0090] Figure 3 The figure shows the classification accuracy of various algorithms. The four different dotted lines are the classification accuracy of the forward sequence selection algorithm (SFS), floating forward sequence selection algorithm (SFFS), adaptive forward sequence selection algorithm (ASFFS) and feature selection method 200 (RSFFS algorithm) in the traditional sequence algorithm after feature selection of the musk dataset. Figure 3 It can be seen that, overall, the classification accuracy of each algorithm increases with the increase of the number of feature subsets, and finally tends to be stable. However, when the number of feature subsets is the same, the classification accuracy of the feature subset obtained by the RSFFS algorithm of the present invention is significantly higher than that of the traditional sequence algorithms SFS, SFFS and ASFFS, especially when the number of feature subsets is between 10 and 16.
[0091] Based on the same inventive concept, an embodiment of the present invention provides a feature selection device. Figure 4 FIG. 2 shows a schematic diagram of the structure of a feature selection device provided according to an embodiment of the present invention. Figure 4 As shown, the feature selection device 400 includes:
[0092] An acquisition module 410 is used to acquire a feature subset to be optimized of the original feature set;
[0093] A first construction module 420 is used to add the first feature in the candidate feature subset of the original feature set to the current feature subset to be optimized, so as to obtain a first feature subset, wherein the first feature subset is superior to a set obtained by adding any other feature other than the first feature in the candidate feature subset to the current feature subset to be optimized;
[0094] A second construction module 430 is used to remove the second feature from the first feature subset to obtain a second feature subset, where the second feature subset is superior to a set obtained by removing any other feature except the first feature and the second feature from the first feature subset;
[0095] The selection module 440 is used to select the first feature subset as the next feature subset to be optimized if the second feature subset is not better than the current feature subset to be optimized, until the first feature subset meets the preset stopping criteria, and select the first feature subset as the optimal feature subset of the original feature set.
[0096] In some embodiments of the present invention, the feature selection device 400 further includes:
[0097] The third construction module is used to use the second feature subset as a new first feature subset if the second feature subset is better than the current feature subset to be optimized, and eliminate the new second feature from the new first feature subset to obtain a new second feature subset, until the new second feature subset is not better than the corresponding feature subset to be optimized or the number of features in the new second feature subset is less than a quantity threshold, and the new first feature subset is used as the next feature subset to be optimized.
[0098] In some embodiments of the present invention, the first construction module 420 includes:
[0099] A first processing unit is used to select one feature from the candidate feature subsets and add it to the feature subset to be optimized to obtain a first feature subset to be determined;
[0100] The second processing unit is used to determine the undetermined first feature subset with the highest evaluation function value as the first feature subset, and determine the feature added to the first feature subset as the first feature.
[0101] In some embodiments of the present invention, the second construction module 430 includes:
[0102] A first processing unit is used to select and remove any feature other than the first feature in the first feature subset to obtain a pending second feature subset;
[0103] The second processing unit is used to determine the undetermined second feature subset with the highest evaluation function value as the second feature subset, and determine the features eliminated from the second feature subset as the second features.
[0104] In some embodiments of the present invention, the feature selection device 400 further includes:
[0105] The feature elimination module is used to eliminate the related features of the second feature from the candidate feature subset.
[0106] In some embodiments of the present invention, the feature selection device 400 further includes:
[0107] A screening module, used for screening out, from the candidate features in the candidate feature subset, features whose correlation with the second feature is greater than a second threshold value as new candidate features;
[0108] The feature selection module is used to increase the first threshold according to a preset growth step, and use the increased first threshold to screen new candidate features until the number of screened candidate features is zero, and use the new candidate related features as related features of the second feature.
[0109] Other details of the feature selection device according to the embodiment of the present invention are combined with the above Figure 1 to Figure 2 The method described in the embodiment of the present invention is similar and will not be described in detail here.
[0110] Figure 5 It is a structural diagram of an exemplary hardware architecture of a feature selection device in an embodiment of the present invention.
[0111] like Figure 5 As shown, the feature selection device 500 includes an input device 501, an input interface 502, a central processing unit 503, a memory 504, an output interface 505, and an output device 506. The input interface 502, the central processing unit 503, the memory 504, and the output interface 505 are connected to each other through a bus 510, and the input device 501 and the output device 506 are connected to the bus 510 through the input interface 502 and the output interface 505, respectively, and then connected to other components of the feature selection device 500.
[0112] Specifically, the input device 501 receives input information from the outside and transmits the input information to the central processing unit 503 through the input interface 502; the central processing unit 503 processes the input information based on the computer executable instructions stored in the memory 504 to generate output information, temporarily or permanently stores the output information in the memory 504, and then transmits the output information to the output device 506 through the output interface 505; the output device 506 outputs the output information to the outside of the feature selection device 500 for user use.
[0113] That is to say, Figure 5 The feature selection device shown can also be implemented as comprising: a memory storing computer executable instructions; and a processor, which can implement the combination of Figures 1 to 4A method and apparatus for feature selection of a device are described.
[0114] In one embodiment, Figure 5 The feature selection device 500 shown can be implemented as a device, which may include: a memory for storing a program; a processor for running the program stored in the memory to perform a combination of Figures 1 to 3 A method of feature selection apparatus is described.
[0115] The embodiment of the present invention further provides a computer storage medium, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the feature selection method of the embodiment of the present invention is implemented. The computer program instructions can be specifically Python codes, and the computer program can be packaged as a tool in exe format.
[0116] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.
[0117] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments that are used to perform the required tasks. Programs or code segments can be stored in machine-readable media, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable media" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0118] The above is only a specific implementation of the present invention. Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
Claims
1. A feature selection method, characterized in that: The method comprises: Obtain the current feature subset to be optimized of the original feature set, where the original feature set is a feature set composed of features in the musk data set; Adding the first feature in the candidate feature subset of the original feature set to the current feature subset to be optimized to obtain a first feature subset, wherein the first feature subset is superior to a set obtained by adding any other feature in the candidate feature subset except the first feature to the current feature subset to be optimized; Eliminate the second feature from the first feature subset to obtain a second feature subset, wherein the second feature subset is superior to a set obtained by eliminating any other feature except the first feature and the second feature from the first feature subset; If the second feature subset is not better than the current feature subset to be optimized, the first feature subset is used as the next feature subset to be optimized, until the first feature subset meets the preset stop criterion, the first feature subset is selected as the optimal feature subset of the original feature set, and the optimal feature subset is used to perform binary classification on molecules; The step of adding the first feature in the candidate feature subset of the original feature set to the current feature subset to be optimized to obtain the first feature subset comprises: Selecting one feature from the candidate feature subsets and adding it to the feature subset to be optimized to obtain a first feature subset to be determined; Determine the undetermined first feature subset with the highest evaluation function value as the first feature subset, and determine the feature added to the first feature subset as the first feature; The step of removing the second feature from the first feature subset to obtain a second feature subset includes: Select any feature other than the first feature in the first feature subset and remove it to obtain a pending second feature subset; The undetermined second feature subset with the highest evaluation function value is determined as the second feature subset, and the features eliminated from the second feature subset are determined as the second features.
2. The method according to claim 1, characterized in that After removing the second feature from the first feature subset to obtain the second feature subset, the method further includes: If the second feature subset is better than the current feature subset to be optimized, the second feature subset is used as a new first feature subset, and the new second feature is removed from the new first feature subset to obtain a new second feature subset. Until the new second feature subset is not better than the corresponding feature subset to be optimized or the number of features in the new second feature subset is less than the number threshold, the new first feature subset is used as the next feature subset to be optimized.
3. The method according to claim 2, characterized in that The method further comprises: The related features of the second feature are eliminated from the candidate feature subset.
4. The method according to claim 3, characterized in that The method further comprises: Selecting, from the candidate features in the candidate feature subset, a feature whose correlation with the second feature is greater than a second threshold as a new candidate feature; The first threshold is increased according to a preset growth step, and the new candidate features are screened using the increased first threshold until the number of the screened candidate features is zero, and the new candidate related features are used as related features of the second feature.
5. A feature selection device, characterized in that: The device comprises: An acquisition module is used to acquire a feature subset to be optimized of an original feature set, where the original feature set is a feature set composed of features in the musk data set; A first construction module is used to add the first feature in the candidate feature subset of the original feature set to the current feature subset to be optimized, so as to obtain a first feature subset, wherein the first feature subset is superior to a set obtained by adding any other feature other than the first feature in the candidate feature subset to the current feature subset to be optimized; A second construction module is used to remove a second feature from the first feature subset to obtain a second feature subset, wherein the second feature subset is superior to a set obtained by removing any other feature except the first feature and the second feature from the first feature subset; A selection module, used for selecting the first feature subset as the next feature subset to be optimized if the second feature subset is not better than the current feature subset to be optimized, until the first feature subset meets a preset stop criterion, and selecting the first feature subset as the optimal feature subset of the original feature set, wherein the optimal feature subset is used to perform binary classification on molecules; The first construction module is specifically used to select one feature in the candidate feature subset and add it to the feature subset to be optimized to obtain a pending first feature subset; determine the pending first feature subset with the highest evaluation function value as the first feature subset, and determine the feature added to the first feature subset as the first feature; The second construction module is specifically used to select any one feature other than the first feature in the first feature subset and eliminate it to obtain a pending second feature subset; determine the pending second feature subset with the highest evaluation function value as the second feature subset, and determine the feature eliminated from the second feature subset as the second feature.
6. The device according to claim 5, characterized in that The device also includes: The third construction module is used to use the second feature subset as a new first feature subset if the second feature subset is better than the current feature subset to be optimized, and eliminate the new second features from the new first feature subset to obtain a new second feature subset, until the new second feature subset is not better than the corresponding feature subset to be optimized or the number of features in the new second feature subset is less than a quantity threshold, and the new first feature subset is used as the next feature subset to be optimized.
7. A feature selection device, characterized in that: The device comprises: Memory, used to store programs; A processor, configured to run the program stored in the memory to execute the feature selection method according to any one of claims 1 to 4.
8. A computer storage medium, characterized in that: The computer storage medium stores computer program instructions, and when the computer program instructions are executed by the processor, the feature selection method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Feature selection method and device
CN104573741A
Feature selection method and system
CN105184323A
Integrated feature selection method and system
CN105512686A
Feature selection algorithm based on Relief and mutual information
CN108875795A
Multivariate discrete feature selection method, device, apparatu and storage medium
CN109284766A
