On this page

Two-stage optimization algorithm of random forest and its effectiveness in stock index prediction

By: Jingdan Luo 1, Yang Shen 1
1Guilin Institute of Information Technology, Guilin, Guangxi, 541000, China

Abstract

A stock price index is an indicator reflecting the overall trend of the stock market, calculated through weighted averaging based on a selected sample of stocks. For investors, observing the fluctuations in stock price indices can help assess market sentiment and risk, predict future market trends, and formulate more informed investment strategies. This study introduces the particle swarm optimization (PSO) algorithm to optimize random forests, constructing a PSO-RF prediction model. Simulation experiments indicate that when the number of particles reaches 32, the model’s evaluation metrics achieve optimal performance. When applying the PSO-RF algorithm to the selection of decision trees in ensemble forests, the quality of sub-forests of different sizes was evaluated using different diversity (or similarity) metrics. The PSO-RF algorithm achieved optimization effects for the random forest algorithm across all selected sub-forest sizes. Data from the CSI 500 Index from 2023 to 2027 was selected as the sample set. After validation and analysis in different experiments, the optimized random forest model demonstrated high prediction accuracy, strong stability, and good predictive performance on the CSI 500 Index across different time periods.