# An Information Entropy Embedding Feature Selection Based on Genetic Algorithm

Authors: Yuzheng Wu
Journal: Security and Communication Networks
 (2022)

---

## Abstract

Feature selection is of vital importance to reduce information redundancy and deal with the invalidation of basic classification approaches for massive dataset and too many features. In order to improve the classification accuracy and decrease time complexity, an algorithm with intelligent optimization genetic algorithm and weight distribution based on information entropy is proposed, called EEGA. Information entropy of features is defined as the population labels in GA rather than the direct iteration of individual fitness. Experiments have been performed by using several standard databases with four fitness algorithms. Experimental results have proved that EEGA performs better based on the measure of accuracy. Furthermore, it can significantly reduce the required time when figuring out the better results.


---

## Body

## 1. Introduction

Owing to the pervasive use of Internet and rapid performance boost of information technology, people are exposed to an increasing amount of information in a day. Such huge amount of information is hard to handle, which may cause some trouble in information processing like the dimension disaster. Reducing the dimension of the samples can effectively solve the information redundancy but unreasonable dimensionality reduction will cause information loss that affects data analysis and accuracy of classification. Therefore, it is of vital importance to keep essential information with low-dimensionality, which is sort of technology called feature reduction [1].Feature reduction could be divided in two categories, feature extraction and feature selection. Raw features can be transformed by feature extraction into a set of features with statistical significance or kernel, and feature selection means choosing the best feature subset from all feature sets. In recent years, researches of feature selection can be summarized into three algorithms, filter, wrapper, and embedder. Todorov [2] uses valid distance metric into Relief [3], a classic filtering feature selection algorithm. Peng et al. [4] propose a wrapped algorithm named FACO, which combines the ant colony optimization algorithm and feature selection. Rao et al. [5] apply artificial bee colony algorithm into decision tree (embedded one), achieving global optimization. Wang et al. [6] improve the AdaBoost approach based on a weighted feature selection in traditional filters, which obtains significant boost on classification accuracy. All above algorithms improve the traditional feature selection methods to increase the accuracy of classification; however, they did not take dynamic changes in weight distribution into consideration. What is more, a large number of redundant calculations increase the time complexity. Based on these issues, a weight distribution algorithm combining Information Entropy Theory and genetic algorithm is proposed for feature reduction.Information entropy is defined as the average amount of information excluding redundancy, which is the quantified form of information. In 1948, Shannon proposed Information Entropy Theory inspired by thermodynamic entropy and mentioned that there is redundancy in any information and the size of the redundancy is related to the probability or uncertainty of the occurrence of each symbol in the information. So the weight among indicators could be measured by calculating the information entropy. Genetic algorithm (GA) is originated from computer simulation studies of biological systems, which is a random global search and optimization method inspired by biological evolution mechanism in nature [7]. It is an efficient, parallel, global search algorithm, which can automatically acquire and accumulate knowledge about the search space during the search process and adaptively control the search process to obtain the best solution.In this paper, EEGA (Entropy Embedding Genetic Algorithm for feature selection), a weight distribution model, is proposed, combining characteristics of filter and wrapper algorithms. Based on Information Entropy Theory, EEGA achieves calculation of weights and selection of features. GA is extra introduced for threshold optimization in EEGA, dynamically controlling the feature selection. Classification performance of EEGA is compared with traditional Random Forest and other wrapper algorithms. The comparison outcomes confirmed the effectiveness of our algorithm.The other parts of the paper are arranged as follows. The main content of Section2 is basic theory of Information Entropy Theory and genetic algorithm. Section 3 introduces the proposed EEGA algorithm. Section 4 is the performance comparison and the result analysis. Section 5 is the summary of the paper, and the future work is eventually left to Section 5, too.


## 2. Problem Analysis

### 2.1. Feature Selection

In classification questions about massive dataset or dataset with too many features, fast, accurate, and stable classification is the most concerned. Feature selection provides classification with a direct approach that is replacing the whole by some significant features with most information based on specific criterion. Through feature selection, feature dimensions and redundant features can be reduced, while important features can be retained, so that the learning and generalization ability can be both boosted.The algorithms of feature selection are mainly divided into filter, wrapper, and embedder. The filter scores each feature according to correlation or other information criterion and then sets a threshold or the number of thresholds for selection, while the wrapper one is an iteration process about recursive feature elimination, whose main principle is deleting the features with poor weights, recalculating the features for the overall model in the prediction model with weighted features, and then repeating recursion continuously until expectation. Embedded selection is to integrate the feature selection process with the learner training process, so the feature selection is automatically performed during training process.Wrapper has better classification effect and is more targeted for feature selection, while filter generally involves a noniterative computation, which can be much faster than continuous iterations. Hence, fast and accurate feature selection can be acquired by the combination of filter and wrapper algorithms. Therefore, the filter based on Information Entropy Theory and genetic algorithm, an efficient wrapper, are both introduced for feature selection.


### 2.2. Information Entropy

Entropy was defined by Clausius in 1854 as a measure of system chaos in thermodynamics. Later, entropy theory gradually expanded to other scientific fields. For example, information entropy is proposed by Shannon in the field of information and life entropy is proposed by Schrödinger in the life sciences. In information theory, the more chaotic something is, the greater the entropy is, and the greater the amount of information needed to determine something. Therefore, the uncertainty of things can be measured by information entropy. In other words, information entropy is an index to quantify the uncertainty of events. So the characteristics of information entropy could be utilized to achieve weight distribution.For a feature, the greater the entropy is, the less information it contains (the greater the cost of entropy reduction), for the reason that its assigned weight is smaller. Firstly, uncertainty functiong is defined as(1)g=log1p=−logp,where p is related probability. Then, the measurement of information entropy HG can be realized by calculating the expectation of the uncertainty function:(2)HG=EG=∑g∈Gg⋅p=−∑​plogp,where G is the set of all possible events.


### 2.3. Genetic Algorithm

