Railway train delay prediction method based on XGBoost-LSTM fusion model

By using the XGBoost-LSTM fusion model, which combines static and temporal features, the problem of handling static features and variable-length sequences in railway train delay prediction is solved, achieving higher prediction accuracy and generalization ability, especially with a significant improvement in accuracy within ±1 minute.

CN121543778APending Publication Date: 2026-02-17LANZHOU JIAOTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511450212.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-11
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

Existing methods for predicting train delays are ineffective at handling static and temporal features and lack effective mechanisms for processing variable-length sequences, resulting in insufficient prediction accuracy.

Method used

We employ an XGBoost-LSTM fusion model that combines static and temporal features. We use Optuna Bayesian optimization to find the optimal parameters, and use the MaskedHuberLoss loss function and MaskedMeanAbsoluteError evaluation metrics to handle variable-length sequences and padding issues. We also avoid data leakage by partitioning the data by run ID.

Benefits of technology

It significantly improved the accuracy of railway train delay prediction, with a test set MAE of 0.2439, representing improvements of 4.6% and 23.5% respectively compared to the single model. The model's generalization ability was enhanced, and the accuracy of prediction error within ±1 minute reached 95.65%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121543778A_ABST
    Figure CN121543778A_ABST
Patent Text Reader

Abstract

The invention discloses a railway train delay prediction method based on an XGBoost-LSTM fusion model. The method comprises the following steps: 1) inputting train operation historical data; 2) preprocessing the historical train operation data; 3) time feature extraction, classification feature processing and sequence feature construction are carried out; 4) dividing the processed data into a training set, a verification set and a test set according to the travel ID; 5) constructing an XGBoost model and an LSTM (Long Short Term Memory) model, finding an optimal XGBoost model parameter by utilizing Optuna Bayesian optimization, and respectively training the two models; 6) determining fusion weights of the XGBoost model and the LSTM model on the verification set, and fusing prediction results of the two models; and 7) evaluating the performance of the fusion model on the test set, and outputting a prediction result. Static features and time sequence features can be processed at the same time, a variable-length sequence is effectively processed, and prediction precision is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence and railway transportation management, and in particular to a method for predicting railway train arrival delays based on the fusion of machine learning and deep learning. Background Technology

[0002] With the increasing scale and complexity of the railway network, train operations are affected by various factors, resulting in delays and causing considerable inconvenience to railway dispatching and passenger travel. Currently, railway train delay prediction methods mainly include the following categories:

[0003] 1) Methods based on statistical models, such as time series analysis and regression models, but these methods are difficult to handle high-dimensional nonlinear relationships;

[0004] 2) Methods based on a single machine learning model, such as random forests and support vector machines, can handle nonlinear relationships, but have limited ability to capture temporal features.

[0005] 3) Deep learning-based methods, such as RNN and LSTM, can capture temporal dependencies, but they do not adequately handle static features.

[0006] Existing technologies suffer from the following main problems: First, railway operation data possesses both static and temporal characteristics, making it difficult for a single model to effectively handle both types of features; second, inconsistent train journey lengths complicate data processing, lacking an effective mechanism for handling variable-length sequences; and finally, existing models suffer accuracy loss when dealing with padded values ​​and missing data. Therefore, there is an urgent need to develop a train delay prediction method that can simultaneously handle static and temporal characteristics and effectively process variable-length sequences. Summary of the Invention

[0007] To overcome the shortcomings of existing single models that cannot effectively handle both static and temporal features and are difficult to deal with variable-length sequence data, this invention provides a railway train delay prediction method based on the XGBoost-LSTM fusion model, which can simultaneously handle both static and temporal features, effectively handle variable-length sequences, and significantly improve prediction accuracy.

[0008] The technical solution adopted by this invention to solve its technical problem is:

[0009] A railway train delay prediction method based on an XGBoost-LSTM fusion model includes the following steps:

[0010] 1) Input historical train operation data;

