###### Abstract
developed the 'Enpasol' digital recorder for recording the drilling parameters of the drilling rig and classifying the rock and soil [10]. [PERSON] considered percussion drilling parameters and the variability between them and predicted the rock-quality designation (RQD) during tunnel excavation [11]. [PERSON] et al. improved the monitoring method of the drilling rate, proposed a fast and intuitive time series analysis method of the space-time data of the drilling process, and suggested that the change in formation could be predicted according to the change in the penetration rate of drilling [12]. [PERSON] et al. set up an indoor rock-mass digital drilling test platform to investigate the relationships between the drilling parameters and rock properties based on a polycrystalline diamond compact (PDC) bit [13]. [PERSON] et al. proposed a probability-classification method for formation recognition based on Bayesian principles [14]. Many assumptions and linear fitting relationships for rock-formation classification or rock-mass classification predictions based on MWD data were used in traditional theoretical methods [15]; these are inconsistent with the complex variability of the actual drilling process in the field and the nonlinear relationships between parameters. In recent years, some scholars have introduced machine learning in the field of rock-mass identification [16; 17]; such methods can determine the laws between multiple variables from the data and provide the required results when the process mechanism is not clear [18; 19]. [PERSON] et al. used the neural network method to classify lithologies based on laboratory drilling experimental data [20]. [PERSON] et al. used an SVM to build a relationship model between the parameters of the PDC bit while drilling and the rock-mass uniaxial compressive strength (UCS) [21]. These studies demonstrate that machine learning can effectively identify the properties of rock and soil based on drilling parameters using simple models and less noisy indoor drilling experiment data. [PERSON] et al. used different machine-learning methods to predict porosity with reservoir-associated gas using gas-while-drilling data [22]. [PERSON] et al. based on the fuzzy logic (FL) algorithm [23], [PERSON] et al. based on the MLP, [PERSON] et al. and [PERSON] et al. based on the DT ensemble learning conducted formation-lithology recognition [24; 25; 26], applied machine learning methods in practical engineering with a large amount of noisy data. Although current machine-learning algorithms can achieve good prediction results, several shortcomings persist: (1) Drilling is a continuous process; however, these studies only use the drilling data corresponding to the position to classify the rock class at a certain depth during the drilling process. [PERSON] et al. demonstrated through their research that considering the information contained in the sequence can improve the accuracy of results [27]. (2) Datasets obtained in practice are small and prone to overfitting, thereby impacting the prediction effect. (3) Most studies use accuracy as model performance evaluation metric, but the proportions of the surrounding rocks of different classes in an actual project vary greatly. For such unbalanced datasets, a single evaluation metric may incorrectly evaluate model performance. To address the aforementioned issues, this study proposes a machine-learning method with BILSTM as the core, using depth-sequence MWD data to classify rock-mass classes in real-time. (1) The BILSTM was used to fully consider the influence of depth-sequence MWD data on rock-classification results. Information related to the surrounding rock class were extracted in both the forward and reverse directions. (2) Stratified K-fold cross-validation determined the optimal model in a small and unbalanced dataset to avoid overfitting. The voting mechanism was designed to avoid random effects and misidentification in special circumstances, while the random window-selection mechanism was devised to enhance the model's generalization ability.