The genetic algorithm proposed by Holland adopts the binary coding method and realizes iterative optimization by simulating the natural selection mechanism of “survival of the fittest.” The algorithm flow of GA is shown in Figure1.Figure 1
Genetic algorithm process.From the perspective of biology, a population in nature is composed of many individuals and each individual has its own unique gene. It is true that individuals pass their genes to their offspring through mating and reproduction, and in this process, the genes of the parents will cross over. Besides, considering time iteration, these genes may also mutate. According to the “survival of the fittest” theory, the natural environment will weed out those unfit individuals, which makes their genes disappear. Under these conditions, after a sufficiently long period of replacement, what will be left will be the individuals best suited to the environment, so that we can also obtain the genetic makeup that is the optimal choice (assuming environmental conditions do not change).From a mathematical point of view, the gene carried by an individual can be regarded as a feasible solution to the problem. The crossover and mutation of genes can be regarded as the change of the problem solution. And the environment can naturally be understood as fitness function. Under the same fitness function, genes closer to the optimal solution have higher scores. In each iteration, genes with lower scores are discarded. With continuous crossover and mutation, as long as suitable iteration periods are set, a global optimal solution could be achieved.There are some biological terminologies in genetic algorithm [8]. In order to describe them clearly, accurately, and normatively, here explain the meanings of the nouns and basic concepts in Table 1.Table 1
Definition of terms related to genetic algorithm.
TerminologyExplanationGene genotype phenotype evolutionBasic genetic unit in biology, binary in GAInternal representation of trait chromosomes, binary sequence in GAExternal manifestations of trait chromosomes, parameters after binary decodingThe process in which the population gradually adapts to the living environment and the quality is continuously improvedSelection reproduction crossover mutation coding decoding individualSelect a number of individuals from the population with a certain probabilityDNA is transferred into newly created cells by replicationCrossover of DNA at the same location on two chromosomes to form two new chromosomesMutation during replication produces new chromosomes with new traitsThe genetic information in DNA is arranged in a certain pattern on a long chain (binary code) Mapping binary to real numbersChromosomal entityFirst and foremost, what must be prioritized is population initialization, creating a population by randomly selecting features. Then use binary to encode a chromosome as a genotype (randomly generate a string of 0, 1 of a specific length, representing an individual’s genes). Length is decided by the distribution of the weights calculated by the previous information entropy method. The population size is set, too. Next step is estimating the fitness of the individual in the current environment through fitness function (such as SVM, Random Forest, etc.).Implementing the iteration of parent and child requires selection. According to the fitness of individuals in the population, individuals with high fitness are selected from the current population by an approach named roulette. Roulette is to determine the amount of each individual’s inheritance into the next generation population through the individual fitness size and the probability proportional to it. The greater the individual fitness, the higher the probability of survival, and the greater the probability of genes being passed on to the next generation.Also, mating probability needs to be set, resplicing the binary strings representing two individuals to obtain a new binary code, thereby generating a new individual. Furthermore, generate mutation points in gene sequences randomly, which reverses the original genes of the mutation points according to the mutation probability threshold (change 0 to 1, 1 to 0). Therefore, generate new individuals.When the dominant gene changes are no longer significant or the number of iterations reaches the preset epochs, the algorithm is terminated and the genotypes of outstanding individuals are outputted. Finally, decoding genotype into phenotype is the optimal solution.


## 2.1. Feature Selection

In classification questions about massive dataset or dataset with too many features, fast, accurate, and stable classification is the most concerned. Feature selection provides classification with a direct approach that is replacing the whole by some significant features with most information based on specific criterion. Through feature selection, feature dimensions and redundant features can be reduced, while important features can be retained, so that the learning and generalization ability can be both boosted.The algorithms of feature selection are mainly divided into filter, wrapper, and embedder. The filter scores each feature according to correlation or other information criterion and then sets a threshold or the number of thresholds for selection, while the wrapper one is an iteration process about recursive feature elimination, whose main principle is deleting the features with poor weights, recalculating the features for the overall model in the prediction model with weighted features, and then repeating recursion continuously until expectation. Embedded selection is to integrate the feature selection process with the learner training process, so the feature selection is automatically performed during training process.Wrapper has better classification effect and is more targeted for feature selection, while filter generally involves a noniterative computation, which can be much faster than continuous iterations. Hence, fast and accurate feature selection can be acquired by the combination of filter and wrapper algorithms. Therefore, the filter based on Information Entropy Theory and genetic algorithm, an efficient wrapper, are both introduced for feature selection.


## 2.2. Information Entropy

Entropy was defined by Clausius in 1854 as a measure of system chaos in thermodynamics. Later, entropy theory gradually expanded to other scientific fields. For example, information entropy is proposed by Shannon in the field of information and life entropy is proposed by Schrödinger in the life sciences. In information theory, the more chaotic something is, the greater the entropy is, and the greater the amount of information needed to determine something. Therefore, the uncertainty of things can be measured by information entropy. In other words, information entropy is an index to quantify the uncertainty of events. So the characteristics of information entropy could be utilized to achieve weight distribution.For a feature, the greater the entropy is, the less information it contains (the greater the cost of entropy reduction), for the reason that its assigned weight is smaller. Firstly, uncertainty functiong is defined as(1)g=log1p=−logp,where p is related probability. Then, the measurement of information entropy HG can be realized by calculating the expectation of the uncertainty function:(2)HG=EG=∑g∈Gg⋅p=−∑​plogp,where G is the set of all possible events.


## 2.3. Genetic Algorithm