[0011] 2) Preprocess the train operation history data, including cleaning missing values, outlier detection and correction, and data standardization and normalization;

[0012] 3) Perform feature engineering processing, including temporal feature extraction, classification feature processing, and sequence feature construction;

[0013] 4) Divide the processed data into training set, validation set, and test set according to the trip ID;

[0014] 5) Construct XGBoost and LSTM models, use Optuna Bayesian optimization to find the optimal XGBoost model parameters, and train the two models respectively.

[0015] 6) Determine the fusion weights of the XGBoost model and the LSTM model on the validation set, and fuse the prediction results of the two models;

[0016] 7) Evaluate the performance of the fusion model on the test set and output the prediction results.

[0017] The beneficial effects of this invention are mainly reflected in:

[0018] 1. By integrating XGBoost and LSTM models, the advantages of static features and temporal features are effectively combined, significantly improving prediction accuracy;

[0019] 2. By using a method of partitioning data by trip ID, data leakage is avoided and the model's generalization ability is improved;

[0020] 3. A custom MaskedHuberLoss loss function and MaskedMeanAbsoluteError evaluation metric were introduced, which effectively handled the problems of variable-length sequences and padding values;

[0021] 4. The optimal hyperparameters for XGBoost are found through Optuna Bayesian optimization, reducing the workload of manual parameter tuning;

[0022] 5. The optimal fusion weights were found on the validation set, which further optimized the prediction performance. The final MAE on the test set reached 0.2439, which is an improvement of 4.6% and 23.5% respectively compared with the single model. Attached Figure Description

[0023] Figure 1 This is a flowchart of a railway train delay prediction method based on an XGBoost-LSTM fusion model according to the present invention.

[0024] Figure 2 XGBoost feature importance analysis plot;

[0025] Figure 3 The training history of the LSTM model is shown in the figure, where (a) is the training and validation curve of the Huber loss of the LSTM model, and (b) is the training and validation curve of the MAE of the LSTM model.

[0026] Figure 4 A time series comparison chart of the fusion model;

[0027] Figure 5 A time series comparison chart of the fusion model;

[0028] Figure 6 This is a graph showing the distribution of prediction errors for the fusion model. Detailed Implementation

[0029] The present invention will now be further described with reference to the accompanying drawings.

[0030] Reference Figures 1-6 This paper presents a railway train delay prediction method based on an XGBoost-LSTM fusion model. The railway operation data used in this example comes from passenger train operation data within a certain railway section from November 11, 2023 to December 11, 2023, for data analysis, learning, and prediction. The method includes the following steps:

[0031] 1) Input historical train operation data;

[0032] The historical operation data mainly includes 15 types of information: station sequence, station, arrival time, departure time, arriving train number, departing train number, scheduled arrival time, scheduled departure time, in-station parking track, arrival delay time, departure delay time, actual stop time, scheduled stop time, actual interval travel time and scheduled interval travel time.

[0033] Subsequent feature engineering will generate "station sequence information" (lagging, cumulative) and "line characteristics" (classification / planning) based on several fields (such as station sequence, station, track, scheduled / actual time, arrival / departure delay, section running time, etc.);

[0034] The station sequence information is based on the trip ID, and the station samples within the same trip are arranged in chronological order. The first-order lag and cumulative sequence features constructed from this are at least the arrival delay time of the previous station, the departure delay time of the previous station, the running time deviation of the previous interval, and the cumulative arrival delay time (to the previous station).

[0035] The line features are static / categorical / planned features describing the attributes of the operating line and stations, as well as the scheduled operation organization. These include at least stations, station parking tracks, station sequence, and scheduled stop minutes calculated based on scheduled timetables, scheduled interval travel time, and train type extracted from the train number field. Non-numerical features are input into the model after one-hot encoding.

[0036] 2) Data Preprocessing: The train operation data undergoes cleaning (missing values, outlier detection and correction), and data standardization and normalization. The process is as follows:

