Python-actual combat: VMD hyperparameter optimization based on Whale WOA

Table of contents

1 principle

2 combat

2.1 The original time series

 2.2 Directly set parameters for VMD decomposition

 2.3 WOA optimizes VMD hyperparameters

 2.4 VMD decomposition using optimized parameters

 3 codes


In the use of VMD--Variational Mode Decomposition, its k and alpha have a great influence on the decomposition results. A large number of articles optimize the selection of these two parameters, such as through the analysis of the fft spectrum of the mode, and through the optimization algorithm There are also a small number of matlab cases on the Internet, but there are basically no python cases. For this, I wrote a python version.

1 principle

The more complex the time series, the larger the calculated value of the sample entropy SE, and vice versa. Therefore, after applying VMD to decompose the signal, calculate the SE value of each subsequence, and the sequence with the smallest SE is the trend item of the decomposed sequence.

When the decomposition number K is small, the signal decomposition may be insufficient, and other interference items may be mixed into the trend item, resulting in a larger SE value. When taking an appropriate K value, the SE of the trend item becomes smaller. Therefore, when the smallest entropy SE (local sample entropy) in the decomposed IMF is minimized, the VMD decomposition is the best

Of course, sample entropy has its limitations, so there are many methods at present, such as minimizing envelope entropy, minimizing spectral correlation kurtosis, etc. This article still uses minimizing local sample entropy as the starting point to program

'''适应度函数,最小化各VMD分量的局部样本熵'''
def fitness(pop,data):
    np.random.seed(0)
    
    K = int(pop[0])
    alpha = int(pop[1])
    #print(K,alpha)
    tau = 0  
    DC = 0         
    init = 1         
    tol = 1e-7
    imf,res,u_hat,omega=VMD(data, alpha, tau, K, DC, init, tol)
    comp=np.vstack([imf,res.reshape(1,-1)])
    SE = 0
    se_imf=[]
    for i in range(comp.shape[0]):
        temp= sampEn(comp[i,:], np.std(comp[i,:]),2, 0.15)
        SE +=temp
        se_imf.append(temp)
    # fit = SE
    # fit = SE/K
    fit = min(se_imf)
    
    
    np.random.seed(int(time.time()))
    return fit 

2 combat

2.1 The original time series

 2.2 Directly set parameters for VMD decomposition

 2.3 WOA optimizes VMD hyperparameters

        Since we are minimizing the local sample entropy, the fitness curve is a descending curve

The optimal k and alpha are 9 and 65

iteration 1 = 0.03475234914892587 [6, 715]
iteration 2 = 0.03474872927521434 [6, 721]
iteration 3 = 0.03423725134060173 [8, 882]
iteration 4 = 0.034142069286057515 [9, 920]
iteration 5 = 0.015960969553223837 [9, 65]
iteration 6 = 0.015960969553223837 [9, 65]
iteration 7 = 0.015960969553223837 [9, 65]
iteration 8 = 0.015960969553223837 [9, 65]
iteration 9 = 0.015960969553223837 [9, 65]
iteration 10 = 0.015960969553223837 [9, 65]

 2.4 VMD decomposition using optimized parameters

 3 codes

see my blog comment area

Guess you like

Origin blog.csdn.net/qq_41043389/article/details/127762397