The genetic algorithm proposed by Holland adopts the binary coding method and realizes iterative optimization by simulating the natural selection mechanism of “survival of the fittest.” The algorithm flow of GA is shown in Figure1.Figure 1
Genetic algorithm process.From the perspective of biology, a population in nature is composed of many individuals and each individual has its own unique gene. It is true that individuals pass their genes to their offspring through mating and reproduction, and in this process, the genes of the parents will cross over. Besides, considering time iteration, these genes may also mutate. According to the “survival of the fittest” theory, the natural environment will weed out those unfit individuals, which makes their genes disappear. Under these conditions, after a sufficiently long period of replacement, what will be left will be the individuals best suited to the environment, so that we can also obtain the genetic makeup that is the optimal choice (assuming environmental conditions do not change).From a mathematical point of view, the gene carried by an individual can be regarded as a feasible solution to the problem. The crossover and mutation of genes can be regarded as the change of the problem solution. And the environment can naturally be understood as fitness function. Under the same fitness function, genes closer to the optimal solution have higher scores. In each iteration, genes with lower scores are discarded. With continuous crossover and mutation, as long as suitable iteration periods are set, a global optimal solution could be achieved.There are some biological terminologies in genetic algorithm [8]. In order to describe them clearly, accurately, and normatively, here explain the meanings of the nouns and basic concepts in Table 1.Table 1
Definition of terms related to genetic algorithm.
TerminologyExplanationGene genotype phenotype evolutionBasic genetic unit in biology, binary in GAInternal representation of trait chromosomes, binary sequence in GAExternal manifestations of trait chromosomes, parameters after binary decodingThe process in which the population gradually adapts to the living environment and the quality is continuously improvedSelection reproduction crossover mutation coding decoding individualSelect a number of individuals from the population with a certain probabilityDNA is transferred into newly created cells by replicationCrossover of DNA at the same location on two chromosomes to form two new chromosomesMutation during replication produces new chromosomes with new traitsThe genetic information in DNA is arranged in a certain pattern on a long chain (binary code) Mapping binary to real numbersChromosomal entityFirst and foremost, what must be prioritized is population initialization, creating a population by randomly selecting features. Then use binary to encode a chromosome as a genotype (randomly generate a string of 0, 1 of a specific length, representing an individual’s genes). Length is decided by the distribution of the weights calculated by the previous information entropy method. The population size is set, too. Next step is estimating the fitness of the individual in the current environment through fitness function (such as SVM, Random Forest, etc.).Implementing the iteration of parent and child requires selection. According to the fitness of individuals in the population, individuals with high fitness are selected from the current population by an approach named roulette. Roulette is to determine the amount of each individual’s inheritance into the next generation population through the individual fitness size and the probability proportional to it. The greater the individual fitness, the higher the probability of survival, and the greater the probability of genes being passed on to the next generation.Also, mating probability needs to be set, resplicing the binary strings representing two individuals to obtain a new binary code, thereby generating a new individual. Furthermore, generate mutation points in gene sequences randomly, which reverses the original genes of the mutation points according to the mutation probability threshold (change 0 to 1, 1 to 0). Therefore, generate new individuals.When the dominant gene changes are no longer significant or the number of iterations reaches the preset epochs, the algorithm is terminated and the genotypes of outstanding individuals are outputted. Finally, decoding genotype into phenotype is the optimal solution.


## 3. Entropy Embedding Genetic Algorithm for Feature Selection

For massive dataset with complex features and huge number of samples, the smooth progress of the classification will be influenced by the high time complexity and the noise generated by the unimportant features. Hence, dimensionality reduction technique named feature selection is necessary, where wrapper algorithms (GA, ant colony, algorithm, etc.) optimize through intelligent search. However, these wrapper algorithms are easy to be affected by irrelevant features and different search strategies, causing low accuracy and even overfitting. Therefore, it is of vital importance to select the most relevant features before optimizing, which is related to weight distribution, for the reason that Information Entropy Theory can provide high-quality weight allocation for wrapper algorithms due to its ability to measure the amount of information in indicators. Entropy Embedding Genetic Algorithm for feature selection (EEGA) proposed in this paper, which is a mixed algorithm about filter and wrapper, combines Information Entropy Theory with genetic algorithm for optimizing to realize feature selection.


### 3.1. Weight Distribution Based on Information Entropy Theory

For chosen dataset, values of information entropy about every feature can be exported by Information Entropy Theory, achieving a kind of direct weight distribution. The results of weight distribution serve as labels for individual features for the composition of individuals in each population in GA. Entropy calculation especially for features are represented as follows.At first, what must be prioritized is dimension unification by standardizing data based on positive and negative definition of features. The formulas used are shown in equations (3) and (4)(3)xij∗=xij−minmax−min,if positive,(4)xij∗=max−xijmax−min,if negative,where max and min, respectively, represent the maximum and minimum values of all sample data in each feature.Then, calculate the proportionpij of the value of sample i under the feature j as(5)pij=xij∗∑i=1nxij∗,i=1,⋯,n;j=1,…m.Next, figure out the entropyej of feature j by equation (2).(6)ej=−1logn∑i=1npijlogpij.Accordingly, the weight of the feature can be indicated in(7)wj=1−ejm−∑jmej,j=1,…m.In this paper, the process of weight distribution based on information entropy is described in Algorithm 1.Algorithm 1: Information entropy weight distribution.
Input: NumPy independent variable dataset DOutput: Weight list wj_list(1)
Normalize based on custom functions(2)
Export data shape, the number of rows isn, the number of columns is m(3)
Calculate the Proportionpij=xij∗/∑i=1nxij∗,i=1,…,n;j=1,…m(4)
Figure out the entropyej=−1/logn∑i=1npijlogpij(5)
Calculate the weight of each indicatorwj=1−ej/m−∑jmej(6)
Form weight listwj_list


### 3.2. Genetic Algorithm with Entropy Label