[0037] (2.1) Handling missing values ​​in business scenario awareness: For the missing values ​​of 'actual interval running time' and 'planned interval running time' in specific scenarios of the terminal station, they are uniformly filled with 0, which is in line with the railway operation rule that there is no subsequent interval running at the terminal station. This processing strategy ensures the integrity of the data structure and is consistent with the actual business logic.

[0038] (2.2) Stop time correction based on operation rules: The features of 'actual stop minutes_calculated' and 'scheduled stop minutes_calculated' are calculated by time difference. When the calculation result is less than 0 (which may be due to data recording errors or cross-day operation), the system automatically corrects it to 0, strictly following the railway operation standard that the minimum stop time of trains at stations should not be less than 0 minutes. This correction eliminates the potential interference of unreasonable data on model training and improves the business rationality of data quality.

[0039] (2.3) Multi-source coding adaptive time column standardization processing: The four key time columns, 'Arrival Time', 'Departure Time', 'Scheduled Arrival Time' and 'Scheduled Departure Time', are uniformly converted into datetime objects, and an abnormal format is handled by a forced conversion strategy (errors = 'coerce'); records containing NaT (Not a Time) values ​​after conversion are systematically filtered to ensure that subsequent analysis is based on valid time data; the system automatically calculates and records the number of invalid records filtered, providing a quantitative basis for data quality control.

[0040] 3) Three-dimensional feature engineering construction and processing, including temporal feature extraction, classification feature processing, and sequence feature construction, the process is as follows:

[0041] (3.1) Temporal feature extraction, the process is as follows:

[0042] 3.1.1) Extract the hour, day of the week, month, and day of the year features from the datetime column, denoted as t. hour ,t weekday ,t month ,t dayofyear ;

[0043] 3.1.2) Calculate the actual stop minutes and the scheduled stop minutes using the following formula:

[0044]

[0045] 3.1.3) Periodically encode the time features using the following formula:

[0046]

[0047] (3.2) Classification feature processing, the process is as follows:

[0048] 3.2.1) Extract train type: For fields containing train type information such as "departure train number" and "arrival train number", extract the first character as the "train type" feature;

[0049] 3.2.2) Retain the classification features of stations and tracks, and use OneHotEncoder to perform one-hot encoding on the non-numerical classification features of stations and tracks to generate a sparse binary feature matrix;

[0050] (3.3) Sequence feature construction, the process is as follows:

[0051] 3.3.1) Group the data by "departure train number" and "scheduled departure time" to generate "trip ID", which is a combination of train number and trip date;

[0052] 3.3.2) Sort the data by "trip ID" and "station order" to construct lag features and cumulative features:

[0053] First-order lag characteristics include the arrival delay time of the previous station, the departure delay time of the previous station, and the travel time deviation of the previous interval;

[0054] The cumulative feature is "cumulative arrival delay time_previous station". The cumulative delay time from the first station to the previous station is calculated by grouping and accumulating the arrival delay time by trip ID and shifting it forward by one position.

[0055] 3.3.3) Missing values ​​for the lag feature of the first station of the trip are filled with 0.

[0056] 4) Hierarchical data partitioning based on trip ID: A trip-level independent partitioning strategy is adopted to avoid data leakage. The data partitioning process is as follows:

[0057] (4.1) Obtain the IDs of all independent trips, each trip ID representing the complete run of a train on a specific date;

[0058] (4.2) Divide the set of trip IDs into training set, validation set, and test set IDs:

[0059] The test set ratio (e.g., 15%) and validation set ratio (e.g., 15%) are pre-defined. The system first randomly divides all trip IDs into two groups: one group is used for "training + validation" and the other group is used for "testing".

[0060] The test set comprises 15% of the total number of trip IDs, while the remaining 85% is allocated to the "training + validation" group. The system then further randomly partitions the trip IDs within the "training + validation" group.

[0061] The validation set comprised 17.65% of the "training + validation" group (equivalent to 15% of the total).

[0062] The training set comprised 82.35% of the "training + validation" group (equivalent to 70% of the total).

