The moth-flame algorithm shows some shortcomings in solving the complex problem of optimization, such as insufficient population diversity and unbalanced search ability. In this paper, an IMFO (Improved Moth-Flame Optimization) algorithm is proposed to be applied in solving the optimization problem of function. First, cat chaotic mapping is used to generate the initial position of moth to improve the population diversity. Second, cosine inertia weight is introduced to balance the global and local search abilities of the algorithm. Third, the memory information in the particle swarm algorithm is introduced into the iterative process of the algorithm to speed up the convergence of the population. Finally, Gaussian mutation strategy is used in the current optimal solution to avoid the algorithm from falling into the local optimum. Simulation experiments are conducted on 11 benchmark test functions, compared with other improved MFO (Moth-Flame Optimization) algorithms and classical optimization algorithms. The results show that the IMFO has higher accuracy and stability in solving the above-mentioned test functions. The proposed algorithm is experimented and verified by optimizing the KELM (Kernel Extreme Learning Machine) in an engineering example and exhibits a better optimization performance.