Genetic algorithm (GA) is a kind of optimization algorithm, aiming to search the global optimal point. And due to its characteristic of dynamic adjustment, its derived results are not easy to fall into local optimum. In classification, the high accuracy of classification is the prime gist, as well as the optimal direction in GA. What is more, the calculation of classification accuracy relied on fitness function, which can be any basic classification algorithm such as decision tree, KNN, etc. or just linear discriminant function like Fisher, in GA.First job is population construction. In common genetic algorithm, each individual in population is the data with different feature clustering. However, it is too redundant with carrying a large number of low-correlated features for heavy fitness calculations in massive dataset. Therefore, we introduce features with entropy labels rather than raw data of features and use independent threshold for individual in population rather than the feature clustering. By this approach, features can be chosen by the comparison of the threshold and entropy labels, and population iterations in GA are transformed into the simple threshold iterations, which effectively simplifies the algorithm. For population initialization, each threshold corresponds to a unique binary code, called gene sequence or DNA sequence. The maximum length of gene sequence is decided by features and the distribution of their entropies, which would better be set first, called DNA size. Pop size that is the number of individuals in this generation should also be set in this step. Then, based on pop size, randomly generate binary sequences with DNA size as the primary population. And every individual in primary population has its own normalized decimal value.The second noteworthy step is the calculation of different individual fitness. Compare the information entropy value of each feature in the data with the individual threshold, and the features that meet the standard will be selected. Finally, a new data list will be formed with calculating its fitness, that is, the classification accuracy. After the above process, each individual in this generation owns its fitness value.Then, it is the natural selection algorithm in GA, which uses roulette approach to decide genotypes of next generation. As the name suggests, the principle of roulette is calculating the proportion of fitness of each individual to the sum of fitness, so every individual has its own area on the turntable based on the proportion. One genotype of an individual is selected by generating a random number (looks like pointer on this turntable), where the number of repetitions is equal to the size of population. Therefore, these selected genotypes will participate in crossover and mutation later. Besides, at the part of calculation of the proportion of fitness, normalization should be finished first, and a penalty function is proposed, shown in equation (8), smoothing the fitness and emphasizing the merit of dominant individuals.(8)Fnew fit=2sinπ2α⋅f⋅f,where f is fitness, Fnew fit is the processed fitness function, yf=2sinπ/2α⋅f represents penalty function, and α∈0,1 is the penalty coefficient.In roulette, cumulative probability is calculated to allow each genotype to own its distribution in0,1. Then, generate random numbers in 0,1 to realize the consequent of turntable. In connection with massive dataset, double roulette mechanism is introduced, which chooses better result in each selection of genotype, significantly improving model quality even compared with original genetic algorithm model for halving the population (because original roulette mechanism may meet the loss of dominant population with low pop size). What is more, model time complexity is also reduced, especially using complex discriminant model in fitness calculation.The process of crossover is an imitation in nature that means the crossover of DNA at the same location on two chromosomes to form two new chromosomes. In this paper, randomly generated crossover points are restricted to the second half of the parental DNA sequence in order to better simulate the natural characteristics of the child inheriting the shape of the parent. The description of selection, crossover, and mutation in genetic algorithm are separately shown in Algorithms 2 and 3.Algorithm 2: Selection in GA.
Input: Population pop, fitness list fit_valueOutput: New population pop(1)
Normalize pop and construct penalty map forfit_value as Fnew fit=2sinπ/2α⋅fit_value⋅fit_value(2)
Calculate the fitness sum and cumulative probability(3)
Create cumulative probability listcum(4)
Fori in range(len(pop)) do(5)
Generate 0-1 random numbers into two listsms1,ms2End for(6)
Sortms1,ms2(7)
Traverse the list without exceeding the scope of the listms1 and cum. If the value of this position of ms1 is less than the value of the current position of cum, the genotype at the current position in pop is stored in the temporary gene register new pop1. Position number in ms1 + 1, otherwise the current position +1, until finish traversing.(8)
Perform step 7 onms2 and pop so that new pop2 is formed.(9)
Compare the value of each position ofnew pop1 and new pop2, select the greater value and put it into popAlgorithm 3: Crossover and mutation in GA.
Input: Population pop, CROSSOVER_RATE, MUTATION_RATEOutput: New population new_pop(1)
For father in popdo(2)
child = father(3)
If generate 0-1 random numbers, less than CROSSOVER_RATE(4)
Select another individual in the population and use that individual as the mother.(5)
Randomly generate crossover points in the second half of the DNA sequence.child gets the genes of the mother behind the junction.(6)
If generate 0-1 random numbers, less than MUTATION_RATE(7)
Randomly generate mutation points and change the value of this binary point(8)
Putchild into list new_popEnd forRepeat the above process according to the set number of iterations. Or the average fitness of the population does not change significantly; then end the loop. Overall, EEGA can be summarized as these following points and its technology roadmap is shown in Figure2.(i)
Import the dataset and complete data cleaning.(ii)
Calculate the information entropy of the feature about the dataset.(iii)
Initialize the population.(iv)
Select features according to weights calculated by information entropy.(v)
Calculate the fitness, or in other words, classification accuracy relied on fitness function, which can be any basic classification algorithm or just linear discriminant function.(vi)
Realize the iterative operation in GA, including selection, crossover, and mutation.(vii)
Stop the genetic algorithm after the number of iterations is reached or the population remains relatively stable.(viii)
Output optimal genotype and maximum fitness.Figure 2
Algorithm framework of EEGA.


## 3.1. Weight Distribution Based on Information Entropy Theory

For chosen dataset, values of information entropy about every feature can be exported by Information Entropy Theory, achieving a kind of direct weight distribution. The results of weight distribution serve as labels for individual features for the composition of individuals in each population in GA. Entropy calculation especially for features are represented as follows.At first, what must be prioritized is dimension unification by standardizing data based on positive and negative definition of features. The formulas used are shown in equations (3) and (4)(3)xij∗=xij−minmax−min,if positive,(4)xij∗=max−xijmax−min,if negative,where max and min, respectively, represent the maximum and minimum values of all sample data in each feature.Then, calculate the proportionpij of the value of sample i under the feature j as(5)pij=xij∗∑i=1nxij∗,i=1,⋯,n;j=1,…m.Next, figure out the entropyej of feature j by equation (2).(6)ej=−1logn∑i=1npijlogpij.Accordingly, the weight of the feature can be indicated in(7)wj=1−ejm−∑jmej,j=1,…m.In this paper, the process of weight distribution based on information entropy is described in Algorithm 1.Algorithm 1: Information entropy weight distribution.
Input: NumPy independent variable dataset DOutput: Weight list wj_list(1)
Normalize based on custom functions(2)
Export data shape, the number of rows isn, the number of columns is m(3)
Calculate the Proportionpij=xij∗/∑i=1nxij∗,i=1,…,n;j=1,…m(4)
Figure out the entropyej=−1/logn∑i=1npijlogpij(5)
Calculate the weight of each indicatorwj=1−ej/m−∑jmej(6)
Form weight listwj_list


## 3.2. Genetic Algorithm with Entropy Label