[0063] During the random segmentation process, a fixed random number seed (e.g., 42) is used to ensure that the same segmentation result is obtained each time the program is run, which facilitates experimental reproduction and ultimately forms three non-overlapping run ID groups: training set ID group, validation set ID group, and test set ID group.

[0064] (4.3) Separate the feature column and the target column:

[0065] The target column (arrival delay time), trip ID column, arrival train number column, and departure train number column are excluded as features. All other columns in the dataset are considered as feature columns, except for these excluded columns.

[0066] For the training set, the system extracts all feature columns to form a feature matrix X_train and extracts the target column to form a target vector y_train. The validation set and test set are processed in the same way to obtain X_val, y_val and X_test, y_test, respectively.

[0067] 5) XGBoost model construction and LSTM model construction process:

[0068] (5.1) XGBoost Model Construction and Bayesian Optimization: Construct a static feature processing model and optimize hyperparameters. The construction and training process of the XGBoost model is as follows:

[0069] (5.1.1) Use ColumnTransformer to standardize numerical features and perform one-hot encoding on categorical features. The process is as follows:

[0070] First, the original features are classified to identify numerical features (such as running time, delay time, etc.) and categorical features (such as station, train type, etc.).

[0071] For numerical features, we apply StandardScaler to perform z-score standardization, which transforms all numerical features into a distribution with a mean of 0 and a standard deviation of 1, thus solving the problem of inconsistent dimensions of different features.

[0072] For categorical features, OneHotEncoder is applied for one-hot encoding to convert text categories into binary feature vectors, enabling machine learning algorithms to process this type of data.

[0073] The system uses ColumnTransformer to combine these two transformations to build a complete feature processing pipeline, ensuring that all features receive appropriate preprocessing.

[0074] The preprocessor first fits the data to the training data, and then applies it to the training set, validation set and test set respectively to ensure the consistency of feature processing.

[0075] (5.1.2) Bayesian hyperparameter optimization is performed using Optuna, where the optimization objective is to minimize the mean absolute error (MAE) of the validation set;

[0076] (5.1.3) During the hyperparameter search process, optimize the following parameters: learning rate, maximum tree depth, subsampling rate, column sampling rate, L1 regularization term, L2 regularization term, minimum child node weight, minimum loss reduction, and number of trees. The lower bound of the encoding is [0.001, 3, 0.5, 0.5, 1e-8, 1e-8, 1, 1e-8, 100], and the upper bound of the encoding is [0.3, 10, 1.0, 1.0, 10.0, 10.0, 20, 10.0, 1500].

[0077] (5.1.4) Train the XGBoost model using the built-in early stopping mechanism for each set of parameter configurations, i.e.:

[0078] In each Optuna trial, the system constructs an XGBoost regressor based on the currently sampled hyperparameter configuration.

[0079] Set the objective function of the model to "reg:squarederror" (mean squared error regression) and the evaluation metric to "mae" (mean absolute error).

[0080] Enable XGBoost's built-in early stopping mechanism by setting early_stopping_rounds=50. This means that if the performance on the validation set does not improve after 50 consecutive iterations, the training will end early.

[0081] Fit the model on the training set while monitoring performance changes on the validation set and recording the MAE on the validation set.

[0082] After each trial, the current validation set MAE is returned to Optuna to update the probabilistic model of the hyperparameter-performance relationship.

[0083] Optuna intelligently adjusts the parameter sampling probability distribution for the next test based on historical test results, thereby improving search efficiency.

[0084] (5.1.5) Select the parameter configuration that minimizes the MAE of the validation set;

[0085] (5.1.6) Train the final XGBoost model on the merged training and validation sets using the optimal parameters.

[0086] (5.1.7) Perform XGBoost feature importance analysis: Extract and visualize feature importance scores from the finally trained model. Use a gain-based evaluation method to identify the features that have the most significant impact on the prediction results, such as... Figure 2 As shown.

