A method for spatiotemporal gradient boosting decision trees
By embedding spatiotemporal information in the GBDT algorithm, a spatiotemporal gradient enhancement decision tree (ST-GBDT) model is constructed, which solves the problem of insufficient embedding of spatiotemporal information in the existing technology, and significantly improves the prediction performance of standardized precipitation evaporation exudation index.
Patent Information
- Application Number
- CN202111326449.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-10
- Publication Date
- 2024-11-22
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing GBDT algorithms are difficult to effectively embed spatiotemporal information in geospatial information processing, resulting in limited model prediction performance.
A spatial-temporal gradient enhancement decision tree (ST-GBDT) method is proposed. By combining time and space information, using Python's scikit-learn library to develop models, and using spatio-temporal features and meteorological data to build prediction models, including data preprocessing, model construction and verify.
By adding spatiotemporal information characteristics, the prediction accuracy and stability of the model are improved, and the prediction effect of the standardized precipitation evaporation and sparse index (SPEI) is improved, which performs better than the traditional GBDT model.
Smart Images

Figure CN114169520B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of geospatial information processing technology, and in particular to a method for spatiotemporal gradient boosting decision tree. Background Art
[0002] The GBDT (Gradient Boosted Decision Tree) algorithm is a combination of decision trees and ensemble learning techniques, which aims to improve the performance of a single prediction model by combining multiple models. The GBDT algorithm uses two processes: boosting and classification. It can correct the training results through regularization functions to reduce the degree of overfitting. Decision trees are easy for researchers to understand and implement. These trees can handle missing features well because each node of the decision tree depends on only one feature. Boosting is a method to improve the performance of GBDT by constructing a prediction function sequence group that converts several weak learning classifiers into a high-precision strong learning classifier, but it has some disadvantages:
[0003] Although the GBDT algorithm has good effects in some areas of geospatial information processing, the model cannot embed spatiotemporal information into the model. Summary of the invention
[0004] The purpose of the present invention is to provide a method for spatiotemporal gradient boosting decision tree, so as to achieve the effect of developing a ST-GBDT using temporal and spatial information by using the scikit-learn class library in Python language.
[0005] To achieve the above object, the present invention provides the following technical solution: a method for spatiotemporal gradient boosting decision tree, which is divided into the SPEI prediction method of standardized precipitation evapotranspiration index, comprising the following steps:
[0006] Step 1: Target data acquisition: filter the original data to obtain the data of the meteorological stations in the target area;
[0007] Step 2: Use Python to perform linear processing on unnecessary feature data in the data and noise data in the remaining data to improve data integrity;
[0008] Step 3: Calculate the processed meteorological data and convert the daily data into the required monthly average data;
[0009] Step 4: Obtaining spatiotemporal information based on the time attribute information and space attribute information of the site;
[0010] Step 5: Calculate monthly SPEI data using the latitude of the meteorological station, monthly average temperature and monthly average precipitation;
[0011] Step 6: ST-GBDT model construction and prediction.
[0012] Preferably, in step 1, the stations in the target area are first extracted, the daily data set of China's ground climate data is screened using Python's pandas library, and the corresponding data is screened out using the characteristic value of the station number.
[0013] Preferably, in the step 2, multiple meteorological data in the daily value data set of China's ground climate data do not need to be used, the SPEI value is calculated by three characteristic values of temperature, precipitation and latitude, and other meteorological features except temperature and precipitation are deleted, and the two meteorological data of temperature and precipitation are retained. The data contains noise data, which is generated due to lack of observation tasks and other reasons. The noise data is linearly processed by using the pandas library in Python.
[0014] Preferably, in step three, the date data in the data set is converted into dataframe data through Python's pandas library, and then the monthly average value of the data is calculated.
[0015] Preferably, in step 4, for a given site, its spatial (Ds) and temporal (Dt) characteristics can be expressed as the following formula:
[0016]
[0017] The ds and dt represent the temporal and spatial distances, and M and N represent the m stations near the station and the previous n months of the same station, respectively.
[0018] Preferably, in step 5, the monthly average meteorological data and latitude data of a given site are calculated by the ClimateIndices library in Python to obtain SPEI data, and then the outliers in the results are processed. In step 6, the overall process of the proposed prediction method includes the following steps:
[0019] A. Data preprocessing;
[0020] B. ST-GBDT model construction;
[0021] C. ST-GBDT model prediction;
[0022] D. Verification and analysis.
[0023] Preferably, in step A, the data of step three, step four and step five are combined and processed by the following formula, and the time characteristics, spatial characteristics, latitude, temperature and precipitation are used as variables to predict SPEI, and the combination method is SPEI=f(lat, pre, tas, Ds, Dt), wherein lat represents the latitude of the site, pre represents the monthly precipitation average, tas represents the monthly temperature average, Ds represents the spatial characteristics, Dt represents the time characteristics, and f is a function obtained by ST-GBDT model training.
[0024] Preferably, in step B, the GBDT is composed of multiple decision trees, and the outputs of all decision trees are accumulated to be the output of GBDT. The learning content of each decision tree of GBDT is the residual of the sum of the outputs of all previous decision trees, and the residual value is the cumulative amount of the true value plus the predicted value. The GBDT is a strong learner composed of multiple CART decision trees as weak learners, and is a strong learner formed by continuous iteration of CART decision trees. The GBDT adds spatiotemporal information to form ST-GBDT, so that ST-GBDT can utilize the synergy of ensemble regression method and spatiotemporal information; the regularization of the ST-GBDT is mainly processed by controlling the learning rate, subsampling ratio and pruning the CART decision tree. The model tests multiple parameters in the training data import algorithm, and finally obtains the optimized model. The grid search in Python's scikit-learn library is used to adjust these parameters, that is, the machine is allowed to automatically traverse and cross-validate according to the given model parameters, and the selection of parameters is determined by tracking the scoring results. In the ST-GBDT model, like traditional machine learning methods, such as GBDT, there are seven important parameters that need to be adjusted:
[0025] (1) The maximum number of weak learners;
[0026] (2) The weight reduction factor of each weak learner;
[0027] (3) Maximum depth of the decision tree;
[0028] (4) Minimum number of samples for leaf nodes;
[0029] (5) The minimum number of samples that need to be divided for an internal node;
[0030] (6) Maximum number of features during partitioning;
[0031] (7) The sampling rate of the training set.
[0032] Preferably, in step C, the ST-GBDT model is trained by putting the processed data set into the training set and testing the training results, and the data set is divided into a training set and a test set, wherein the ratio of the training set to the test set is 8 to 2, i.e., eighty percent of the data set is used as the training set and twenty percent as the test set. The model is trained with the training set to fit a function, and then the training results of the model are tested with the test set.
[0033] Preferably, the verification and analysis method is a statistical method, by selecting the coefficient of determination (R2), mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE) and mean absolute percentage error (MAPE), to evaluate the performance of prediction using the proposed method, and by comparing the training results of ordinary GBDT and ST-GBDT.
[0034] Compared with the prior art, the invention has the following beneficial effects: the method of spatiotemporal gradient boosting decision tree:
[0035] It is possible to combine spatiotemporal information with GBDT to add spatiotemporal information to the input exploration variables and increase the characteristics of the input variables. It has achieved the development and implementation in Python language using the scikit-learn library to develop a ST-GBDT that utilizes time and space information. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a schematic diagram of the working process of the present invention;
[0037] Figure 2 This is a schematic diagram of the daily value dataset of China's surface climate data V3.0 of the present invention;
[0038] Figure 3 This is a schematic diagram of site selection in the Huanghuaihai region of the present invention;
[0039] Figure 4 This is a schematic diagram of the average data of the temperature and precipitation month of the present invention;
[0040] Figure 5 This is a schematic diagram of the spatiotemporal characteristic data of the present invention;
[0041] Figure 6 It is a schematic diagram comparing the ordinary GBDT of the present invention and the ST-GBDT. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] See also Figure 1-6 The present invention provides a technical solution: a method for spatiotemporal gradient boosting decision tree, which is divided into the SPEI prediction method of the standardized precipitation evapotranspiration index, including the following embodiments:
[0044] according to Figure 1 The data of meteorological stations in the plains from January 2001 to December 2020 in the daily value dataset of China's surface climate data are processed, including the following steps:
[0045] 1. Obtaining the original data: Filter the original data to obtain the data of the meteorological stations in the target area. First, extract the stations in the target area, use Python's pandas library to filter the daily value dataset of China's ground climate data, and filter out the corresponding data through the characteristic value of the station number.
[0046] Download the daily data set of China's surface climate data (V3.0) from the China Meteorological Data Network (http: / / data.cma.cn / data / weatherBk.html). Figure 2 As shown in the figure, the data sources of this dataset are as follows: the data from 1951 to 2010 in the dataset are developed based on the "Basic Data Set of Monthly Data Files (A0 / A1 / A) Corrected for National Ground Station Data from 1951 to 2010" archived by the Ground Basic Meteorological Data Construction Project; the data from January 2011 to May 2012 are developed based on the ground monthly data files (A files) reported by various provinces to the National Meteorological Information Center; the data from June to July 2012 are developed based on the real-time database data of the National Meteorological Information Center. This part of the data in the real-time database comes from the hourly data files (Z files) and daily data files of the ground automatic stations uploaded in real time.
[0047] 2. Data screening: Use Python to perform linear processing on unnecessary feature data in the data and noise data in the remaining data to improve data integrity. In step 2, multiple meteorological data in the daily value dataset of China's ground climate data do not need to be used. The SPEI value is calculated through three characteristic values of temperature, precipitation and latitude. Other meteorological features except temperature and precipitation are deleted, and the two meteorological data of temperature and precipitation are retained. The data contains noise data due to lack of observation tasks and other reasons. The noise data is linearly processed by using the pandas library in Python.
[0048] Unzip and open the downloaded China Surface Climate Dataset, and filter the files according to the required year and meteorological data. The filtered station locations are as follows: Figure 3 As shown; extract the precipitation and temperature data from January 2001 to December 2020 and put them in the same folder, then use Python to batch read the TXT file, use the numpy library to convert the read data into array type data, and then use the functions in numpy to splice and delete the data, delete duplicate data, and splice daily data in time series;
[0049] 3. Process the noise data, calculate the processed meteorological data, and convert the daily data into the required monthly average data. In step 3, the date data in the data set is converted into dataframe data through Python's pandas library, and then the monthly average value of the data is calculated.
[0050] According to the data obtained in step 2, the noise is processed, and the data is converted into DataFrame type data using the pandas library in Python, and the feature name is added. According to the description of precipitation data in the data specification: precipitation 32700 means "trace" precipitation; 32XXX, XXX is pure fog, dew and frost; 31XXX, XXX is the total amount of rain and snow; 30XXX, XXX is the amount of snow (only including sleet and snowstorms), the data is processed and converted into null values so that it can be filled using the linear interpolation method in the interpolate function. The noise in the data is within the interpolation interval, so the interpolation method is used to process the data.
[0051] Fourth, calculate the monthly average meteorological data, and obtain spatiotemporal information based on the time attribute information and spatial attribute information of the station. In step 4, for a given station, its spatial (Ds) and temporal (Dt) characteristics can be expressed as follows:
[0052]
[0053] The ds and dt represent the temporal and spatial distances, and M and N represent the m stations near the station and the previous n months of the same station, respectively.
[0054] Using the pandas library in Python, since the data itself contains time information, we can use the datatime function in the library to convert the time information into pandas time series data. Then, we use the groupby function to group each site to prevent different sites from affecting each other. Then, we use the mean function to calculate the average monthly data of each site and merge the calculated data to obtain complete data, such as Figure 4 shown.
[0055] 5. Obtain spatiotemporal characteristics and SPEI data, and calculate monthly SPEI data using the latitude of the meteorological station, the monthly average temperature and the monthly average precipitation. Step 5 uses the ClimateIndices library in Python to calculate the monthly average meteorological data and latitude data of the given station to obtain SPEI data, and then process the outliers in the results.
[0056] According to the data obtained in step 4, the distances to the 15 nearest stations of each station are calculated, and the 15 nearest adjacent stations are weighted by distance weighting to obtain spatial feature data; the time difference of the meteorological data measurement values of the 15 nearest adjacent stations in the past 12 months is used to weight the time feature data, such as Figure 5 shown.
[0057] At the same time, according to the data obtained in step 4, the ClimateIndices library in Python is used to calculate the latitude, monthly average temperature and monthly average precipitation data to obtain the SPEI data, and then the linear interpolation method of the interpolate function in the pandas library is used to process the outliers. The obtained SPEI value is as follows: Figure 6 shown.
[0058] VI.,ST-GBDT Model Construction and Prediction,In step six, the overall process of the proposed prediction,method includes the following steps:
[0059] A. Data preprocessing;
[0060] B. ST-GBDT model construction;
[0061] C. ST-GBDT model prediction;
[0062] D. Verification and analysis.
[0063] The data obtained in step five is processed by combining the following formula, adding time features and spatial features to the variables to enrich the variable information of the data.
[0064] SPEI=f(lat,pre,tas,Ps,Pt)
[0065] ST-GBDT is composed of multiple decision trees, and the output of all decision trees is the output of GBDT after accumulation. The central idea of GBDT is that the learning content of each decision tree is the residual of the sum of the outputs of all previous decision trees, and the residual value is the accumulation of the true value plus the predicted value. GBDT is a strong learner composed of multiple CART decision trees as weak learners, and is a strong learner formed by the continuous iteration of CART decision trees. Adding spatiotemporal information to GBDT to form ST-GBDT can make ST-GBDT more robust, and at the same time, it can use the synergy of ensemble regression methods and spatiotemporal information to improve prediction capabilities.
[0066] The settings of the parameters in the model are:
[0067] learning_rate = 0.1;
[0068] n_estimators = 450;
[0069] min_samples_leaf = 50;
[0070] min_samples_split = 2;
[0071] max_features=45;
[0072] subsample=0.9;
[0073] random_state=2218.
[0074] VII. Accuracy Verification and Analysis
[0075] According to a variety of popular statistical methods, the coefficient of determination (R2), mean square error (MSE), root mean square error (RMSE) and mean absolute error (MAE) are selected to evaluate the performance of prediction using the proposed method and compared with the ordinary GBDT. Figure 6 Shown
[0076] The ST-GBDT results are:
[0077] Test set R^2 = 0.5389;
[0078] MSE = 1.3660;
[0079] RMSE = 1.1687;
[0080] MAE = 0.4964;
[0081] In comparison, the model evaluation of ordinary GBDT is:
[0082] Test set R^2 = 0.4991;
[0083] MSE = 1.4138;
[0084] RMSE = 1.1890;
[0085] MAE=0.5264.
[0086] Working principle: When using the spatiotemporal gradient boosting decision tree method, the spatiotemporal information added to the GBDT algorithm is combined into ST-GBDT, which not only utilizes the rich information conveyed in the input variables, but also benefits from extracting geospatial information weighted by the distance between adjacent sites and the central site, as well as the time difference measured with ground meteorological data, increasing the characteristics of the input variables and improving the stability and accuracy of the model's prediction ability. Afterwards, the area to be predicted is gridded, and the SPEI can be predicted through the meteorological site data and the latitude information of the grid center point, increasing the overall practicality.
[0087] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for spatiotemporal gradient boosting decision tree, characterized in that The SPEI prediction method based on the standardized precipitation evapotranspiration index is divided into the following steps: Step 1: Target data acquisition: filter the original data to obtain the data of the meteorological stations in the target area; Step 2: Use Python to perform linear processing on unnecessary feature data in the data and noise data in the remaining data to improve data integrity; Step 3: Calculate the processed meteorological data and convert the daily data into the required monthly average data; Step 4: Obtaining spatiotemporal information based on the time attribute information and space attribute information of the site; Step 5: Calculate monthly SPEI data using the latitude of the meteorological station, monthly average temperature and monthly average precipitation; Step 6: ST-GBDT model construction and prediction: Integrate the acquired temporal attribute information and spatial attribute information of the site into the ST-GBDT model to carry out model construction and prediction; In step 5, the monthly average meteorological data and latitude data of a given station are calculated by using the Climate Indices library in Python to obtain SPEI data, and then the abnormal values in the results are processed. In step 6, the overall process of the proposed prediction method includes the following steps: A. Data preprocessing; B. ST-GBDT model construction; C. ST-GBDT model prediction; D. Verification and analysis; In the step A, the data of step three, step four and step five are combined and processed by the following formula, and the time characteristics, spatial characteristics, latitude, temperature and precipitation are used as variables to predict SPEI, and the combination method is SPEI=f(lat, pre, tas, Ds, Dt), wherein lat represents the latitude of the site, pre represents the monthly precipitation average, tas represents the monthly temperature average, Ds represents the spatial characteristics, Dt represents the time characteristics, and f is a function obtained by ST-GBDT model training; In step B, the GBDT is composed of multiple decision trees, and the outputs of all decision trees are accumulated to be the output of GBDT. The learning content of each decision tree of GBDT is the residual of the sum of the outputs of all previous decision trees, and the residual value is the cumulative amount of the true value plus the predicted value. The GBDT is a strong learner composed of multiple CART decision trees as weak learners, and is a strong learner formed by continuous iteration of CART decision trees. The GBDT adds spatiotemporal information to form ST-GBDT, so that ST-GBDT can utilize the synergy of ensemble regression method and spatiotemporal information; the regularization of the ST-GBDT is mainly processed by controlling the learning rate, subsampling ratio and pruning the CART decision tree. The model tests multiple parameters in the training data import algorithm, and finally obtains the optimized model. The grid search in the scikit-learn library of Python is used to adjust these parameters, that is, the machine is allowed to automatically traverse and cross-validate according to the given model parameters, and the selection of parameters is determined by tracking the scoring results. In the ST-GBDT model, there are seven important parameters that need to be adjusted: (1) The maximum number of weak learners; (2) The weight reduction factor of each weak learner; (3) Maximum depth of the decision tree; (4) Minimum number of samples for leaf nodes; (5) The minimum number of samples that need to be divided for an internal node; (6) Maximum number of features during partitioning; (7) The sampling rate of the training set; In step C, the ST-GBDT model is trained by putting the processed data set into the model and testing the training results. The data set is divided into a training set and a test set, wherein the ratio of the training set to the test set is 8 to 2, i.e., eighty percent of the data set is used as the training set and twenty percent as the test set. The model is trained with the training set to fit a function, and then the training results of the model are tested with the test set.
2. The method of spatiotemporal gradient boosting decision tree according to claim 1, characterized in that: In the step 1, the stations in the target area are first extracted, and the daily data set of China's ground climate data is screened using the Python pandas library, and the corresponding data is screened out using the characteristic value of the station number.
3. The method of a spatiotemporal gradient boosting decision tree according to claim 1, characterized in that: In the step 2, multiple meteorological data in the daily value dataset of China's ground climate data do not need to be used. The SPEI value is calculated through the three characteristic values of temperature, precipitation and latitude. Other meteorological features except temperature and precipitation are deleted, and the two meteorological data of temperature and precipitation are retained. The data contains noise data, which is linearly processed by using the pandas library in Python.
4. The method of spatiotemporal gradient boosting decision tree according to claim 1, characterized in that: In step three, the date data in the data set is converted into dataframe data through Python's pandas library, and then the monthly average value of the data is calculated.
5. The method of spatiotemporal gradient boosting decision tree according to claim 1, characterized in that: In step 4, for a given site, its spatial (Ds) and temporal (Dt) characteristics can be expressed as follows: ; ; M and N represent the m sites near the site and the previous n months at the same site, respectively.
6. The method of spatiotemporal gradient boosting decision tree according to claim 1, characterized in that: The statistical method of verification and analysis is used to evaluate the performance of prediction using the proposed method by selecting the coefficient of determination (R2), mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE) and mean absolute percentage error (MAPE), and the evaluation is performed by comparing the training results of ordinary GBDT and ST-GBDT.