Genetic algorithm (GA) is a kind of optimization algorithm, aiming to search the global optimal point. And due to its characteristic of dynamic adjustment, its derived results are not easy to fall into local optimum. In classification, the high accuracy of classification is the prime gist, as well as the optimal direction in GA. What is more, the calculation of classification accuracy relied on fitness function, which can be any basic classification algorithm such as decision tree, KNN, etc. or just linear discriminant function like Fisher, in GA.First job is population construction. In common genetic algorithm, each individual in population is the data with different feature clustering. However, it is too redundant with carrying a large number of low-correlated features for heavy fitness calculations in massive dataset. Therefore, we introduce features with entropy labels rather than raw data of features and use independent threshold for individual in population rather than the feature clustering. By this approach, features can be chosen by the comparison of the threshold and entropy labels, and population iterations in GA are transformed into the simple threshold iterations, which effectively simplifies the algorithm. For population initialization, each threshold corresponds to a unique binary code, called gene sequence or DNA sequence. The maximum length of gene sequence is decided by features and the distribution of their entropies, which would better be set first, called DNA size. Pop size that is the number of individuals in this generation should also be set in this step. Then, based on pop size, randomly generate binary sequences with DNA size as the primary population. And every individual in primary population has its own normalized decimal value.The second noteworthy step is the calculation of different individual fitness. Compare the information entropy value of each feature in the data with the individual threshold, and the features that meet the standard will be selected. Finally, a new data list will be formed with calculating its fitness, that is, the classification accuracy. After the above process, each individual in this generation owns its fitness value.Then, it is the natural selection algorithm in GA, which uses roulette approach to decide genotypes of next generation. As the name suggests, the principle of roulette is calculating the proportion of fitness of each individual to the sum of fitness, so every individual has its own area on the turntable based on the proportion. One genotype of an individual is selected by generating a random number (looks like pointer on this turntable), where the number of repetitions is equal to the size of population. Therefore, these selected genotypes will participate in crossover and mutation later. Besides, at the part of calculation of the proportion of fitness, normalization should be finished first, and a penalty function is proposed, shown in equation (8), smoothing the fitness and emphasizing the merit of dominant individuals.(8)Fnew fit=2sinπ2α⋅f⋅f,where f is fitness, Fnew fit is the processed fitness function, yf=2sinπ/2α⋅f represents penalty function, and α∈0,1 is the penalty coefficient.In roulette, cumulative probability is calculated to allow each genotype to own its distribution in0,1. Then, generate random numbers in 0,1 to realize the consequent of turntable. In connection with massive dataset, double roulette mechanism is introduced, which chooses better result in each selection of genotype, significantly improving model quality even compared with original genetic algorithm model for halving the population (because original roulette mechanism may meet the loss of dominant population with low pop size). What is more, model time complexity is also reduced, especially using complex discriminant model in fitness calculation.The process of crossover is an imitation in nature that means the crossover of DNA at the same location on two chromosomes to form two new chromosomes. In this paper, randomly generated crossover points are restricted to the second half of the parental DNA sequence in order to better simulate the natural characteristics of the child inheriting the shape of the parent. The description of selection, crossover, and mutation in genetic algorithm are separately shown in Algorithms 2 and 3.Algorithm 2: Selection in GA.
Input: Population pop, fitness list fit_valueOutput: New population pop(1)
Normalize pop and construct penalty map forfit_value as Fnew fit=2sinπ/2α⋅fit_value⋅fit_value(2)
Calculate the fitness sum and cumulative probability(3)
Create cumulative probability listcum(4)
Fori in range(len(pop)) do(5)
Generate 0-1 random numbers into two listsms1,ms2End for(6)
Sortms1,ms2(7)
Traverse the list without exceeding the scope of the listms1 and cum. If the value of this position of ms1 is less than the value of the current position of cum, the genotype at the current position in pop is stored in the temporary gene register new pop1. Position number in ms1 + 1, otherwise the current position +1, until finish traversing.(8)
Perform step 7 onms2 and pop so that new pop2 is formed.(9)
Compare the value of each position ofnew pop1 and new pop2, select the greater value and put it into popAlgorithm 3: Crossover and mutation in GA.
Input: Population pop, CROSSOVER_RATE, MUTATION_RATEOutput: New population new_pop(1)
For father in popdo(2)
child = father(3)
If generate 0-1 random numbers, less than CROSSOVER_RATE(4)
Select another individual in the population and use that individual as the mother.(5)
Randomly generate crossover points in the second half of the DNA sequence.child gets the genes of the mother behind the junction.(6)
If generate 0-1 random numbers, less than MUTATION_RATE(7)
Randomly generate mutation points and change the value of this binary point(8)
Putchild into list new_popEnd forRepeat the above process according to the set number of iterations. Or the average fitness of the population does not change significantly; then end the loop. Overall, EEGA can be summarized as these following points and its technology roadmap is shown in Figure2.(i)
Import the dataset and complete data cleaning.(ii)
Calculate the information entropy of the feature about the dataset.(iii)
Initialize the population.(iv)
Select features according to weights calculated by information entropy.(v)
Calculate the fitness, or in other words, classification accuracy relied on fitness function, which can be any basic classification algorithm or just linear discriminant function.(vi)
Realize the iterative operation in GA, including selection, crossover, and mutation.(vii)
Stop the genetic algorithm after the number of iterations is reached or the population remains relatively stable.(viii)
Output optimal genotype and maximum fitness.Figure 2
Algorithm framework of EEGA.


## 4. Experiment

### 4.1. Dataset

The datasets used for the experiment in this paper are all real datasets, all of which are from UCI Machine Learning Repository [9]. In this experiment, five datasets with different characteristics are chosen to test the generality of EEGA, which are from chemistry, medicine, and computer science. Some of them have missing values and outliers, so data preprocessing has been achieved first. The characteristics of the datasets are organized in Table 2. As is shown in Table 2, the number of samples ranges from 1040 to 10129, and the number of features ranges from 16 to 168.Table 2
Detail of datasets.
NoNameFeature numberSample sizeCategoryMissing valueArea1Cardiotocography [10]3421263N/ALife2Musk [11]16865982NoPhysical3Parkinson speech [12]2610402N/ALife4Room occupancy estimation [13]16101294N/AComputer5Spambase [14]5746012YesComputer


### 4.2. Experimental Results and Discussions

The performance of Entropy Embedding Genetic Algorithm for feature selection (EEGA) is visualized in five datasets by two evaluation indicators: accuracy and time complexity. Because EEGA has built-in models of individual fitness of different populations and the model can be seen as an optimization algorithm of these built-in models for classification problem, some basic approaches about classification like Random Forest (RF) are selected as built-in models of EEGA to make comparison about themselves. The specific experimental results can be found below.


#### 4.2.1. Accuracy Assessment