[0087] (5.2) LSTM Model Construction and Dynamic Training: A time series modeling scheme adapted to variable-length sequences is designed. The process of constructing and training the LSTM model is as follows:

[0088] (5.2.1) Determine the sequence length specification: By calculating the 95th percentile value of all journey lengths in the training set, the maximum sequence length is determined to be 571, ensuring that the model covers 95% of the journey data features; the journey length is the number of data points corresponding to each journey ID.

[0089] (5.2.2) Sequence standardization:

[0090] Group the data by trip ID and extract the feature matrix and target vector for each trip.

[0091] The pad_sequences function is used to pad the feature sequence and the target sequence to a length of 571. For sequences that are not long enough, the end is padded with a feature vector with a value of 0.0 and a target scalar with a value of -999.0.

[0092] After processing, feature tensors and target tensors are formed, where the training set has shapes of (18,571,63) and (18,571,1), and the validation set and test set have shapes of (4,571,63) and (4,571,1).

[0093] (5.2.3) Mask matrix construction: For each batch of target sequences, generate a Boolean mask matrix with the same shape, where the position where the target value is not equal to -999.0 is marked as True and the position where the padding is marked as False, to distinguish between valid data and padding values.

[0094] (5.2.4) Neural Network Architecture Design:

[0095] Input layer: Define an input layer with shape (None, 571, 63) to receive batch sequence data;

[0096] Masking layer: Connects to the Masking layer, marking inputs with a value of 0.0 as padding values ​​and ignoring them;

[0097] Bidirectional LSTM layer:

[0098] The first bidirectional LSTM layer contains 128 hidden units, uses the tanh activation function, enables the return_sequences=True parameter, and outputs a feature representation with shape (None, 571, 256).

[0099] The second bidirectional LSTM layer contains 64 hidden units, also uses the tanh activation function and returns the complete sequence, with an output shape of (None, 571, 128).

[0100] Regularization layer: a dropout layer with Dropout=0.3, randomly dropping 30% of neuron connections to suppress overfitting, while maintaining the output shape as (None, 571, 128);

[0101] Output layer: The Dense layer wrapped by TimeDistributed applies a fully connected operation independently to each time step, mapping the 128-dimensional features to a single predicted value. The final output shape is (None, 571, 1).

[0102] The model has a total of 361,089 trainable parameters and a memory footprint of approximately 1.38 MB.

[0103] (5.2.5) Custom loss function and evaluation metrics:

[0104] Loss function: Define the MaskedHuberLoss class, set the padding value padding_value = -999.0 and the threshold delta = 1.0, extract valid data points through the mask matrix, calculate the Huber loss and return the average value;

[0105] Evaluation metrics: Define the MaskedMeanAbsoluteError class, which uses an accumulator to count the absolute error of valid data and returns the mean absolute error;

[0106] (5.2.6) Optimizer and training strategy configuration:

[0107] Optimizer: The Adam optimizer is used with an initial learning rate of 0.0026. The default momentum parameters beta_1 = 0.9 and beta_2 = 0.999 are maintained, and epsilon = 1e-7 is set to ensure numerical stability.

[0108] Early stopping mechanism: Use the EarlyStopping callback to monitor the validation set val_masked_mae metric. If there is no improvement after 20 consecutive epochs, stop training and restore the optimal weights.

[0109] Learning rate scheduling: The validation set val_masked_mae metric is monitored through the ReduceLROnPlateau callback. If there is no improvement after 10 consecutive epochs, the learning rate is halved, and the minimum is reduced to 1e-6.

[0110] (5.2.7) Model training and visualization of the training process:

[0111] The model is trained using the model.fit method, with batch_size=4 and epochs=150, and the validation set is used as the validation data.

[0112] The learning rate was dynamically adjusted during training, decreasing to 0.001323, 0.0006616, and 0.0003308 at the 51st, 117th, and 147th epochs, respectively.

