The volume gas fraction is an important parameter in gas-liquid two-phase flow, which plays a significant role in the study of mass and heat transfer, pressure drop, and other aspects of gas-liquid two-phase flow. Accurate identification and characterization of gas volume fraction is an important prerequisite for scientific study and industrial process. In this paper, phased array ultrasonic technology was used to conduct flow parameter measurement experiments of three flow patterns (slug flow, plug flow, and stratified flow) in horizontal pipes at the high-precision gas-liquid two-phase flow testing device. Through an analysis of measurement results by the sector scan method, coupled with principal component analysis (PCA) to mitigate noise and extract eigenvalues from the acquired 128*448 matrix data, a predictive model for gas volume fraction satisfying the three flow patterns is established by the random forest (RF) algorithm. The Laboratory results show that the average mean absolute percentage error (MAPE) is 10.98%. The model is adaptive to the three flow patterns, which provides a technical solution to the gas volume fraction detection of gas-liquid two-phase flow in industrial process.