There is no doubt that accuracy is the most important evaluation criterion in classification problems. Because most of classification in machine learning is supervised learning, accuracy can be defined as the proportion of test samples which are correctly classified based on class labels. Hence, the fitness target of genetic algorithm should be set as accuracy in this experiment. What is more, the fitness models, or in other words, the built-in models of GA, are specified as KNN, DNN, SVM, and RF here. Besides, because the results of RF are not fixed, the accuracy of RF and RF with EEGA is tested five times and average is made.First and foremost, what must be preferentially calculated is information entropy of dataset. And the results of it are shown as Figure3.Figure 3
Weight distribution about five datasets.Then, some parameters should be set in EEGA before experiment. The crossover rate and mutation rate are set as 0.8 and 0.02, respectively. Also, population size is 40. And generation cycle is 40, too (while the model would call out the loop in advance in most situation in actual experiment). DNA size is 8 except 9 in Musk dataset. Finally, penalty rate in penalty function equation (8) represents 0.8.As for built-in models in EEGA, import KNN, DNN, SVM, and RF directly through the sklearn module. For the division of the data set, k-fold cross-validation method is used and the parameterk here is ten. K-fold cross-validation uses the technique without repeated sampling. Each sample point has only one chance to be included in the training set or test set during each iteration. The principle is to randomly divide the dataset into k packages, one of which is used as the test set each time, and the remaining k − 1 packages are used as the training set for training. Finally, the average of the test results is taken as the final result, shown in(9)Acc=∑i=1kacctesti,where acctesti is the accuracy result on the test set for each fold.Table3 shows the comparison about classification accuracy between original algorithms and EEGA. Also, Figure 4 shows the changes of the four algorithms in indicator accuracy before and after the EEGA is introduced.Table 3
Comparison about classification accuracy.
Cardiotocography (%)Musk (%)Parkinson speech (%)Room occupancy estimation (%)Spambase (%)KNN80.99577.24263.94295.88377.919KNN with EEGA98.40184.95399.32797.16687.981DNN91.62481.02995.48197.95691.936DNN with EEGA98.49585.08710010093.936SVM77.84688.40879.51996.76171.072SVM with EEGA98.40189.51099.80897.34489.785RF97.97179.99999.90497.66094.066RF with EEGA98.54287.22510010095.087Figure 4
Accuracy about five datasets.It can be seen in Table3 that all performances of four algorithms in five datasets are improved by introducing EEGA. In Cardiotocography dataset, accuracies of all improved models are more than 98%, with approximately 1% to 19% increase. However, no model is more than 90% accurate in Musk, but there are still accuracy boosts within about single digit percent. The limited improvement may be caused by huge 168 features so that genetic algorithm needs bigger DNA size to contain the feature thresholds, while because of the limitation of equipment, the maximum DNA size is set 9. Model performance can be further improved in Musk. The greatest improvement in this experiment occurs in Parkinson Speech using KNN with EEGA, from 63.942% to 99.327% (approximately 55.3% increase shows visually in Figure 4 about Parkinson Speech). Even though some algorithms without EEGA have already achieved excellent accuracy such as DNN and RF in Parkinson Speech and Room Occupancy Estimation dataset, they still obtain significant boost to directly 100%. The outstanding performance of EEGA with all four algorithms illustrates the method can still perform good feature selection in the face of samples with a large amount of data or complex features. Finally, for massive dataset Spambase, two of the fitness algorithms keep smaller accuracy improvement, while the performance of KNN rises to 87.981% (origin is 77.919%), and SVM also obtains 18% magnification.Besides, through the iteration of genetic algorithm, the optimal genotype, in other words, optimal threshold for feature selection, is figured out. Similarly, optimal threshold in RF is chosen when the maximum accuracy is taken out in five times. The results about it are sorted in Table4.Table 4
The optimal threshold in EEGA for feature selection.
CardiotocographyMuskParkinson speechRoom occupancy estimationSpambaseKNN with EEGA0.9760.3750.6990.7580.789DNN with EEGA0.5820.1170.8080.7930.133SVM with EEGA0.3050.5550.7970.8400.223RF with EEGA0.2810.4570.8080.7930.863It can be easily seen in Table4 that the optimal threshold is not the same in different datasets with different original algorithms; even the accuracies are equivalent in one dataset, Cardiotocography (0.976 with KNN and 0.305 with SVM), which may be on account of difference in fitness calculation or multiple optimal genotypes, except the situation of 100% accuracy. However, the calculation of optimal thresholds provides a new possibility of feature selection that obtains the result of optimal genotype with shallower iteration to make new data for classification.


### 4.3. Time Assessment

Time complexity is also one of the important evaluation indicators to determine the quality of the classification model. Many classification algorithms would rather sacrifice accuracy to reduce model time complexity. In some theory, time complexity can be simply described as the running time of algorithm. And this paper follows this definition. The running time is measured and calculated between original algorithms and EEGA, shown in Table5. The final running time is the average of the results of five runs.Table 5
Comparison about time complexity (per second).
CardiotocographyMuskParkinson speechRoom occupancy estimationSpambaseKNN0.173101.251010.124970.689970.61050KNN with EEGA0.140541.141620.046820.485940.54809DNN4.6847619.9373210.371516.4599611.59904DNN with EEGA3.8977219.169797.9664613.4100110.45439SVM1.094686.743150.407443.392827.24195SVM with EEGA1.080495.744770.390533.129397.22855RF2.1324220.033981.800423.551735.04623RF with EEGA2.0283318.740991.761692.645564.93956As shown in Table5, through feature selection of EEGA, the time complexity of the algorithms is generally reduced, where DNN obtains the greater performance boost in time assessment in range between 9.9% and 23%. The rest of the algorithms make running time decrease but not all evidently, while most of improvement is more than 5% and the most significant dropping about time complexity is KNN with EEGA for Parkinson Speech (62%), which illustrates that EEGA makes great contribution on time complexity reduction. Besides, as the complexity of the model increases and the number of features grows, the advantages of this model will be further highlighted.


## 4.1. Dataset