[0113] The model weights for the 137th epoch were recovered based on the early stopping strategy, at which point the masked_mae value of the validation set reached the optimal value of 0.1936;

[0114] After training, the performance was evaluated on the test set. The test loss (masked_huber) was measured to be 0.1471 and the test MAE (masked_mae) was measured to be 0.3189. The model was then saved.

[0115] Training process visualization analysis: Construct a dual-graph training history graph. The left side shows the trend of Huber loss changes on the training and validation sets, and the right side shows the changes in the masked_mae evaluation metric, such as... Figure 3 As shown.

[0116] 6) Model fusion and determination of fusion weights: The advantages of the two types of models are integrated through a weighted averaging strategy. The process is as follows:

[0117] (6.1) Prediction results acquisition: The prediction results of the XGBoost model and the LSTM model are obtained on the validation set respectively, and the invalid data points corresponding to the padding value (-999.0) are removed by masking technology, and only the predicted values ​​and true values ​​of the valid data points are retained;

[0118] (6.2) Weight space search: Generate a set of candidate weights in the weight range [0,1] with a step size of 0.05, and traverse each weight value ω;

[0119] (6.3) Fusion Prediction Calculation: For each weight value ω, the fusion prediction result is calculated based on a linear weighting strategy, using the following formula:

[0120] y pred_fused =ω·y pred_xgb +(1-ω)y pred_lstm

[0121] Where y pred_xgb y represents the predicted value from the XGBoost model. pred_lstm y represents the predicted value from the LSTM model. pred_fused These are the predicted values ​​from the fusion model.

[0122] 7) Performance evaluation and result analysis of the fusion model.

[0123] Performance evaluation: The mean absolute error (MAE) between the fused prediction results and the true values ​​on the validation set was calculated, and the prediction bias was quantified. The performance of the final fused model (weighted average) on the test set was 0.2439, which is 4.6% and 23.5% higher than XGBoost / LSTM, respectively, with an RMSE of 0.5911.

[0124] Multidimensional Visualization Evaluation: To comprehensively showcase the predictive performance of the fusion model, the system implements three types of visualization analysis:

[0125] 7.1) Prediction Error Distribution Analysis: Calculate the absolute error between the predicted values ​​and the actual values ​​of the fusion model on the test set, statistically analyze the sample proportion within different error ranges (±1 minute, ±3 minutes, and ±5 minutes), and generate a bar chart to display the prediction accuracy, such as... Figure 4 As shown in the figure. The results show that 95.65% of the prediction errors are within ±1 minute, 99.58% are within ±3 minutes, and 99.84% are within ±5 minutes, which intuitively verifies the high accuracy of the model;

[0126] 7.2) Time Series Comparison Plot: Arrange the test set samples sequentially and plot a scatter plot comparing the actual late arrival times with the predicted values ​​of the fusion model. Blue dots represent the actual values, and red dots represent the predicted values. For example... Figure 5 As shown in the figure, this figure reveals the fit between the model predictions and the actual values ​​at different sample points. The visualization results show that the predicted points and the actual points highly overlap, especially in the [-10, 10] minute late point range where the performance is the best.

[0127] 7.3) Scatter Plot Comparison: Construct a two-dimensional scatter plot comparing the actual delay time and the predicted delay time. Add an ideal prediction line (y=x) as a baseline and use a color gradient to identify the sample sequence number, such as... Figure 6 As shown in the figure, this figure visually illustrates the trend of prediction accuracy as the delay time changes. The results show that the predicted points are mainly concentrated around the ideal line, especially in the range of [-20, 10] minutes where they almost completely overlap, with only a slight underestimation in the area of ​​larger positive delay values ​​(>15 minutes).

[0128] Through the above three visualization analyses, the system comprehensively demonstrates the predictive performance of the fusion model from different perspectives, verifies the effectiveness of the weighted average fusion strategy, and provides reliable decision support for railway operation scheduling.

[0129] The embodiments described in this specification are merely examples of implementations of the inventive concept and are for illustrative purposes only. The scope of protection of this invention should not be considered limited to the specific forms described in these embodiments; rather, it extends to equivalent technical means conceived by those skilled in the art based on the inventive concept.

Claims

1. A railway train delay prediction method based on an XGBoost-LSTM fusion model, characterized in that, The method includes the following steps: 1) Input historical train operation data, station sequence information, and line characteristics; 2) Preprocess the train operation history data, including cleaning missing values, outlier detection and correction, and data standardization and normalization; 3) Perform feature engineering processing, including temporal feature extraction, classification feature processing, and sequence feature construction; 4) Divide the processed data into training set, validation set, and test set according to the trip ID; 5) Construct XGBoost and LSTM models, use Optuna Bayesian optimization to find the optimal XGBoost model parameters, and train the two models respectively. 6) Determine the fusion weights of the XGBoost model and the LSTM model on the validation set, and fuse the prediction results of the two models; 7) Evaluate the performance of the fusion model on the test set and output the prediction results.

2. The railway train delay prediction method based on the XGBoost-LSTM fusion model as described in claim 1, characterized in that, In the first part (1), the train operation history data includes station sequence, station, arrival time, departure time, arriving train number, departing train number, scheduled arrival time, scheduled departure time, station parking track, arrival delay time, departure delay time, actual stop time, scheduled stop time, actual interval running time and scheduled interval running time.

3. The railway train delay prediction method based on the XGBoost-LSTM fusion model as described in claim 1 or 2, characterized in that, The process described in 2) is as follows: (2.1) Handling missing values ​​in business scenario awareness: For the missing values ​​of 'actual interval running time' and 'planned interval running time' in specific scenarios of the terminal station, they are uniformly filled with 0, which is in line with the railway operation rule that there is no subsequent interval running at the terminal station; (2.2) Correction of stopping time based on operating rules: The characteristics of 'actual stopping minutes_calculated' and 'scheduled stopping minutes_calculated' are calculated by time difference. When the calculation result is less than 0, it is corrected to 0, strictly following the railway operation standard that the minimum stopping time of trains at stations should not be less than 0 minutes; (2.3) Multi-source coding adaptive time column standardization processing: The four key time columns, 'arrival time', 'departure time', 'scheduled arrival time' and 'scheduled departure time', are uniformly converted into datetime objects, and a forced conversion strategy is used to handle abnormal formats; records containing NaT (Not a Time) values ​​after conversion are systematically filtered to ensure that subsequent analysis is based on valid time data.

4. The railway train delay prediction method based on the XGBoost-LSTM fusion model as described in claim 1 or 2, characterized in that, The process described in 3) is as follows: (3.1) Temporal feature extraction, the process is as follows: 3.1.1) Extract the hour, day of the week, month, and day of the year features from the datetime column, denoted as t. hour ,t weekday ,t month ,t dayofyear ; 3.1.2) Calculate the actual stop minutes and the scheduled stop minutes using the following formula: 3.1.3) Periodically encode the time features using the following formula: (3.2) Classification feature processing, the process is as follows: 3.2.1) Extract train type: For fields containing train type information such as "departure train number" and "arrival train number", extract the first character as the "train type" feature; 3.2.2) Retain the classification features of stations and tracks, and use OneHotEncoder to perform one-hot encoding on the non-numerical classification features of stations and tracks to generate a sparse binary feature matrix; (3.3) Sequence feature construction, the process is as follows: 3.3.1) Group the data by "departure train number" and "scheduled departure time" to generate "trip ID", which is composed of the train number and the trip date; 3.3.2) Sort the data by "trip ID" and "station order" to construct lag features and cumulative features: First-order lag characteristics include the arrival delay time of the previous station, the departure delay time of the previous station, and the travel time deviation of the previous interval; The cumulative feature is "cumulative arrival delay time_previous station". The cumulative delay time from the first station to the previous station is calculated by grouping the arrival delay time by trip ID, adding it up and shifting it forward by one position. 3.3.3) Missing values ​​for the lag feature of the first station of the trip are filled with 0.