The datasets used for the experiment in this paper are all real datasets, all of which are from UCI Machine Learning Repository [9]. In this experiment, five datasets with different characteristics are chosen to test the generality of EEGA, which are from chemistry, medicine, and computer science. Some of them have missing values and outliers, so data preprocessing has been achieved first. The characteristics of the datasets are organized in Table 2. As is shown in Table 2, the number of samples ranges from 1040 to 10129, and the number of features ranges from 16 to 168.Table 2
Detail of datasets.
NoNameFeature numberSample sizeCategoryMissing valueArea1Cardiotocography [10]3421263N/ALife2Musk [11]16865982NoPhysical3Parkinson speech [12]2610402N/ALife4Room occupancy estimation [13]16101294N/AComputer5Spambase [14]5746012YesComputer


## 4.2. Experimental Results and Discussions

The performance of Entropy Embedding Genetic Algorithm for feature selection (EEGA) is visualized in five datasets by two evaluation indicators: accuracy and time complexity. Because EEGA has built-in models of individual fitness of different populations and the model can be seen as an optimization algorithm of these built-in models for classification problem, some basic approaches about classification like Random Forest (RF) are selected as built-in models of EEGA to make comparison about themselves. The specific experimental results can be found below.


### 4.2.1. Accuracy Assessment

There is no doubt that accuracy is the most important evaluation criterion in classification problems. Because most of classification in machine learning is supervised learning, accuracy can be defined as the proportion of test samples which are correctly classified based on class labels. Hence, the fitness target of genetic algorithm should be set as accuracy in this experiment. What is more, the fitness models, or in other words, the built-in models of GA, are specified as KNN, DNN, SVM, and RF here. Besides, because the results of RF are not fixed, the accuracy of RF and RF with EEGA is tested five times and average is made.First and foremost, what must be preferentially calculated is information entropy of dataset. And the results of it are shown as Figure3.Figure 3
Weight distribution about five datasets.Then, some parameters should be set in EEGA before experiment. The crossover rate and mutation rate are set as 0.8 and 0.02, respectively. Also, population size is 40. And generation cycle is 40, too (while the model would call out the loop in advance in most situation in actual experiment). DNA size is 8 except 9 in Musk dataset. Finally, penalty rate in penalty function equation (8) represents 0.8.As for built-in models in EEGA, import KNN, DNN, SVM, and RF directly through the sklearn module. For the division of the data set, k-fold cross-validation method is used and the parameterk here is ten. K-fold cross-validation uses the technique without repeated sampling. Each sample point has only one chance to be included in the training set or test set during each iteration. The principle is to randomly divide the dataset into k packages, one of which is used as the test set each time, and the remaining k − 1 packages are used as the training set for training. Finally, the average of the test results is taken as the final result, shown in(9)Acc=∑i=1kacctesti,where acctesti is the accuracy result on the test set for each fold.Table3 shows the comparison about classification accuracy between original algorithms and EEGA. Also, Figure 4 shows the changes of the four algorithms in indicator accuracy before and after the EEGA is introduced.Table 3
Comparison about classification accuracy.
Cardiotocography (%)Musk (%)Parkinson speech (%)Room occupancy estimation (%)Spambase (%)KNN80.99577.24263.94295.88377.919KNN with EEGA98.40184.95399.32797.16687.981DNN91.62481.02995.48197.95691.936DNN with EEGA98.49585.08710010093.936SVM77.84688.40879.51996.76171.072SVM with EEGA98.40189.51099.80897.34489.785RF97.97179.99999.90497.66094.066RF with EEGA98.54287.22510010095.087Figure 4
Accuracy about five datasets.It can be seen in Table3 that all performances of four algorithms in five datasets are improved by introducing EEGA. In Cardiotocography dataset, accuracies of all improved models are more than 98%, with approximately 1% to 19% increase. However, no model is more than 90% accurate in Musk, but there are still accuracy boosts within about single digit percent. The limited improvement may be caused by huge 168 features so that genetic algorithm needs bigger DNA size to contain the feature thresholds, while because of the limitation of equipment, the maximum DNA size is set 9. Model performance can be further improved in Musk. The greatest improvement in this experiment occurs in Parkinson Speech using KNN with EEGA, from 63.942% to 99.327% (approximately 55.3% increase shows visually in Figure 4 about Parkinson Speech). Even though some algorithms without EEGA have already achieved excellent accuracy such as DNN and RF in Parkinson Speech and Room Occupancy Estimation dataset, they still obtain significant boost to directly 100%. The outstanding performance of EEGA with all four algorithms illustrates the method can still perform good feature selection in the face of samples with a large amount of data or complex features. Finally, for massive dataset Spambase, two of the fitness algorithms keep smaller accuracy improvement, while the performance of KNN rises to 87.981% (origin is 77.919%), and SVM also obtains 18% magnification.Besides, through the iteration of genetic algorithm, the optimal genotype, in other words, optimal threshold for feature selection, is figured out. Similarly, optimal threshold in RF is chosen when the maximum accuracy is taken out in five times. The results about it are sorted in Table4.Table 4
The optimal threshold in EEGA for feature selection.
CardiotocographyMuskParkinson speechRoom occupancy estimationSpambaseKNN with EEGA0.9760.3750.6990.7580.789DNN with EEGA0.5820.1170.8080.7930.133SVM with EEGA0.3050.5550.7970.8400.223RF with EEGA0.2810.4570.8080.7930.863It can be easily seen in Table4 that the optimal threshold is not the same in different datasets with different original algorithms; even the accuracies are equivalent in one dataset, Cardiotocography (0.976 with KNN and 0.305 with SVM), which may be on account of difference in fitness calculation or multiple optimal genotypes, except the situation of 100% accuracy. However, the calculation of optimal thresholds provides a new possibility of feature selection that obtains the result of optimal genotype with shallower iteration to make new data for classification.


## 4.2.1. Accuracy Assessment

There is no doubt that accuracy is the most important evaluation criterion in classification problems. Because most of classification in machine learning is supervised learning, accuracy can be defined as the proportion of test samples which are correctly classified based on class labels. Hence, the fitness target of genetic algorithm should be set as accuracy in this experiment. What is more, the fitness models, or in other words, the built-in models of GA, are specified as KNN, DNN, SVM, and RF here. Besides, because the results of RF are not fixed, the accuracy of RF and RF with EEGA is tested five times and average is made.First and foremost, what must be preferentially calculated is information entropy of dataset. And the results of it are shown as Figure3.Figure 3
Weight distribution about five datasets.Then, some parameters should be set in EEGA before experiment. The crossover rate and mutation rate are set as 0.8 and 0.02, respectively. Also, population size is 40. And generation cycle is 40, too (while the model would call out the loop in advance in most situation in actual experiment). DNA size is 8 except 9 in Musk dataset. Finally, penalty rate in penalty function equation (8) represents 0.8.As for built-in models in EEGA, import KNN, DNN, SVM, and RF directly through the sklearn module. For the division of the data set, k-fold cross-validation method is used and the parameterk here is ten. K-fold cross-validation uses the technique without repeated sampling. Each sample point has only one chance to be included in the training set or test set during each iteration. The principle is to randomly divide the dataset into k packages, one of which is used as the test set each time, and the remaining k − 1 packages are used as the training set for training. Finally, the average of the test results is taken as the final result, shown in(9)Acc=∑i=1kacctesti,where acctesti is the accuracy result on the test set for each fold.Table3 shows the comparison about classification accuracy between original algorithms and EEGA. Also, Figure 4 shows the changes of the four algorithms in indicator accuracy before and after the EEGA is introduced.Table 3
Comparison about classification accuracy.
Cardiotocography (%)Musk (%)Parkinson speech (%)Room occupancy estimation (%)Spambase (%)KNN80.99577.24263.94295.88377.919KNN with EEGA98.40184.95399.32797.16687.981DNN91.62481.02995.48197.95691.936DNN with EEGA98.49585.08710010093.936SVM77.84688.40879.51996.76171.072SVM with EEGA98.40189.51099.80897.34489.785RF97.97179.99999.90497.66094.066RF with EEGA98.54287.22510010095.087Figure 4
Accuracy about five datasets.It can be seen in Table3 that all performances of four algorithms in five datasets are improved by introducing EEGA. In Cardiotocography dataset, accuracies of all improved models are more than 98%, with approximately 1% to 19% increase. However, no model is more than 90% accurate in Musk, but there are still accuracy boosts within about single digit percent. The limited improvement may be caused by huge 168 features so that genetic algorithm needs bigger DNA size to contain the feature thresholds, while because of the limitation of equipment, the maximum DNA size is set 9. Model performance can be further improved in Musk. The greatest improvement in this experiment occurs in Parkinson Speech using KNN with EEGA, from 63.942% to 99.327% (approximately 55.3% increase shows visually in Figure 4 about Parkinson Speech). Even though some algorithms without EEGA have already achieved excellent accuracy such as DNN and RF in Parkinson Speech and Room Occupancy Estimation dataset, they still obtain significant boost to directly 100%. The outstanding performance of EEGA with all four algorithms illustrates the method can still perform good feature selection in the face of samples with a large amount of data or complex features. Finally, for massive dataset Spambase, two of the fitness algorithms keep smaller accuracy improvement, while the performance of KNN rises to 87.981% (origin is 77.919%), and SVM also obtains 18% magnification.Besides, through the iteration of genetic algorithm, the optimal genotype, in other words, optimal threshold for feature selection, is figured out. Similarly, optimal threshold in RF is chosen when the maximum accuracy is taken out in five times. The results about it are sorted in Table4.Table 4
The optimal threshold in EEGA for feature selection.
CardiotocographyMuskParkinson speechRoom occupancy estimationSpambaseKNN with EEGA0.9760.3750.6990.7580.789DNN with EEGA0.5820.1170.8080.7930.133SVM with EEGA0.3050.5550.7970.8400.223RF with EEGA0.2810.4570.8080.7930.863It can be easily seen in Table4 that the optimal threshold is not the same in different datasets with different original algorithms; even the accuracies are equivalent in one dataset, Cardiotocography (0.976 with KNN and 0.305 with SVM), which may be on account of difference in fitness calculation or multiple optimal genotypes, except the situation of 100% accuracy. However, the calculation of optimal thresholds provides a new possibility of feature selection that obtains the result of optimal genotype with shallower iteration to make new data for classification.


## 4.3. Time Assessment

Time complexity is also one of the important evaluation indicators to determine the quality of the classification model. Many classification algorithms would rather sacrifice accuracy to reduce model time complexity. In some theory, time complexity can be simply described as the running time of algorithm. And this paper follows this definition. The running time is measured and calculated between original algorithms and EEGA, shown in Table5. The final running time is the average of the results of five runs.Table 5
Comparison about time complexity (per second).
CardiotocographyMuskParkinson speechRoom occupancy estimationSpambaseKNN0.173101.251010.124970.689970.61050KNN with EEGA0.140541.141620.046820.485940.54809DNN4.6847619.9373210.371516.4599611.59904DNN with EEGA3.8977219.169797.9664613.4100110.45439SVM1.094686.743150.407443.392827.24195SVM with EEGA1.080495.744770.390533.129397.22855RF2.1324220.033981.800423.551735.04623RF with EEGA2.0283318.740991.761692.645564.93956As shown in Table5, through feature selection of EEGA, the time complexity of the algorithms is generally reduced, where DNN obtains the greater performance boost in time assessment in range between 9.9% and 23%. The rest of the algorithms make running time decrease but not all evidently, while most of improvement is more than 5% and the most significant dropping about time complexity is KNN with EEGA for Parkinson Speech (62%), which illustrates that EEGA makes great contribution on time complexity reduction. Besides, as the complexity of the model increases and the number of features grows, the advantages of this model will be further highlighted.


## 5. Conclusion

In this paper, an improved feature reduction algorithm is proposed called Entropy Embedding Genetic Algorithm for feature selection (EEGA), which is the combination of filter and wrapper methods. The main principle of it is making use of information entropy to calculate feature weights and using the distributed weights as the labels of features into population iteration in genetic algorithm instead of the whole data into generation which greatly reduces model complexity. What is more, because of the decrease of features, that is, significant features get more weight, the accuracy of the model has also generally improved. The performance improvement mentioned above has been proved by the experiment about the comparison between EEGA and original algorithms without EEGA. The experiments have been performed by using several standard databases with different fitness methods. Classification accuracy has been improved by maximum 20% and each error rate is limited to 15%. The similar boost is proved about reducing model time complexity in range between approximately 5% and 23%. The improvement in accuracy and the reduction in time complexity both demonstrate the effectiveness of EEGA in feature selection [15].



---

*Source: 7111034-2022-05-25.xml*