5. The railway train delay prediction method based on the XGBoost-LSTM fusion model as described in claim 1 or 2, characterized in that, The process described in 4) is as follows: (4.1) Obtain the IDs of all independent trips, each trip ID representing the complete run of a train on a specific date; (4.2) Divide the set of trip IDs into training set, validation set, and test set IDs: Pre-set the test set ratio and validation set ratio. First, randomly divide all trip IDs into two groups: one group is used for "training + validation" and the other group is used for "testing". During the random segmentation process, a fixed random number seed is used to ultimately form three non-overlapping trip ID groups: training set ID group, validation set ID group, and test set ID group; (4.3) Separate the feature column and the target column: The target column, trip ID column, arrival train number column, and departure train number column are excluded as features. All other columns in the dataset are considered as feature columns. For the training set, extract all feature columns to form a feature matrix X_train, and extract the target column to form a target vector y_train. Process the validation set and test set in the same way to obtain X_val, y_val and X_test, y_test, respectively.

6. The railway train delay prediction method based on the XGBoost-LSTM fusion model as described in claim 1 or 2, characterized in that, Step 5) includes constructing a gradient boosting tree-based regression model XGBoost for static / non-sequence features and performing automated hyperparameter optimization, selecting the optimal parameter configuration based on the validation set performance index; appropriately scaling and encoding numerical and categorical features to form training inputs; obtaining a first predictor on the training data based on the optimal parameters; and evaluating the feature contribution to support result interpretation.

7. The railway train delay prediction method based on the XGBoost-LSTM fusion model as described in claim 1 or 2, characterized in that, Step 5) further includes constructing a bidirectional LSTM time series model for variable-length sequences grouped by trip ID: determining a uniform maximum sequence length based on training set statistics and padding the feature and target sequences; setting a masking mechanism in the model to ignore samples corresponding to padding values; and generating time series predictions of late arrivals through the output layer at each time step. We employ robust regression loss and absolute error metrics for training and evaluation, and optimize the training process by combining early stopping and adaptive learning rate strategies.

8. The railway train delay prediction method based on the XGBoost-LSTM fusion model as described in claim 1 or 2, characterized in that, The process described in 6) is as follows: (6.1) Prediction results acquisition: The prediction results of the XGBoost model and the LSTM model are obtained on the validation set respectively, and the invalid data points corresponding to the padding value (-999.0) are removed by masking technology, and only the predicted values ​​and true values ​​of the valid data points are retained; (6.2) Weight space search: Generate a set of candidate weights in the weight range [0,1] with a step size of 0.05, and traverse each weight value ω; (6.3) Fusion Prediction Calculation: For each weight value ω, the fusion prediction result is calculated based on a linear weighting strategy, using the following formula: y pred_fused =ω·y pred_xgb +(1-ω)y pred_lstm Where y pred_xgb y represents the predicted value from the XGBoost model. pred_lstm y represents the predicted value from the LSTM model. pred_fused These are the predicted values ​​from the fusion model.

9. The railway train delay prediction method based on the XGBoost-LSTM fusion model as described in claim 1 or 2, characterized in that, The process described in 7) is as follows: Performance evaluation: Calculate the mean absolute error (MAE) between the fused prediction results and the true values ​​on the validation set, and quantify the prediction bias; The multidimensional visualization evaluation is as follows: 7.1) Prediction error distribution analysis: Calculate the absolute error between the predicted value and the true value of the fusion model on the test set, count the sample proportion in different error ranges, and generate a bar chart to show the prediction accuracy. 7.2) Time series comparison chart: Arrange the test set samples in sequence and draw a scatter plot comparing the actual late arrival times with the predicted values ​​of the fusion model; 7.3) Scatter Plot Comparison: Construct a two-dimensional scatter plot of the actual delay time and the predicted delay time, add an ideal prediction line as a baseline, and use a color gradient to identify the sample sequence number.