WO2021203980A1 - Meteorological event prediction method and apparatus, and related device - Google Patents

Meteorological event prediction method and apparatus, and related device Download PDF

Info

Publication number
WO2021203980A1
WO2021203980A1 PCT/CN2021/083026 CN2021083026W WO2021203980A1 WO 2021203980 A1 WO2021203980 A1 WO 2021203980A1 CN 2021083026 W CN2021083026 W CN 2021083026W WO 2021203980 A1 WO2021203980 A1 WO 2021203980A1
Authority
WO
WIPO (PCT)
Prior art keywords
sample
terminal
aggregated
model
hash table
Prior art date
Application number
PCT/CN2021/083026
Other languages
French (fr)
Chinese (zh)
Inventor
王健宗
李泽远
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021203980A1 publication Critical patent/WO2021203980A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/04Forecasting or optimisation specially adapted for administrative or management purposes, e.g. linear programming or "cutting stock problem"
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • G06N20/20Ensemble learning
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02ATECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE
    • Y02A90/00Technologies having an indirect contribution to adaptation to climate change
    • Y02A90/10Information and communication technologies [ICT] supporting adaptation to climate change, e.g. for weather forecasting or climate simulation

Definitions

  • This application relates to the technical field of big data processing, and in particular to a method, device and related equipment for predicting meteorological events.
  • weather forecasting methods mainly include traditional statistical methods such as regression models and autoregressive moving average models, and artificial neural networks, support vector machines, regression trees and other artificial intelligence models.
  • the existing researches are all aimed at centralized training models, that is, the models are trained after uploading all the data of each meteorological station to the central server.
  • the meteorological stations are widely distributed, the number is large, and the time is long. Monitoring, the amount of data is very large, and the meteorological data of different provinces involves confidentiality issues. Only using the centralized training mode to train the model often fails to meet people's expectations. The training process is very weak and will inevitably lead to inefficient calculations. Too broad and insufficient performance.
  • the embodiments of the present application provide a method for predicting meteorological events, which can solve the problems of data privacy protection between meteorological data and the problems of low computational efficiency, over-extensiveness, and insufficient performance of models.
  • this application provides a method for predicting meteorological events.
  • the method for predicting meteorological items is applied to a meteorological forecasting system.
  • the meteorological forecasting system includes a first terminal located at a first weather station and a second terminal located at a second weather station.
  • the method includes: the first terminal calculates the first step set and the second step set of the loss function of the model to be trained according to each sample in the first sample set, wherein one gradient in the first step set The value is calculated based on a sample in the first sample set, and a gradient value in the second gradient set is calculated based on a sample in the first sample set, and the first sample set is the first weather
  • the collection of samples collected by the station the first terminal receives the aggregated first-order degree set and the aggregated second-order degree set calculated according to the second sample set sent by the second terminal, and the second sample set includes the same as the first Samples in the sample set that are similar to each sample;
  • a sample set is used to train the model to be trained to obtain a trained model; the first terminal predicts the sample to be predicted based on the trained model, and determines the prediction result of the sample to be predicted.
  • this application provides a method for predicting meteorological events.
  • the method for predicting meteorological items is applied to a meteorological forecasting system.
  • the meteorological forecasting system includes a first terminal at a first weather station and a second terminal at a second weather station.
  • the method includes: the second terminal sends a second hash table to the first terminal, the second hash table including an identifier corresponding to each sample in the third sample set and each sample Corresponding to the hash value, the third sample set is the sample collected by the second weather station; the second terminal receives the sample identification set sent by the first terminal, and each sample identification in the sample identification set Indicates a sample in the third sample set; the second terminal determines a second sample set in the third sample set according to the sample identification set, and calculates the second sample set according to each sample in the second sample set Aggregate the first-order degree set and the aggregated second-order degree set of the loss function of the model to be trained, and send the aggregated first-order degree set and the aggregated second-order degree set to the first terminal.
  • the present application provides a meteorological event prediction device.
  • the device includes: a processing unit for calculating the first step set and the second step set of the loss function of the model to be trained based on each sample in the first sample set Degree set, wherein a gradient value in the first step degree set is calculated based on a sample in the first sample set, and a gradient value in the second step degree set is calculated based on a sample in the first sample set Obtained, the first sample set is a set of samples collected by the first weather station; the receiving unit is configured to receive the aggregated first degree set and aggregated second degree set calculated from the second sample set sent by the second terminal The second sample set includes samples that are similar to each sample in the first sample set; the processing unit is further configured to: The two-level degree set, the aggregated two-level degree set, and the first sample set are trained on the model to be trained to obtain a trained model; based on the trained model, predict the sample to be predicted, Determine the prediction result of the sample to be predicted; or, the device includes:
  • the present application provides a computer device that includes a processor and a memory, the memory is used to store instructions, the processor is used to execute the instructions, and when the processor executes the instructions , Execute the following method: according to each sample in the first sample set, calculate the first step set and the second step set of the loss function of the model to be trained, wherein a gradient value in the first step set is based on the first A sample in the sample set is calculated, a gradient value in the second gradient set is calculated based on a sample in the first sample set, and the first sample set is the sample collected by the first weather station A set; receiving an aggregated first-order degree set and an aggregated second-order degree set calculated according to a second sample set sent by the second terminal, the second sample set including samples similar to each sample in the first sample set; Training the model to be trained according to the first step degree set, the aggregate first step degree set, the second step degree set, the aggregate second step degree set, and the first sample set to obtain training Good model; based on the trained model, predict
  • the third sample set is The sample collected by the second weather station; receiving the sample identification set sent by the first terminal, each sample identification in the identification set indicates a sample in the third sample set; according to the sample identification set in the In the third sample set, a second sample set is determined, and according to each sample in the second sample set, the aggregated first degree set and aggregated second degree set of the loss function of the model to be trained are calculated, and the aggregated The first-order degree set and the aggregated second-order degree set are sent to the first terminal.
  • the present application provides a computer-readable storage medium storing a computer program, and the computer program is executed by a processor to implement the following method: according to each sample in the first sample set Calculate the first step set and the second step set of the loss function of the model to be trained, wherein a gradient value in the first step set is calculated based on a sample in the first sample set, and the second step set A gradient value in the set is calculated based on a sample in the first sample set.
  • the first sample set is a set of samples collected by the first weather station; receiving the second terminal sent and calculated based on the second sample set Aggregating a first degree set and an aggregate second degree set, the second sample set includes samples similar to each sample in the first sample set; according to the first degree set and the aggregate first degree set ,
  • the two-level degree set, the aggregated two-level degree set, and the first sample set are trained on the model to be trained to obtain a trained model; based on the trained model, a sample to be predicted Make a prediction to determine the prediction result of the sample to be predicted; or,
  • the third sample set is The sample collected by the second weather station; receiving the sample identification set sent by the first terminal, each sample identification in the identification set indicates a sample in the third sample set; according to the sample identification set in the In the third sample set, a second sample set is determined, and according to each sample in the second sample set, the aggregated first degree set and aggregated second degree set of the loss function of the model to be trained are calculated, and the aggregated The first-order degree set and the aggregated second-order degree set are sent to the first terminal.
  • the first terminal of the first weather station uses the gradient set calculated by the first sample and the gradient set calculated by the second sample of the second terminal to train the model, where the second sample is the second weather
  • the samples of the station and the first weather station are similar, it can be seen that the local data and the data similar to other weather stations are used as the training parameters of the model, and the data and resources are rationally used to make the prediction results of the model more accurate; and the first terminal What is received is the gradient value of the sample of the second terminal.
  • This method does not involve the central server.
  • the terminals of each weather station do not need to upload the data to the central server, which avoids the problem of data privacy leakage; this method can also be applied to multiple applications at the same time.
  • each weather station can cooperate and train the model for each weather station in parallel, which effectively improves the calculation efficiency of the model.
  • FIG. 1 is a schematic diagram of the overall flow of a method for predicting a meteorological event provided by an embodiment of this application;
  • Figure 2 is a sample data structure of a data terminal provided in an embodiment of the application.
  • FIG. 3 is a schematic flowchart of a model training process provided in an embodiment of this application.
  • FIG. 4 is a schematic diagram of a data structure obtained by encrypting sample data of a data terminal provided in an embodiment of the application
  • FIG. 5 is a schematic diagram of a data structure of a sample identification set determined by a data terminal according to a hash table according to an embodiment of the application;
  • Fig. 6 is a schematic structural diagram of a meteorological event prediction device provided in an embodiment of the application.
  • FIG. 7 is a schematic structural diagram of a computer device provided in an embodiment of this application.
  • the technical solution of this application may involve the field of artificial intelligence and/or big data technology to realize event prediction and promote the construction of smart cities.
  • the data involved in this application such as samples and/or prediction results, can be stored in a database, or can be stored in a blockchain, which is not limited in this application.
  • the traditional method is often to upload the data of multiple participants to a central server, train the model through the central server, and then send the trained model to the participants for use Participants make predictions about related events.
  • this method can use all participants' data for model training, so that the trained model is suitable for the data prediction of each participant, the method has low computational efficiency, the model is too broad, and there is a problem of privacy leakage.
  • this application provides a method for predicting meteorological events, which combines the characteristics of federated learning technology and uses the XGBOOST model to train the model.
  • Each weather station does not need to upload data to the central server to share data.
  • Each weather station locally trains a model for local samples, and also uses similar samples from other weather stations for local model training, where similar samples refer to collections from other weather stations Among the samples in the sample, the local model is trained by receiving the aggregate gradient value of similar samples from other weather stations, which avoids the problem of data privacy leakage.
  • Each weather station synchronizes and parallel trains the model for each weather station, which effectively improves The calculation efficiency of the model and the accuracy of the model are improved.
  • Figure 1 shows a schematic diagram of the overall process of the meteorological event prediction method.
  • the overall process of predicting a meteorological event includes the following steps:
  • the early data refers to the early meteorological data.
  • a certain meteorological data points out that when the temperature is 29°C, the humidity is 73%, the wind speed is 27 km/h, and the pressure is 1009 hPa, the meteorological data in a certain place
  • the condition is light rain
  • temperature, humidity, wind speed, and air pressure are the sample feature sets of the meteorological event
  • light rain is the sample label of the meteorological event.
  • the sample feature set and sample label of the meteorological event constitute a meteorological event sample.
  • the model used for model training is the XGBOOST model.
  • the process of model training is the process of constructing regression trees, that is, constantly adding regression trees, that is, learning a new function f(t) to fit the residuals predicted by the previously trained t-1 tree.
  • the final trained model can input the sample feature set of the meteorological event into the trained model when the feature set of each meteorological sample (temperature, humidity, wind speed, air pressure, etc.) is known without knowing the meteorological event.
  • the meteorological result of the meteorological event is predicted.
  • the sample feature set of the meteorological event is input into the trained model, and a sample feature of the sample feature set will correspond to a leaf node in a tree.
  • the sum of the weights of the leaf nodes obtained from each tree is used as the predicted value of the meteorological event.
  • the sample feature set in the meteorological data may include other meteorological features except temperature, humidity, wind speed, air pressure, etc.
  • the embodiment of the present application does not limit the sample feature set, and the meteorological conditions may be wind, cloud, etc.
  • the number of sample labels corresponding to a certain meteorological condition is also not limited.
  • the meteorological event prediction method provided in the embodiments of the present application is applied to a meteorological prediction system, where the meteorological prediction system includes data terminals of multiple weather stations, and each weather station is trained in parallel and synchronized.
  • the process of model training is the same, and the data is not shared.
  • On the basis of joint training When each weather station trains the local XGBOOST model, not only the local sample data is used, but also the data similar to the local sample data of other weather stations.
  • This method can realize joint training without leaking the sample data of each weather station, and solves the problem of data privacy leakage between weather station data.
  • Using local samples and similar samples from other weather stations to train the model can make the model more accurate.
  • the data and resources are used rationally, and the weather stations synchronize and train the model, which effectively improves the calculation efficiency of the model.
  • the following takes a single weather station as an example to introduce the model training method provided in the application embodiment.
  • Embodiments of the present application relates to the model training between the plurality of weather stations, each for its own weather station meteorological data exists, then, P i represents the i Station, i ⁇ (1,2,3, ...., M), M is the number of weather stations, Q represents the samples of data samples P i of the i-th weather, q ⁇ (1,2,3, ......, N i), N i is the number of samples P i of the i-th Station, sample data Include sample feature set And sample label Sample feature set Sample Station P q i represents the i corresponding feature set (temperature, humidity, wind speed, pressure and other meteorological data), wherein the sample feature set T is the number of sample features, sample label Q represents sample i of the i-th Station P samples corresponding tag (no rain, drizzle, rain, heavy rain, heavy rain), wherein 0 means no rain, 1 means light rain, 2 means moderate rain, 3 means heavy rain, and 4 means heavy rain. Station P of the i I i i of the sample set can be expressed as
  • the naming method of the sample identification corresponding to the sample data is not limited, and each weather station can confirm the identification of each sample by itself, or be uniformly determined by all weather stations participating in the model training.
  • Fig. 2 shows a sample data structure of a data terminal provided in an embodiment of the present application.
  • the sample data table of P 1 , I 1 represents the first sample set of the first weather station P 1
  • sample The sample ID is 1
  • sample data The sample ID is 2
  • sample Sample feature set Include sample characteristics
  • the sample label corresponding to this sample is In the table shown in Fig.
  • the row corresponding to the sample ID of 1 is the sample data of the first weather station P 1 sample 1, and the sample data includes sample characteristics
  • the value is 12, the sample feature The value is 17, the sample feature The value of is 10,..., the sample feature The value is 54, the sample label If the value is 0, the sample ID is 2 and the row corresponds to the sample data of the meteorological station P 1 sample 2, and so on.
  • FIG. 3 shows a schematic flowchart of a model training process provided in an embodiment of the present application. Since each of the same weather model training process, so FIG. 3 shows only the first weather model training process P 1 a first terminal, it should be understood that, when there are M meteorological stations simultaneously training model, the The second weather station P 2 to the M -th weather station P M, the M-1 weather station , is also training the model locally during the model training of the first weather station P 1 , and the model training process is the same as that of the first weather station P The model training process of 1 is the same.
  • the first terminal converts each sample in the first sample set into a hash value to obtain a first hash table corresponding to the first sample set.
  • the first sample set I 1 is a collection of samples collected by the first weather station P 1 , which includes N 1 sample data, each sample includes a sample feature set and a sample label, and the sample feature set includes temperature, humidity, wind speed, and air pressure ,
  • the sample label indicates the weather conditions.
  • the data needs to be encrypted.
  • a is a d-dimensional random vector
  • v is d-dimensional sample data
  • b is a random value on [0,1]
  • the random number is set by each weather station.
  • FIG. 4 shows a schematic diagram of a data structure obtained after encryption of a sample set of a data terminal provided in an embodiment of the present application.
  • the data structure diagram of the encrypted sample set of the first weather station P 1 is shown in Fig. 4, and the sample data of the first weather station P 1 After hash function processing, L hash functions will be generated sample After hash function processing, L hash functions will be generated
  • the first weather station P 1 has a total of N 1 samples, and the weather station P 1 obtains a first hash table of N 1 *L.
  • the second terminal converts each sample in the third sample set into a hash value, obtains a second hash table corresponding to the third sample set, and sends the second hash table to the first terminal.
  • the third sample set I 2 is the samples collected by the second weather station P 2.
  • Each sample includes a sample feature set and a sample label.
  • the sample feature set includes temperature, humidity, wind speed and air pressure.
  • the sample label indicates the meteorological condition.
  • the hash table includes a sample identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample. Similar to the first terminal, the second P weather third sample set of the I 2 2, the second terminal of the second weather P 2 N 2 * L to generate a second hash function hash table, and The second hash table is sent to the first weather station P 1 .
  • each weather station participating in model training will perform the operations of the second terminal, generate a hash table corresponding to each sample, and send it to the first terminal.
  • weather stations generates a P i N i * L hash table transmits to the first terminal, and the same hash function used in each of the weather.
  • the first terminal receives the second hash table sent by the second terminal, obtains the sample identification set according to the first hash table and the second hash table, and sends the sample identification set to the second terminal.
  • the second hash table includes the identifier corresponding to each sample in the third sample set and the hash value corresponding to each sample.
  • the first terminal determines in the third sample set according to the first hash table and the second hash table. The sample identification corresponding to the most similar sample of each sample in the first sample set, thereby obtaining the sample identification set.
  • the hash value corresponds to a certain sample in the first sample set
  • the first terminal searches the second hash table for a hash value that is the closest to the hash value.
  • the closest hash value the sample ID corresponding to the closest hash value is determined.
  • the set represented by all samples is the sample ID set, then The sample corresponding to the closest hash value is the most similar sample of a certain sample in the first sample set.
  • Sample ID Sample ID model training set comprises weather stations participating in the first sample a local weather station P corresponding to the most similar samples, a first sample is a local weather station P 1 Any sample in the first sample set.
  • the first weather station P 1 compares the hash tables of other weather stations with the first hash table, and determines that the samples collected by other weather stations are the same as those of the first weather station.
  • the most similar sample identification set of the first sample set of the station P 1 that is, N 1 sample identifications are determined from each weather station, where the sample data corresponding to each sample identification represents a sample from the first weather station P 1
  • the sample data of is the most similar, and the sample identification set is sent to the terminals of other M-1 weather stations participating in the model training.
  • each row represents the sample identification of a sample of the first weather station P 1 that is most similar to other weather stations
  • each column represents a weather station corresponding to the sample of the first weather station P 1
  • the sample ID of the most similar sample Taking the second weather station P 2 as an example, the second column in Fig. 5 is the sample identification of the most similar sample corresponding to the samples of the second weather station P 2 and the first weather station P 1, for example, the second weather station P 2 and the sample data of the first weather station P 1
  • the most similar sample is the sample data corresponding to the sample ID 45 in the second weather station P 2.
  • the weather station since the first weather station is looking for similar samples P 1, P 1 have a first weather the N 1 samples, the weather station must find each other the N 1 in the first sample identity Station N 1 * M of a sample identity P 1 set in correspondence sample, i.e., a first obtained Station P 1 S 1.
  • a first weather station 100 samples P 1, P 2 of the second weather station 150 samples, for each sample of the first weather P 1, P 1 from the first weather second weather P 2
  • the sample ID of a most similar sample is determined in P 2 , where the sample IDs of the 100 most similar samples determined from the second weather station P 2 may be different, or may be partly the same.
  • Station P i is the i-th sample identity will get a set S i ⁇ N i ⁇ M, and the set of sample identity broadcasted.
  • the first terminal calculates the first step set and the second step set of the loss function of the model to be trained according to each sample in the first sample set.
  • a gradient value in the first step set is calculated based on a sample in the first sample set
  • a gradient value in the second step set is calculated based on a sample in the first sample set.
  • Function l() represents the loss function of the model to be trained
  • function l′() loss function represents the first derivative of the function l
  • () represents the second derivative of the loss function
  • a first sample of a weather station P Q 1 is any one of a first sample a first Station P concentration sample, That is, for each sample of the first weather station P 1 , the first gradient and the second gradient must be calculated.
  • the terminal of each weather station participating in the model training must perform the operation of the first weather station P 1 described above: use the sample set to calculate the first step and the second step of the loss function
  • the selection of the loss function is not limited.
  • the loss function can be logloss.
  • the second terminal receives the sample identification set sent by the first terminal, determines the second sample set in the third sample set according to the sample identification set, and calculates the aggregation of the loss function of the model to be trained according to each sample in the second sample set.
  • the level set and the aggregated second level set, and the aggregated first level set and the aggregated second level set are sent to the first terminal.
  • the second sample set includes the samples that are most similar to each sample in the first sample set determined in the third sample set, and the second terminal of the second weather station P 2 receives the first terminal of the first weather station P 1
  • the sent sample identification set, each sample identification in the identification set indicates a sample in the third sample set, and the second terminal finds the second sample set from the third sample set according to the sample identification set.
  • the function l() represents the loss function of the model to be trained
  • the function l'() represents the first derivative of the loss function
  • the function l′′() represents the second derivative of the loss function. Since the first weather station P 1 has a total of N 1 samples, the second terminal calculates a total of N 1 aggregation steps and N 1 polymerized second steps. It should be understood that these N 1 polymerized first steps may be different, or may be partly the same, and similarly, the N 1 polymerized second steps may be different or partly the same.
  • the terminal of each weather station participating in model training will perform the operation of the second terminal, that is, find similar sample sets based on the received sample identification set, and calculate similar sample sets.
  • the aggregated first-order degree set and aggregated second-order degree set are sent to the first weather station.
  • the third terminal transmits a weather station in accordance with a first weather Identification set, find the sample similar to the first weather station in the third weather station, calculate the gradient value of the similar sample and send it to the first weather station, the terminal of the fourth weather station finds the sample identification set sent by the first weather station In the fourth weather station similar to the first weather station, the gradient value of the similar sample is calculated and sent to the first weather station, and so on, so that the first weather station will get the gradient value of the first sample set, The gradient values of samples similar to the first sample set in other weather stations participating in the model training will also be obtained.
  • the first terminal receives the aggregated first degree set and aggregated second degree set calculated according to the second sample set sent by the second terminal, and aggregates the first degree set, aggregates first degree set, second degree set, and aggregates
  • the second step set and the first sample set are trained on the model to be trained to obtain a trained model.
  • the first terminal updates the first-order gradient set of the first sample set according to the aggregation of the first-order degree set and the first-order degree set to obtain the first-order sample gradient set, and updates the first-order sample gradient set according to the aggregated second-order degree set and the second-order degree set.
  • the second-order gradient set of the sample set obtains the second-order sample gradient set.
  • the first terminal has a step of the loss function of the sample data
  • the sum of the aggregate first-order gradient corresponding to the sample most similar to the sample data in the second weather station P 2 is taken as the first-order sample gradient of the sample data
  • the second-order gradient of the loss function of the sample data is compared with that of the second weather
  • the sum of the aggregated second-order gradients corresponding to the samples most similar to the sample data in the station P 2 is used as the second-order sample gradient of the sample data.
  • the first terminal of the first weather station P 1 receives the aggregated first degree set and aggregated second degree set sent by terminals of other weather stations.
  • a sample of any P q, P 1 obtained weather first step a degree of polymerization And the degree of aggregation
  • the first terminal of the first weather station P 1 is based on Update the first-order sample gradient G 1q of sample q, according to renew The second-order sample gradient of H 1q , and each sample of the first weather station P 1 must update the first step and the second step to prepare for the training of the model.
  • the first terminal uses the first sample set, the first-order sample gradient set, and the second-order sample gradient set to train the XGBOOST model, so as to obtain the model to be predicted for the first weather station P 1.
  • the first-order sample gradient set and the second-order sample gradient set of the first sample set are used as the first-order gradient set and the second-order gradient set during the training of the first sample set.
  • the process of training the model is the process of continuously building the regression tree, specifically, when building the first tree, it is necessary to split at the root node, and divide the first sample set into a left child node and a right child node at the node.
  • Two sets, and use the sample gradient value of the sample to calculate the G L , G R , H L , H R of the two sets, and then use the formula:
  • the set of left leaf nodes of sample points after G L Representative if splitting a first order sample gradients and, first order sample gradients and, H L that represents a collection of G R representative of the right leaf node if dividing sample points if split
  • the sum of the second-order sample gradients of the set of sample points in the rear left leaf node, and H R represents the sum of the second-order sample gradients of the set of sample points in the right leaf node after the split.
  • the division interval needs to be determined according to different split points.
  • the first sample set is divided into two sets of left child nodes and right child nodes. Then, this split point is determined by the sample feature set of the sample data, and then Repeatedly calculate the gain under different division points.
  • the same split operation is continued on the left and right child nodes, that is, the child node is regarded as the root node and the above process is repeated.
  • the nodes of the tree can no longer be split, and the weight of the leaf nodes is calculated Thus, the first gradient tree is trained.
  • the training process is exactly the same as that of the previous t-1 tree, but the input parameters of the tree are no longer the initial input parameters G 1q and H 1q used by the first tree.
  • the first step at this time is And second degree Need to use the predicted value of the i-th training sample by the model composed of the first t-1 trees Therefore, the gain gain is calculated based on the split point, and the optimal split point and optimal weight required for the current round of gradient tree construction are finally determined.
  • a terminal model training weather stations have to perform a first operation of the first terminal Station P 1
  • model training weather stations participating terminal have to perform Operation of the second terminal of the second weather station P 2 described above. It can be seen that for a weather station, the weather station not only uses the sample data of other weather stations to train the model, but also obtains a prediction model for the weather station.
  • the first terminal predicts the sample to be predicted based on the trained model, and determines the prediction result of the sample to be predicted.
  • the first terminal After the first terminal has trained the meteorological event prediction model, it can use the sample to be predicted to predict the meteorological condition of a certain event. That is, the sample feature set in the sample to be predicted is substituted into the trained regression tree, and each sample feature will eventually fall on a leaf node of a regression tree. Add up the weight values of the leaf nodes obtained from all trees to obtain this The weather forecast value of the event, and then by comparing the result value to the value of which sample label is the closest, the meteorological condition (no rain, light rain, moderate rain, heavy rain, heavy rain) corresponding to the sample label is the forecast of the sample to be predicted result.
  • the meteorological condition no rain, light rain, moderate rain, heavy rain, heavy rain
  • this method uses the idea of federated learning to find samples similar to the samples of the model training party from the sample data of the model training participants to expand the training sample set, thereby constructing a more accurate model.
  • this method After finding the similar samples, instead of sending the sample data directly to the model trainer, it sends the gradient value of the loss function of the similar sample, avoiding the problem of data leakage.
  • This method also supports multiple terminals to train the model at the same time, which effectively improves The computational efficiency of the model.
  • the meteorological event prediction device 100 includes a receiving unit 101, a processing unit 102, and a sending unit 103. Wherein, when the weather event prediction apparatus 100 performs the operation of the first terminal:
  • the receiving unit 101 is configured to receive the aggregate first degree set and the aggregate second degree set calculated according to the second sample set sent by the second terminal, and the second sample set includes information similar to each sample in the first sample set.
  • Sample receiving a second hash table sent by the second terminal, the second hash table including a sample identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample.
  • the processing unit 102 is configured to calculate the first step set and the second step set of the loss function of the model to be trained according to each sample in the first sample set, wherein a gradient value in the first step set is based on the first step The same is calculated from a sample in this set, a gradient value in the second gradient set is calculated based on a sample in the first sample set, and the first sample set is a sample collected by the first weather station According to the first step set, the first step set, the second step set, the second step set, and the first sample set, the training model is trained to obtain a trained model; the first is the same Each sample in this set is converted into a hash value to obtain the first hash table corresponding to the first sample set; according to the first hash table and the second hash table, the third sample set is The sample ID corresponding to the most similar sample of each sample in the sample set is obtained.
  • the sending unit 103 is configured to send the sample identification set to the second terminal, so that the second terminal determines the second sample set according to the sample identification in the sample identification set.
  • the receiving unit 101 is configured to receive a sample identification set sent by the first terminal, where each sample identification in the sample identification set indicates a sample in the third sample set.
  • the processing unit 102 is configured to convert each sample in the third sample set into a hash value to obtain a second hash table corresponding to the third sample set; determine the second sample set in the third sample set according to the identification set, According to each sample in the second sample set, calculate the aggregate first degree set and aggregate second degree set of the loss function of the model to be trained, and send the aggregate first degree set and aggregate second degree set to the first terminal.
  • the sending unit 103 is configured to send a second hash table to the first terminal.
  • the second hash table includes a sample identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample.
  • the third sample set is the sample collected by the second weather station.
  • the meteorological event prediction apparatus 100 described above can refer to the related operations of the first terminal in the foregoing method embodiment for predicting meteorological events, which will not be described in detail here.
  • FIG. 7 is a schematic structural diagram of a computing device provided by an embodiment of the present application.
  • the computing device 200 includes a processor 210, a communication interface 220, and a memory 230.
  • the processor 210, the communication interface 220, and the memory 230 are connected to each other through a bus 240,
  • the processor 210 is configured to execute instructions stored in the memory 230.
  • the memory 230 stores program codes, and the processor 210 can call the program codes stored in the memory 230 to perform the following operations:
  • the meteorological event prediction device calculates the first step set and the second step set of the loss function of the model to be trained according to each sample in the first sample set, wherein a gradient value in the first step set is based on the first step. Calculated from a sample in this set, a gradient value in the second gradient set is calculated based on a sample in the first sample set, and the first sample set is a set of samples collected by the first weather station Receiving the aggregated first-order degree set and aggregated second-order degree set calculated according to the second sample set sent by the second terminal, the second sample set including samples similar to each sample in the first sample set; The first step degree set, the aggregated first step degree set, the second step degree set, the aggregated second step degree set, and the first sample set are trained on the model to be trained, and the training is good The model; based on the trained model, predict the sample to be predicted, and determine the prediction result of the sample to be predicted.
  • the processor 210 may have a variety of specific implementation forms.
  • the processor 210 may be a central processing unit (CPU), a graphics processing unit (GPU), or a tensor processing unit ( A tensor processing unit (TPU) or a neural network processing unit (NPU) or a combination of any one or more of the processors.
  • the processor 210 may also be a single-core processor or a multi-core processor.
  • the processor 210 may be a combination of a CPU (GPU, TPU, or NPU) and a hardware chip.
  • the above-mentioned hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof.
  • ASIC application-specific integrated circuit
  • PLD programmable logic device
  • the above-mentioned PLD complex programmable logic device CPLD
  • field-programmable gate array FPGA
  • GAL generic array logic
  • the processor 210 may also be implemented solely by a logic device with built-in processing logic, such as an FPGA or a digital signal processor (digital signal processor, DSP).
  • the communication interface 220 can be a wired interface or a wireless interface for communicating with other modules or devices.
  • the wired interface can be an Ethernet interface, a controller area network (CAN) interface, or a local interconnect network (local interconnect network, LIN) interface.
  • the wireless interface can be a cellular network interface or a wireless LAN interface.
  • the memory 230 may be a non-volatile memory, for example, read-only memory (ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), Electrically erasable programmable read-only memory (EPROM, EEPROM) or flash memory.
  • ROM read-only memory
  • PROM programmable read-only memory
  • EPROM erasable programmable read-only memory
  • EPROM Electrically erasable programmable read-only memory
  • EEPROM Electrically erasable programmable read-only memory
  • flash memory any type of volatile memory
  • the memory 230 may also be a volatile memory, and the volatile memory may be a random access memory (random access memory, RAM), which is used as an external cache.
  • RAM random access memory
  • the memory 230 may also be used to store instructions and data, so that the processor 210 can call the instructions stored in the memory 230 to implement the operations performed by the processing unit 103 described above or the operations performed by the meteorological event prediction apparatus in the method embodiment.
  • the computing device 200 may include more or fewer components than those shown in FIG. 7, or may have different component configurations.
  • the bus 240 can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in FIG. 6, but it does not mean that there is only one bus or one type of bus.
  • the computing device 200 may further include an input/output interface 250 to which an input/output device is connected to the input/output interface 250 for receiving input information and outputting operation results.
  • computing device 200 in the embodiment of the present application may correspond to the data processing apparatus 100 in the above-mentioned embodiment, and can perform operations performed by the meteorological event prediction apparatus in the above-mentioned method embodiment, which will not be repeated here.
  • An embodiment of the present application also provides a computer (readable) storage medium, wherein the computer readable storage medium stores a computer program (or instruction), and the computer program is executed by a processor to implement the above method.
  • the storage medium involved in this application such as a computer-readable storage medium, may be non-volatile (such as a non-transitory computer storage medium) or volatile.
  • this application provides a non-transitory computer storage medium.
  • the computer storage medium stores instructions. When it runs on a processor, it can implement the method steps in the above method embodiments, and the processor of the computer storage medium is executing
  • the specific implementation of the steps of the foregoing method reference may be made to the specific operations of the foregoing method embodiments, and details are not described herein again.
  • the above-mentioned embodiments may be implemented in whole or in part by software, hardware, firmware or any other combination.
  • the above-mentioned embodiments may be implemented in the form of a computer program product in whole or in part.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more sets of available media.
  • the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium, or a semiconductor medium, and the semiconductor medium may be a solid state hard disk.

Abstract

A meteorological event prediction method. The method comprises: a first terminal calculating, according to each sample in a first sample set, a first-order gradient set and a second-order gradient set of a loss function of a model to be trained; receiving an aggregated first-order gradient set and an aggregated second-order gradient set, which are sent by a second terminal and are obtained by performing calculation according to a second sample set, wherein the second sample set is a sample set which is determined from a sample set of the second terminal and is similar to the first sample set; and then training the model according to gradient values of samples and aggregated gradient values of similar samples, and predicting a meteorological situation by means of the trained model. By means of sending aggregated gradient values of similar samples to a first terminal for model training, the problem of data leakage is avoided, and similar samples of other terminals are also used during a model training process, such that a trained model is more accurate, and the terminals can perform synchronous and parallel training, thereby improving the calculation efficiency of a model, and rationally using data and resources.

Description

一种气象事件预测方法、装置及相关设备Method, device and related equipment for predicting meteorological events
本申请要求于2020年11月20日提交中国专利局、申请号为202011312818.9,发明名称为“一种气象事件预测方法、装置及相关设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on November 20, 2020, the application number is 202011312818.9, and the invention title is "a method, device and related equipment for predicting meteorological events", the entire content of which is incorporated by reference In this application.
技术领域Technical field
本申请涉及大数据处理技术领域,尤其涉及一种气象事件预测方法、装置及相关设备。This application relates to the technical field of big data processing, and in particular to a method, device and related equipment for predicting meteorological events.
背景技术Background technique
随着大数据和人工智能的发展,海量数据深度学习、复杂神经网络等逐步应用,运用大数据与人工智能技术对气象事件预测已成为一个热门话题,例如降雨预报、温度预报、风速预测等等。With the development of big data and artificial intelligence, the gradual application of massive data deep learning, complex neural networks, etc., the use of big data and artificial intelligence technology to predict meteorological events has become a hot topic, such as rainfall forecasts, temperature forecasts, wind speed forecasts, etc. .
发明人发现,目前,气象预报方法主要有回归模型、自回归滑动平均模型等传统统计方式和人工神经网络、支持向量机、回归树等人工智能模型。但是,发明人意识到,现有的研究都针对中心化训练模型,也就是将各气象站点的所有数据上传到中心服务器后训练模型,但由于气象站点分布较广,数量较多,且长时间监控,数据量非常大,而且不同省份气象数据涉及到保密问题,仅仅使用中心化训练模式来训练模型往往不能达到人们的期望,训练过程显得十分乏力,并且会不可避免地导致运算效率低下,模型过于宽泛和性能不足等问题。The inventor found that currently, weather forecasting methods mainly include traditional statistical methods such as regression models and autoregressive moving average models, and artificial neural networks, support vector machines, regression trees and other artificial intelligence models. However, the inventor realizes that the existing researches are all aimed at centralized training models, that is, the models are trained after uploading all the data of each meteorological station to the central server. However, because the meteorological stations are widely distributed, the number is large, and the time is long. Monitoring, the amount of data is very large, and the meteorological data of different provinces involves confidentiality issues. Only using the centralized training mode to train the model often fails to meet people's expectations. The training process is very weak and will inevitably lead to inefficient calculations. Too broad and insufficient performance.
发明内容Summary of the invention
本申请实施例提供一种气象事件预测方法,能够解决气象数据间存在的数据隐私保护问题和模型的运算效率低下、过于宽泛和性能不足等问题。The embodiments of the present application provide a method for predicting meteorological events, which can solve the problems of data privacy protection between meteorological data and the problems of low computational efficiency, over-extensiveness, and insufficient performance of models.
第一方面,本申请提供一种气象事件预测方法,所述气象件预测方法应用于气象预测系统,所述气象预测系统包括位于第一气象站的第一终端和位于第二气象站的第二终端,所述方法包括:第一终端根据第一样本集中的每个样本,计算待训练模型的损失函数的一阶梯度集和二阶梯度集,其中,所述一阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述二阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述第一样本集是第一气象站采集的样本的集合;所述第一终端接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集,所述第二样本集包括与所述第一样本集中每个样本相似的样本;所述第一终端根据所述一阶梯度集、所述聚合一阶梯度集、所述二阶梯度集、所述聚合二阶梯度集以及所述第一样本集,对所述待训练模型进行训练,得到训练好的模型;所述第一终端基于所述训练好的模型,对待预测样本进行预测,确定待预测样本的预测结果。In the first aspect, this application provides a method for predicting meteorological events. The method for predicting meteorological items is applied to a meteorological forecasting system. The meteorological forecasting system includes a first terminal located at a first weather station and a second terminal located at a second weather station. A terminal, the method includes: the first terminal calculates the first step set and the second step set of the loss function of the model to be trained according to each sample in the first sample set, wherein one gradient in the first step set The value is calculated based on a sample in the first sample set, and a gradient value in the second gradient set is calculated based on a sample in the first sample set, and the first sample set is the first weather The collection of samples collected by the station; the first terminal receives the aggregated first-order degree set and the aggregated second-order degree set calculated according to the second sample set sent by the second terminal, and the second sample set includes the same as the first Samples in the sample set that are similar to each sample; the first terminal according to the first step set, the aggregated first step set, the second step set, the aggregated second step set, and the first A sample set is used to train the model to be trained to obtain a trained model; the first terminal predicts the sample to be predicted based on the trained model, and determines the prediction result of the sample to be predicted.
第二方面,本申请提供一种气象事件预测方法,所述气象件预测方法应用于气象预测系统,所述气象预测系统包括位于第一气象站的第一终端和位于第二气象站的第二终端,所述方法包括:所述第二终端将第二哈希表发送给所述第一终端,所述第二哈希表包括所述第三样本集中每个样本对应的标识以及每个样本对应的哈希值,所述第三样本集是所述第二气象站采集的样本;所述第二终端接收所述第一终端发送的样本标识集,所述样本标识集中的每个样本标识指示所述第三样本集中的一个样本;所述第二终端根据所述样本标识集在所述第三样本集中确定第二样本集,根据所述第二样本集中的每个样本,计算所述待训练模型的损失函数的聚合一阶梯度集和聚合二阶梯度集,并将所述聚合一阶梯度集和 所述聚合二阶梯度集发送给所述第一终端。In a second aspect, this application provides a method for predicting meteorological events. The method for predicting meteorological items is applied to a meteorological forecasting system. The meteorological forecasting system includes a first terminal at a first weather station and a second terminal at a second weather station. Terminal, the method includes: the second terminal sends a second hash table to the first terminal, the second hash table including an identifier corresponding to each sample in the third sample set and each sample Corresponding to the hash value, the third sample set is the sample collected by the second weather station; the second terminal receives the sample identification set sent by the first terminal, and each sample identification in the sample identification set Indicates a sample in the third sample set; the second terminal determines a second sample set in the third sample set according to the sample identification set, and calculates the second sample set according to each sample in the second sample set Aggregate the first-order degree set and the aggregated second-order degree set of the loss function of the model to be trained, and send the aggregated first-order degree set and the aggregated second-order degree set to the first terminal.
第三方面,本申请提供一种气象事件预测装置,所述装置包括:处理单元,用于根据第一样本集中的每个样本,计算待训练模型的损失函数的一阶梯度集和二阶梯度集,其中,所述一阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述二阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述第一样本集是第一气象站采集的样本的集合;接收单元,用于接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集,所述第二样本集包括与所述第一样本集中每个样本相似的样本;所述处理单元,还用于根据所述一阶梯度集、所述聚合一阶梯度集、所述二阶梯度集、所述聚合二阶梯度集以及所述第一样本集,对所述待训练模型进行训练,得到训练好的模型;基于所述训练好的模型,对待预测样本进行预测,确定待预测样本的预测结果;或者,所述装置包括:发送单元,用于将第二哈希表发送给第一终端,所述第二哈希表包括所述第三样本集中每个样本对应的样本标识以及每个样本对应的哈希值,所述第三样本集是所述第二气象站采集的样本;接收单元,用于接收所述第一终端发送的样本标识集,所述标识集中的每个样本标识指示所述第三样本集中的一个样本;处理单元,用于根据所述样本标识集在所述第三样本集中确定第二样本集,根据所述第二样本集中的每个样本,计算所述待训练模型的损失函数的聚合一阶梯度集和聚合二阶梯度集;所述发送单元,还用于将所述聚合一阶梯度集和所述聚合二阶梯度集发送给所述第一终端。In a third aspect, the present application provides a meteorological event prediction device. The device includes: a processing unit for calculating the first step set and the second step set of the loss function of the model to be trained based on each sample in the first sample set Degree set, wherein a gradient value in the first step degree set is calculated based on a sample in the first sample set, and a gradient value in the second step degree set is calculated based on a sample in the first sample set Obtained, the first sample set is a set of samples collected by the first weather station; the receiving unit is configured to receive the aggregated first degree set and aggregated second degree set calculated from the second sample set sent by the second terminal The second sample set includes samples that are similar to each sample in the first sample set; the processing unit is further configured to: The two-level degree set, the aggregated two-level degree set, and the first sample set are trained on the model to be trained to obtain a trained model; based on the trained model, predict the sample to be predicted, Determine the prediction result of the sample to be predicted; or, the device includes: a sending unit, configured to send a second hash table to the first terminal, the second hash table including each sample corresponding to the third sample set The sample identifier of and the hash value corresponding to each sample, the third sample set is the sample collected by the second weather station; the receiving unit is configured to receive the sample identification set sent by the first terminal, the identifier Each sample identification in the set indicates a sample in the third sample set; the processing unit is configured to determine a second sample set in the third sample set according to the sample identification set, and according to each sample in the second sample set. Samples to calculate the aggregated first degree set and aggregated second degree set of the loss function of the model to be trained; the sending unit is further configured to send the aggregated first degree set and the aggregated second degree set To the first terminal.
第四方面,本申请提供一种计算机设备,所述计算设备包括处理器和存储器,所述存储器用于存储指令,所述处理器用于执行所述指令,当所述处理器执行所述指令时,执行以下方法:根据第一样本集中的每个样本,计算待训练模型的损失函数的一阶梯度集和二阶梯度集,其中,所述一阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述二阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述第一样本集是第一气象站采集的样本的集合;接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集,所述第二样本集包括与所述第一样本集中每个样本相似的样本;根据所述一阶梯度集、所述聚合一阶梯度集、所述二阶梯度集、所述聚合二阶梯度集以及所述第一样本集,对所述待训练模型进行训练,得到训练好的模型;基于所述训练好的模型,对待预测样本进行预测,确定待预测样本的预测结果;或者,In a fourth aspect, the present application provides a computer device that includes a processor and a memory, the memory is used to store instructions, the processor is used to execute the instructions, and when the processor executes the instructions , Execute the following method: according to each sample in the first sample set, calculate the first step set and the second step set of the loss function of the model to be trained, wherein a gradient value in the first step set is based on the first A sample in the sample set is calculated, a gradient value in the second gradient set is calculated based on a sample in the first sample set, and the first sample set is the sample collected by the first weather station A set; receiving an aggregated first-order degree set and an aggregated second-order degree set calculated according to a second sample set sent by the second terminal, the second sample set including samples similar to each sample in the first sample set; Training the model to be trained according to the first step degree set, the aggregate first step degree set, the second step degree set, the aggregate second step degree set, and the first sample set to obtain training Good model; based on the trained model, predict the sample to be predicted, and determine the prediction result of the sample to be predicted; or,
将第二哈希表发送给第一终端,所述第二哈希表包括所述第三样本集中每个样本对应的样本标识以及每个样本对应的哈希值,所述第三样本集是所述第二气象站采集的样本;接收所述第一终端发送的样本标识集,所述标识集中的每个样本标识指示所述第三样本集中的一个样本;根据所述样本标识集在所述第三样本集中确定第二样本集,根据所述第二样本集中的每个样本,计算所述待训练模型的损失函数的聚合一阶梯度集和聚合二阶梯度集,并将所述聚合一阶梯度集和所述聚合二阶梯度集发送给所述第一终端。Send a second hash table to the first terminal, where the second hash table includes a sample identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample. The third sample set is The sample collected by the second weather station; receiving the sample identification set sent by the first terminal, each sample identification in the identification set indicates a sample in the third sample set; according to the sample identification set in the In the third sample set, a second sample set is determined, and according to each sample in the second sample set, the aggregated first degree set and aggregated second degree set of the loss function of the model to be trained are calculated, and the aggregated The first-order degree set and the aggregated second-order degree set are sent to the first terminal.
第五方面,本申请提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行以实现以下方法:根据第一样本集中的每个样本,计算待训练模型的损失函数的一阶梯度集和二阶梯度集,其中,所述一阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述二阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述第一样本集是第一气象站采集的样本的集合;接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集,所述第二样本集包括与所述第一样本集中每个样本相似的样本;根据所述一阶梯度集、所述聚合一阶梯度集、所述二阶梯度集、所述聚合二阶梯度集以及所述第一样本集,对所述待训练模型进行训练,得到训练好的模型;基于所述训练好的模型,对待预测样本进行预测,确定待预测样本的预测结果;或者,In a fifth aspect, the present application provides a computer-readable storage medium storing a computer program, and the computer program is executed by a processor to implement the following method: according to each sample in the first sample set Calculate the first step set and the second step set of the loss function of the model to be trained, wherein a gradient value in the first step set is calculated based on a sample in the first sample set, and the second step set A gradient value in the set is calculated based on a sample in the first sample set. The first sample set is a set of samples collected by the first weather station; receiving the second terminal sent and calculated based on the second sample set Aggregating a first degree set and an aggregate second degree set, the second sample set includes samples similar to each sample in the first sample set; according to the first degree set and the aggregate first degree set , The two-level degree set, the aggregated two-level degree set, and the first sample set are trained on the model to be trained to obtain a trained model; based on the trained model, a sample to be predicted Make a prediction to determine the prediction result of the sample to be predicted; or,
将第二哈希表发送给第一终端,所述第二哈希表包括所述第三样本集中每个样本对应 的样本标识以及每个样本对应的哈希值,所述第三样本集是所述第二气象站采集的样本;接收所述第一终端发送的样本标识集,所述标识集中的每个样本标识指示所述第三样本集中的一个样本;根据所述样本标识集在所述第三样本集中确定第二样本集,根据所述第二样本集中的每个样本,计算所述待训练模型的损失函数的聚合一阶梯度集和聚合二阶梯度集,并将所述聚合一阶梯度集和所述聚合二阶梯度集发送给所述第一终端。Send a second hash table to the first terminal, where the second hash table includes a sample identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample. The third sample set is The sample collected by the second weather station; receiving the sample identification set sent by the first terminal, each sample identification in the identification set indicates a sample in the third sample set; according to the sample identification set in the In the third sample set, a second sample set is determined, and according to each sample in the second sample set, the aggregated first degree set and aggregated second degree set of the loss function of the model to be trained are calculated, and the aggregated The first-order degree set and the aggregated second-order degree set are sent to the first terminal.
本申请实施例中,第一气象站的第一终端使用第一样本计算得到的梯度集和第二终端的第二样本计算得到的梯度集来训练模型,其中,第二样本是第二气象站与第一气象站相似的样本,可以看出,使用本地数据和其他气象站相似的数据作为模型的训练参数,合理利用了数据和资源,让模型的预测结果更加准确;并且,第一终端接收到的是第二终端的样本的梯度值,该方法也不涉及中心服务器,各气象站的终端无需将数据上传到中心服务器,避免了数据隐私的泄露问题;该方法还可同时应用于多个气象站的气象预测,各气象站可以协同合作,同步并行训练针对各气象站的模型,有效提高了模型的计算效率。In the embodiment of this application, the first terminal of the first weather station uses the gradient set calculated by the first sample and the gradient set calculated by the second sample of the second terminal to train the model, where the second sample is the second weather The samples of the station and the first weather station are similar, it can be seen that the local data and the data similar to other weather stations are used as the training parameters of the model, and the data and resources are rationally used to make the prediction results of the model more accurate; and the first terminal What is received is the gradient value of the sample of the second terminal. This method does not involve the central server. The terminals of each weather station do not need to upload the data to the central server, which avoids the problem of data privacy leakage; this method can also be applied to multiple applications at the same time. For the weather forecast of a weather station, each weather station can cooperate and train the model for each weather station in parallel, which effectively improves the calculation efficiency of the model.
附图说明Description of the drawings
为了更清楚地说明本申请实施例或背景技术中的技术方案,下面将对本申请实施例或背景技术中所需要使用的附图进行说明。In order to more clearly describe the technical solutions in the embodiments of the present application or the background art, the following will describe the drawings that need to be used in the embodiments of the present application or the background art.
图1为本申请实施例提供的一种气象事件预测方法的整体流程示意图;FIG. 1 is a schematic diagram of the overall flow of a method for predicting a meteorological event provided by an embodiment of this application;
图2为本申请实施例中提供的一种数据终端的样本数据结构;Figure 2 is a sample data structure of a data terminal provided in an embodiment of the application;
图3为本申请实施例中提供的一种模型训练过程的流程示意图;FIG. 3 is a schematic flowchart of a model training process provided in an embodiment of this application;
图4为本申请实施例中提供的一种数据终端的样本数据经加密后所得到的数据结构示意图;FIG. 4 is a schematic diagram of a data structure obtained by encrypting sample data of a data terminal provided in an embodiment of the application; FIG.
图5为本申请实施例中提供的一种数据终端根据哈希表确定的样本标识集的数据结构示意图;FIG. 5 is a schematic diagram of a data structure of a sample identification set determined by a data terminal according to a hash table according to an embodiment of the application; FIG.
图6为本申请实施例中提供的一种气象事件预测装置的结构示意图;Fig. 6 is a schematic structural diagram of a meteorological event prediction device provided in an embodiment of the application;
图7为本申请实施例中提供的一种计算机设备的结构示意图。FIG. 7 is a schematic structural diagram of a computer device provided in an embodiment of this application.
具体实施方式Detailed ways
下面结合本申请实施例中的附图对本申请实施例进行描述。本申请的实施方式部分使用的术语仅用于对本申请的具体实施例进行解释,而非旨在限定本申请。The embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation mode part of this application are only used to explain specific embodiments of this application, and are not intended to limit this application.
本申请的技术方案可涉及人工智能和/或大数据技术领域,以实现事件预测,推动智慧城市的建设。可选的,本申请涉及的数据如样本和/或预测结果等可存储于数据库中,或者可以存储于区块链中,本申请不做限定。The technical solution of this application may involve the field of artificial intelligence and/or big data technology to realize event prediction and promote the construction of smart cities. Optionally, the data involved in this application, such as samples and/or prediction results, can be stored in a database, or can be stored in a blockchain, which is not limited in this application.
在涉及到多个参与方参与模型的训练时,传统的方法往往是将多个参与方的数据上传到一个中心服务器,通过中心服务器训练模型,然后再将训练好的模型发送给参与方用于参与方进行相关事件的预测。虽然该方法能够将参与方的数据都用于模型的训练,使得训练出的模型适用于各参与方的数据预测,但是该方法运算效率低下,模型太过宽泛,且存在隐私泄露的问题。When multiple participants participate in the training of the model, the traditional method is often to upload the data of multiple participants to a central server, train the model through the central server, and then send the trained model to the participants for use Participants make predictions about related events. Although this method can use all participants' data for model training, so that the trained model is suitable for the data prediction of each participant, the method has low computational efficiency, the model is too broad, and there is a problem of privacy leakage.
为了解决上述问题,本申请提供一种气象事件预测方法,该方法结合联邦学习技术的特点,使用XGBOOST模型,对模型进行训练。各个气象站无需上传数据到中心服务器共享数据,各个气象站在本地训练针对本地样本的模型,同时还将其他气象站的相似样本用 于本地模型的训练,其中,相似样本是指其他气象站采集的样本中与本地采集的样本相似的样本,通过接收其他气象站相似样本的聚合梯度值训练本地模型,避免了数据隐私泄露的问题,各气象站同步并行训练针对各气象站的模型,有效提高了模型的计算效率和模型的准确率。In order to solve the above problems, this application provides a method for predicting meteorological events, which combines the characteristics of federated learning technology and uses the XGBOOST model to train the model. Each weather station does not need to upload data to the central server to share data. Each weather station locally trains a model for local samples, and also uses similar samples from other weather stations for local model training, where similar samples refer to collections from other weather stations Among the samples in the sample, the local model is trained by receiving the aggregate gradient value of similar samples from other weather stations, which avoids the problem of data privacy leakage. Each weather station synchronizes and parallel trains the model for each weather station, which effectively improves The calculation efficiency of the model and the accuracy of the model are improved.
首先对本申请的实施例涉及的气象事件预测方法的流程进行整体的介绍。First, the overall flow of the meteorological event prediction method involved in the embodiment of the present application is introduced.
图1示出了气象事件预测方法的整体流程示意图,预测气象事件的整体流程包括如下步骤:Figure 1 shows a schematic diagram of the overall process of the meteorological event prediction method. The overall process of predicting a meteorological event includes the following steps:
S101:获取早期数据训练气象预测模型。S101: Obtain early data to train a weather forecast model.
其中,早期数据是指早期的气象数据,例如,某一气象数据指出,在温度为29℃,湿度为73%,风速为27公里/时,气压为1009百帕等数据情况下,某地气象状况为小雨,那么,温度、湿度、风速、气压为气象事件的样本特征集,小雨为该气象事件的样本标签,该气象事件的样本特征集和样本标签构成了一个气象事件样本。运用这些早期已知的数据来训练模型,即寻找模型的参数,最终得到一个已知参数的气象预测模型。Among them, the early data refers to the early meteorological data. For example, a certain meteorological data points out that when the temperature is 29°C, the humidity is 73%, the wind speed is 27 km/h, and the pressure is 1009 hPa, the meteorological data in a certain place The condition is light rain, then temperature, humidity, wind speed, and air pressure are the sample feature sets of the meteorological event, and light rain is the sample label of the meteorological event. The sample feature set and sample label of the meteorological event constitute a meteorological event sample. Use these early known data to train the model, that is, find the parameters of the model, and finally get a weather forecast model with known parameters.
其中,在本申请实施例中,模型训练所用到的模型为XGBOOST模型。模型训练的过程就是构建回归树的过程,,也就是不断添加回归树,即学习新的函数f(t)来拟合前面训练出的t-1棵树预测出的残差。Among them, in the embodiment of the present application, the model used for model training is the XGBOOST model. The process of model training is the process of constructing regression trees, that is, constantly adding regression trees, that is, learning a new function f(t) to fit the residuals predicted by the previously trained t-1 tree.
S102:运用训练好的模型预测气象事件。S102: Use the trained model to predict meteorological events.
最终训练好的模型能够在已知各气象样本特征集(温度、湿度、风速、气压等),而不知道气象事件的情况下,将气象事件的样本特征集输入到训练好的模型后,能够预测出该气象事件的气象结果。具体地,预测一个气象事件的气象状况时,就是这个气象事件的样本特征集输入到训练好的模型中,该样本特征集的一个样本特征会对应落在一棵树中的一个叶子节点上,最后将每棵树得到的叶子节点的权值的总和作为该气象事件的预测值。The final trained model can input the sample feature set of the meteorological event into the trained model when the feature set of each meteorological sample (temperature, humidity, wind speed, air pressure, etc.) is known without knowing the meteorological event. The meteorological result of the meteorological event is predicted. Specifically, when predicting the meteorological condition of a meteorological event, the sample feature set of the meteorological event is input into the trained model, and a sample feature of the sample feature set will correspond to a leaf node in a tree. Finally, the sum of the weights of the leaf nodes obtained from each tree is used as the predicted value of the meteorological event.
在本申请具体的实施例中,气象数据中的样本特征集可以包括除温度、湿度、风速、气压等其他的气象特征,本申请实施例对样本特征集不作限定,气象状况可以为风、云、雪等其他气象状况中的一种或者多种,某气象状况对应的样本标签个数也不作限定。In the specific embodiment of the present application, the sample feature set in the meteorological data may include other meteorological features except temperature, humidity, wind speed, air pressure, etc. The embodiment of the present application does not limit the sample feature set, and the meteorological conditions may be wind, cloud, etc. For one or more of other meteorological conditions such as, snow, etc., the number of sample labels corresponding to a certain meteorological condition is also not limited.
本申请实施例中提供的气象事件预测方法应用于气象预测系统,其中,气象预测系统包括多个气象站的数据终端,且各气象站同步并行训练,模型训练的过程一致,并在不共享数据的基础上进行联合训练。各气象站在训练本地的XGBOOST模型时,不仅用到了本地样本数据,还用到了其他气象站与本地样本数据相似的数据。该方法能够实现在不泄露各气象站样本数据的情况下联合训练,解决了气象站数据间存在的数据隐私泄露问题,使用本地样本和其他气象站的相似样本训练模型能够让模型更加的准确,合理地利用了数据和资源,而各气象站同步并训练模型,有效提高了模型的计算效率。The meteorological event prediction method provided in the embodiments of the present application is applied to a meteorological prediction system, where the meteorological prediction system includes data terminals of multiple weather stations, and each weather station is trained in parallel and synchronized. The process of model training is the same, and the data is not shared. On the basis of joint training. When each weather station trains the local XGBOOST model, not only the local sample data is used, but also the data similar to the local sample data of other weather stations. This method can realize joint training without leaking the sample data of each weather station, and solves the problem of data privacy leakage between weather station data. Using local samples and similar samples from other weather stations to train the model can make the model more accurate. The data and resources are used rationally, and the weather stations synchronize and train the model, which effectively improves the calculation efficiency of the model.
下面以单个气象站为例对申请实施例提供的模型训练方法进行介绍。The following takes a single weather station as an example to introduce the model training method provided in the application embodiment.
由于在模型训练的过程中需要用到大量的样本数据,首先对样本数据的结构进行描述。Since a large amount of sample data needs to be used in the process of model training, the structure of the sample data is described first.
本申请实施例涉及到多个气象站之间的模型训练,对于每个气象站都存在自己的气象数据,那么,P i表示第i气象站,i∈(1,2,3,……,M),M为气象站的个数,
Figure PCTCN2021083026-appb-000001
表示第i气象站P i的样本q的样本数据,q∈(1,2,3,……,N i),N i为第i气象站P i的样本个数, 样本数据
Figure PCTCN2021083026-appb-000002
包括样本特征集
Figure PCTCN2021083026-appb-000003
和样本标签
Figure PCTCN2021083026-appb-000004
样本特征集
Figure PCTCN2021083026-appb-000005
表示第i气象站P i的样本q对应的特征集(温度、湿度、风速、气压等气象数据),其中,样本特征集
Figure PCTCN2021083026-appb-000006
T为样本特征的个数,样本标签
Figure PCTCN2021083026-appb-000007
表示第i气象站P i的样本q对应的样本标签(无雨、小雨、中雨、大雨、暴雨),其中,
Figure PCTCN2021083026-appb-000008
0表示无雨,1表示小雨,2表示中雨,3表示大雨,4表示暴雨。则第i气象站P i的样本集I i可以表示为
Figure PCTCN2021083026-appb-000009
也可以表示为
Figure PCTCN2021083026-appb-000010
并且,每个样本数据都对应一个样本标识(identity,ID),例如,样本
Figure PCTCN2021083026-appb-000011
的样本标识为1,样本
Figure PCTCN2021083026-appb-000012
的样本标识为2,并以此类推。
Embodiments of the present application relates to the model training between the plurality of weather stations, each for its own weather station meteorological data exists, then, P i represents the i Station, i∈ (1,2,3, ......, M), M is the number of weather stations,
Figure PCTCN2021083026-appb-000001
Q represents the samples of data samples P i of the i-th weather, q∈ (1,2,3, ......, N i), N i is the number of samples P i of the i-th Station, sample data
Figure PCTCN2021083026-appb-000002
Include sample feature set
Figure PCTCN2021083026-appb-000003
And sample label
Figure PCTCN2021083026-appb-000004
Sample feature set
Figure PCTCN2021083026-appb-000005
Sample Station P q i represents the i corresponding feature set (temperature, humidity, wind speed, pressure and other meteorological data), wherein the sample feature set
Figure PCTCN2021083026-appb-000006
T is the number of sample features, sample label
Figure PCTCN2021083026-appb-000007
Q represents sample i of the i-th Station P samples corresponding tag (no rain, drizzle, rain, heavy rain, heavy rain), wherein
Figure PCTCN2021083026-appb-000008
0 means no rain, 1 means light rain, 2 means moderate rain, 3 means heavy rain, and 4 means heavy rain. Station P of the i I i i of the sample set can be expressed as
Figure PCTCN2021083026-appb-000009
Can also be expressed as
Figure PCTCN2021083026-appb-000010
And, each sample data corresponds to a sample identification (identity, ID), for example, the sample
Figure PCTCN2021083026-appb-000011
The sample ID is 1, the sample
Figure PCTCN2021083026-appb-000012
The sample identification is 2, and so on.
本申请具体的实施例中,对样本数据对应的样本标识的命名方式不作限定,各气象站可以自行确认各样本的标识,或由所有参与模型训练的气象站统一确定。In the specific embodiment of the present application, the naming method of the sample identification corresponding to the sample data is not limited, and each weather station can confirm the identification of each sample by itself, or be uniformly determined by all weather stations participating in the model training.
如图2示出了本申请实施例中提供的一种数据终端的样本数据结构,以第一气象站P 1的第一终端上的样本数据为例,如图2所示的第一气象站P 1的样本数据表,I 1表示第一气象站P 1的第一样本集,
Figure PCTCN2021083026-appb-000013
样本数据
Figure PCTCN2021083026-appb-000014
的样本标识为1,样本数据
Figure PCTCN2021083026-appb-000015
的样本标识为2,样本数据
Figure PCTCN2021083026-appb-000016
的样本标识为3,……,
Figure PCTCN2021083026-appb-000017
的样本标识为N 1,样本
Figure PCTCN2021083026-appb-000018
的样本特征集
Figure PCTCN2021083026-appb-000019
包括样本特征
Figure PCTCN2021083026-appb-000020
该样本对应的样本标签为
Figure PCTCN2021083026-appb-000021
图2中示出的表格中,样本标识为1对应的一行为第一气象站P 1样本1的样本数据,该样本数据中包括样本特征
Figure PCTCN2021083026-appb-000022
的值为12,样本特征
Figure PCTCN2021083026-appb-000023
的值为17,样本特征
Figure PCTCN2021083026-appb-000024
的值为10,……,样本特征
Figure PCTCN2021083026-appb-000025
的值为54,样本标签
Figure PCTCN2021083026-appb-000026
为0,样本标识为2对应的一行为气象站P 1样本2的样本数据,以此类推。
Fig. 2 shows a sample data structure of a data terminal provided in an embodiment of the present application. Take the sample data on the first terminal of the first weather station P 1 as an example, the first weather station shown in Fig. 2 The sample data table of P 1 , I 1 represents the first sample set of the first weather station P 1,
Figure PCTCN2021083026-appb-000013
sample
Figure PCTCN2021083026-appb-000014
The sample ID is 1, the sample data
Figure PCTCN2021083026-appb-000015
The sample ID is 2, the sample data
Figure PCTCN2021083026-appb-000016
The samples are identified as 3,……,
Figure PCTCN2021083026-appb-000017
The sample is identified as N 1 , the sample
Figure PCTCN2021083026-appb-000018
Sample feature set
Figure PCTCN2021083026-appb-000019
Include sample characteristics
Figure PCTCN2021083026-appb-000020
The sample label corresponding to this sample is
Figure PCTCN2021083026-appb-000021
In the table shown in Fig. 2, the row corresponding to the sample ID of 1 is the sample data of the first weather station P 1 sample 1, and the sample data includes sample characteristics
Figure PCTCN2021083026-appb-000022
The value is 12, the sample feature
Figure PCTCN2021083026-appb-000023
The value is 17, the sample feature
Figure PCTCN2021083026-appb-000024
The value of is 10,..., the sample feature
Figure PCTCN2021083026-appb-000025
The value is 54, the sample label
Figure PCTCN2021083026-appb-000026
If the value is 0, the sample ID is 2 and the row corresponds to the sample data of the meteorological station P 1 sample 2, and so on.
以第一气象站P 1训练模型为例,介绍第一气象站P 1的第一终端与第二气象站P 2的第二终端在模型训练中的训练过程。图3示出了本申请实施例中提供的一种模型训练过程的流程示意图。由于各气象站模型训练的过程一致,所以图3中仅示出了第一气象站P 1的第一终端的模型训练过程,应理解,当存在M个气象站同时进行模型的训练时,第二气象站P 2到第M气象站P M这M-1个气象站在第一气象站P 1的模型训练中也在本地进行着模型的训练,且模型训练的过程与第一气象站P 1的模型训练过程相同。 Taking the training model of the first weather station P 1 as an example, the training process of the first terminal of the first weather station P 1 and the second terminal of the second weather station P 2 in the model training is introduced. Fig. 3 shows a schematic flowchart of a model training process provided in an embodiment of the present application. Since each of the same weather model training process, so FIG. 3 shows only the first weather model training process P 1 a first terminal, it should be understood that, when there are M meteorological stations simultaneously training model, the The second weather station P 2 to the M -th weather station P M, the M-1 weather station , is also training the model locally during the model training of the first weather station P 1 , and the model training process is the same as that of the first weather station P The model training process of 1 is the same.
S201:第一终端将第一样本集中的每个样本转换为哈希值,得到第一样本集对应的第一哈希表。S201: The first terminal converts each sample in the first sample set into a hash value to obtain a first hash table corresponding to the first sample set.
第一样本集I 1是第一气象站P 1采集的样本的集合,其中包括N 1个样本数据,每个样本包括样本特征集和样本标签,样本特征集包括温度、湿度、风速与气压,所样本标签指示 气象状况。在进行模型的训练之前,需要对数据进行加密处理,对于第一气象站P 1的每个样本数据
Figure PCTCN2021083026-appb-000027
根据L个哈希函数生成L个哈希值
Figure PCTCN2021083026-appb-000028
其中,δ a,b(v)=CosSim(a,v)+b表示为哈希函数,a是一个d维随机向量,v是d维样本数据,b是[0,1]上的一个随机数,该随机数由各气象站自己设定,相应地,{δ k} k=1,2…,L表示取不同的随机向量a和随机数b相对应的L个哈希函数。从而每个样本数据通过哈希函数映射成一个固定长度的字符串,图4示出了本申请实施例中提供的一种数据终端的样本集经过加密后所得到的数据结构示意图。
The first sample set I 1 is a collection of samples collected by the first weather station P 1 , which includes N 1 sample data, each sample includes a sample feature set and a sample label, and the sample feature set includes temperature, humidity, wind speed, and air pressure , The sample label indicates the weather conditions. Before training the model, the data needs to be encrypted. For each sample data of the first weather station P 1
Figure PCTCN2021083026-appb-000027
Generate L hash values according to L hash functions
Figure PCTCN2021083026-appb-000028
Among them, δ a,b (v)=CosSim(a,v)+b represents a hash function, a is a d-dimensional random vector, v is d-dimensional sample data, and b is a random value on [0,1] The random number is set by each weather station. Correspondingly, {δ k } k=1, 2,..., L represents L hash functions corresponding to different random vectors a and random numbers b. Thus, each sample data is mapped into a fixed-length character string through a hash function. FIG. 4 shows a schematic diagram of a data structure obtained after encryption of a sample set of a data terminal provided in an embodiment of the present application.
如图4所示的第一气象站P 1的加密后的样本集的数据结构示意图,第一气象站P 1的样本数据
Figure PCTCN2021083026-appb-000029
经过哈希函数处理后会生成L个哈希函数
Figure PCTCN2021083026-appb-000030
样本数据
Figure PCTCN2021083026-appb-000031
经过哈希函数处理后会生成L个哈希函数
Figure PCTCN2021083026-appb-000032
以此类推,第一气象站P 1一共有N 1个样本,则气象站P 1得到一个N 1*L的第一哈希表。
The data structure diagram of the encrypted sample set of the first weather station P 1 is shown in Fig. 4, and the sample data of the first weather station P 1
Figure PCTCN2021083026-appb-000029
After hash function processing, L hash functions will be generated
Figure PCTCN2021083026-appb-000030
sample
Figure PCTCN2021083026-appb-000031
After hash function processing, L hash functions will be generated
Figure PCTCN2021083026-appb-000032
By analogy, the first weather station P 1 has a total of N 1 samples, and the weather station P 1 obtains a first hash table of N 1 *L.
S202:第二终端将第三样本集中的每个样本转换为哈希值,得到第三样本集对应的第二哈希表,并将第二哈希表发送给第一终端。S202: The second terminal converts each sample in the third sample set into a hash value, obtains a second hash table corresponding to the third sample set, and sends the second hash table to the first terminal.
其中,第三样本集I 2是第二气象站P 2采集的样本,每个样本包括样本特征集和样本标签,样本特征集包括温度、湿度、风速与气压,样本标签指示气象状况,第二哈希表包括第三样本集中每个样本对应的样本标识以及每个样本对应的哈希值。与第一终端类似,对于第二气象站P 2的第三样本集I 2,第二气象站P 2中的第二终端根据哈希函数生成一个N 2*L的第二哈希表,并将第二哈希表发送给第一气象站P 1Among them, the third sample set I 2 is the samples collected by the second weather station P 2. Each sample includes a sample feature set and a sample label. The sample feature set includes temperature, humidity, wind speed and air pressure. The sample label indicates the meteorological condition. The hash table includes a sample identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample. Similar to the first terminal, the second P weather third sample set of the I 2 2, the second terminal of the second weather P 2 N 2 * L to generate a second hash function hash table, and The second hash table is sent to the first weather station P 1 .
应理解,当参与模型训练涉及到M个终端时,参与模型训练的各气象站的终端都会执行上述第二终端的操作,生成各自样本对应的哈希表,并发送给第一终端,即每个气象站P i都会生成一个N i*L的哈希表发送给第一终端,且各气象站使用的哈希函数相同。 It should be understood that when M terminals are involved in model training, the terminals of each weather station participating in model training will perform the operations of the second terminal, generate a hash table corresponding to each sample, and send it to the first terminal. weather stations generates a P i N i * L hash table transmits to the first terminal, and the same hash function used in each of the weather.
S203:第一终端接收第二终端发送的第二哈希表,根据第一哈希表和第二哈希表得到样本标识集,并将样本标识集发送给第二终端。S203: The first terminal receives the second hash table sent by the second terminal, obtains the sample identification set according to the first hash table and the second hash table, and sends the sample identification set to the second terminal.
其中,第二哈希表包括第三样本集中每个样本对应的标识以及每个样本对应的哈希值,第一终端根据第一哈希表和第二哈希表,在第三样本集中确定与第一样本集的每个样本最相似的样本对应的样本标识,从而得到样本标识集。The second hash table includes the identifier corresponding to each sample in the third sample set and the hash value corresponding to each sample. The first terminal determines in the third sample set according to the first hash table and the second hash table. The sample identification corresponding to the most similar sample of each sample in the first sample set, thereby obtaining the sample identification set.
具体地,对于第一哈希表中的某一哈希值,该哈希值对应第一样本集中的某一样本,第一终端从第二哈希表中寻找一个与该哈希值最接近的哈希值,确定该最接近哈希值对应的样本标识,当第一哈希表中对应的每个样本都确定出一个样本标识,所有样本表示的集合即为该样本标识集,则最接近的哈希值对应的样本为该第一样本集中的某一样本的最相似的样本。Specifically, for a certain hash value in the first hash table, the hash value corresponds to a certain sample in the first sample set, and the first terminal searches the second hash table for a hash value that is the closest to the hash value. The closest hash value, the sample ID corresponding to the closest hash value is determined. When each sample in the first hash table has a sample ID determined, the set represented by all samples is the sample ID set, then The sample corresponding to the closest hash value is the most similar sample of a certain sample in the first sample set.
当参与模型训练涉及到M个终端时,样本标识集包括参与模型训练的气象站与第一气象站P 1的本地样本对应的最相似的样本的样本标识,本地样本为第一气象站P 1的第一样本集中的任意一个样本。第一气象站P 1根据接收到的其他气象站的M-1个哈希表,将其他气象站的哈希表与第一哈希表比较,确定其他气象站采集的样本中与第一气象站P 1的第一样本集最相似的样本标识集,即从每个气象站中确定N 1个样本标识,其中每个样本标识对应的样本数据表示与第一气象站P 1的一个样本的样本数据最相似,并将样本标识集发送给参与模型训练的其他M-1个气象站的终端。 When it comes to training the model M participating terminals, Sample ID Sample ID model training set comprises weather stations participating in the first sample a local weather station P corresponding to the most similar samples, a first sample is a local weather station P 1 Any sample in the first sample set. According to the received M-1 hash tables of other weather stations, the first weather station P 1 compares the hash tables of other weather stations with the first hash table, and determines that the samples collected by other weather stations are the same as those of the first weather station. The most similar sample identification set of the first sample set of the station P 1 , that is, N 1 sample identifications are determined from each weather station, where the sample data corresponding to each sample identification represents a sample from the first weather station P 1 The sample data of is the most similar, and the sample identification set is sent to the terminals of other M-1 weather stations participating in the model training.
由于第一气象站P 1有N 1个样本,对于其中的某一个样本q的样本数据
Figure PCTCN2021083026-appb-000033
都能从其他气象站P i(i=2,3,4,…….,M)中找到最相似的样本的样本标识,记为
Figure PCTCN2021083026-appb-000034
当i=1时,最相似的样本为第一气象站P 1的样本本身的样本标识,其中,最相似的样本是通过比较哈希表中单个样本的L个哈希值得出的,由于哈希值为固定长度的字符串,通过比较字符串的大小来寻找最相似的样本,即两个比较的字符串大小最接近,则两个样本最相似。
Since the first weather station P 1 has N 1 samples, the sample data of one of the samples q
Figure PCTCN2021083026-appb-000033
The sample ID of the most similar sample can be found from other weather stations P i (i=2,3,4,……., M), denoted as
Figure PCTCN2021083026-appb-000034
When i = 1, is most similar to the first sample of the sample itself Station P sample identification 1, wherein the most similar samples by comparing L hash hash table is worth a single sample, since ha The value is a fixed-length string, and the most similar sample is found by comparing the size of the string, that is, if the size of the two compared strings is the closest, the two samples are the most similar.
图5示例性示出了第一气象站P 1根据哈希表确定的样本标识集的数据结构示意图。如图5所示的表中,每一行代表第一气象站P 1某一样本与其他气象站最相似的样本的样本标识,每一列代表某一气象站与第一气象站P 1的样本对应的最相似样本的样本标识。以第二气象站P 2为例,图5中的第二列即为第二气象站P 2与第一气象站P 1的样本对应的最相似样本的样本标识,例如,第二气象站P 2中与第一气象站P 1的样本数据
Figure PCTCN2021083026-appb-000035
最相似的样本为第二气象站P 2中样本标识为45所对应的样本数据。
5 exemplarily shows a diagram of a data structure of a hash table to determine sample identification set a first weather P. In the table shown in Figure 5, each row represents the sample identification of a sample of the first weather station P 1 that is most similar to other weather stations, and each column represents a weather station corresponding to the sample of the first weather station P 1 The sample ID of the most similar sample. Taking the second weather station P 2 as an example, the second column in Fig. 5 is the sample identification of the most similar sample corresponding to the samples of the second weather station P 2 and the first weather station P 1, for example, the second weather station P 2 and the sample data of the first weather station P 1
Figure PCTCN2021083026-appb-000035
The most similar sample is the sample data corresponding to the sample ID 45 in the second weather station P 2.
需要说明的是,由于寻找的是第一气象站P 1的相似样本,第一气象站P 1有N 1个样本,则其他每个气象站都要找到N 1个样本标识与第一气象站P 1中的样本一一对应,即第一气象站P 1得到的一个N 1*M的样本标识集S 1。例如,第一气象站P 1有100个样本,第二气象站P 2有150个样本,对于第一气象站P 1中的每个样本,第一气象站P 1从第二气象站P 2中确定一个最相似样本的样本标识,其中,从第二气象站P 2中确定的100个最相似样本的样本标识可能各不相同,也可能部分相同。可以看出,当寻找的是第i气象站P i的相似样本时,则第i气象站P i会得到一个样本标识集S i∈N i×M,并将该样本标识集广播出去。 Incidentally, since the first weather station is looking for similar samples P 1, P 1 have a first weather the N 1 samples, the weather station must find each other the N 1 in the first sample identity Station N 1 * M of a sample identity P 1 set in correspondence sample, i.e., a first obtained Station P 1 S 1. For example, there are a first weather station 100 samples P 1, P 2 of the second weather station 150 samples, for each sample of the first weather P 1, P 1 from the first weather second weather P 2 The sample ID of a most similar sample is determined in P 2 , where the sample IDs of the 100 most similar samples determined from the second weather station P 2 may be different, or may be partly the same. As can be seen, when looking for similar samples of the P i when i Station, Station P i is the i-th sample identity will get a set S i ∈N i × M, and the set of sample identity broadcasted.
S204:第一终端根据第一样本集中的每个样本,计算待训练模型的损失函数的一阶梯度集和二阶梯度集。S204: The first terminal calculates the first step set and the second step set of the loss function of the model to be trained according to each sample in the first sample set.
其中,所述一阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述二阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的。利用公式
Figure PCTCN2021083026-appb-000036
Figure PCTCN2021083026-appb-000037
计算第一气象站P 1的某一个样本q的一阶梯度 g 1q和二阶梯度h 1q,其中,
Figure PCTCN2021083026-appb-000038
表示第一气象站P 1的样本i的样本标签,
Figure PCTCN2021083026-appb-000039
表示样本i的预测值,由于此时还没有训练模型,在构建第一棵树时,该预测值为给定的初始值,函数l()表示待训练模型的损失函数,函数l′()表示损失函数的一阶导数,函数l″()表示损失函数的二阶导数,第一气象站P 1的某一个样本q为第一气象站P 1的第一样本集中的任意一个样本,即第一气象站P 1的每一个样本都要计算一阶梯度和二阶梯度。
Wherein, a gradient value in the first step set is calculated based on a sample in the first sample set, and a gradient value in the second step set is calculated based on a sample in the first sample set. Use formula
Figure PCTCN2021083026-appb-000036
with
Figure PCTCN2021083026-appb-000037
Calculate the first step g 1q and the second step h 1q of a sample q of the first weather station P 1 , where,
Figure PCTCN2021083026-appb-000038
Represents the sample label of sample i of the first weather station P 1,
Figure PCTCN2021083026-appb-000039
Represents the predicted value of sample i. Since there is no training model yet, when constructing the first tree, the predicted value is the given initial value. Function l() represents the loss function of the model to be trained, function l′() loss function represents the first derivative of the function l "() represents the second derivative of the loss function, a first sample of a weather station P Q 1 is any one of a first sample a first Station P concentration sample, That is, for each sample of the first weather station P 1 , the first gradient and the second gradient must be calculated.
应理解,当参与模型训练涉及到M个终端时,参与模型训练的每个气象站的终端都要执行上述第一气象站P 1的操作:使用样本集计算损失函数的一阶梯度和二阶梯度,其中,本申请对损失函数的选取不作限制,例如,损失函数可以选择logloss。 It should be understood that when the participating model training involves M terminals, the terminal of each weather station participating in the model training must perform the operation of the first weather station P 1 described above: use the sample set to calculate the first step and the second step of the loss function In this application, the selection of the loss function is not limited. For example, the loss function can be logloss.
S205:第二终端接收第一终端发送的样本标识集,根据样本标识集在第三样本集中确定第二样本集,根据第二样本集中的每个样本,计算待训练模型的损失函数的聚合一阶梯度集和聚合二阶梯度集,并将聚合一阶梯度集和聚合二阶梯度集发送给第一终端。S205: The second terminal receives the sample identification set sent by the first terminal, determines the second sample set in the third sample set according to the sample identification set, and calculates the aggregation of the loss function of the model to be trained according to each sample in the second sample set. The level set and the aggregated second level set, and the aggregated first level set and the aggregated second level set are sent to the first terminal.
其中,第二样本集包括在第三样本集中确定的与第一样本集中每个样本最相似的样本,第二气象站P 2的第二终端接收到第一气象站P 1的第一终端发送的样本标识集,该标识集中的每个样本标识指示第三样本集中的一个样本,第二终端根据样本标识集从第三样本集中找到第二样本集。同样利用公式
Figure PCTCN2021083026-appb-000040
Figure PCTCN2021083026-appb-000041
来计算第二样本集的损失函数的聚合一阶梯度集和聚合二阶梯度集,并发送给第一气象站P 1,其中,
Figure PCTCN2021083026-appb-000042
表示第二气象站P 2的样本q的样本标签,
Figure PCTCN2021083026-appb-000043
表示样本q的预测值,由于此时还没有训练模型,在构建第一棵树时,该预测值为给定的初始值,函数l()表示待训练模型的损失函数,函数l′()表示损失函数的一阶导数,函数l″()表示损失函数的二阶导数。由于第一气象站P 1总共有N 1个样本,因此第二终端一共计算出N 1个聚合一阶梯度和N 1个聚合二阶梯度。应理解,这N 1个聚合一阶梯度可能各不相同,也可能部分相同,同理,这N 1个聚合二阶梯度可能各不相同,也可能部分相同。
Wherein, the second sample set includes the samples that are most similar to each sample in the first sample set determined in the third sample set, and the second terminal of the second weather station P 2 receives the first terminal of the first weather station P 1 The sent sample identification set, each sample identification in the identification set indicates a sample in the third sample set, and the second terminal finds the second sample set from the third sample set according to the sample identification set. Also use the formula
Figure PCTCN2021083026-appb-000040
with
Figure PCTCN2021083026-appb-000041
To calculate the aggregate first degree set and aggregate second degree set of the loss function of the second sample set, and send it to the first weather station P 1 , where,
Figure PCTCN2021083026-appb-000042
Represents the sample label of sample q of the second weather station P 2,
Figure PCTCN2021083026-appb-000043
Indicates the predicted value of the sample q. Since there is no training model at this time, when the first tree is constructed, the predicted value is a given initial value. The function l() represents the loss function of the model to be trained, and the function l'() Represents the first derivative of the loss function, and the function l″() represents the second derivative of the loss function. Since the first weather station P 1 has a total of N 1 samples, the second terminal calculates a total of N 1 aggregation steps and N 1 polymerized second steps. It should be understood that these N 1 polymerized first steps may be different, or may be partly the same, and similarly, the N 1 polymerized second steps may be different or partly the same.
应理解,当参与模型训练涉及到M个终端时,参与模型训练的每个气象站的终端都会执行上述第二终端的操作,即根据接收到的样本标识集找到相似样本集,计算相似样本集的聚合一阶梯度集和聚合二阶梯度集并发送给第一气象站。It should be understood that when M terminals are involved in model training, the terminal of each weather station participating in model training will perform the operation of the second terminal, that is, find similar sample sets based on the received sample identification set, and calculate similar sample sets. The aggregated first-order degree set and aggregated second-order degree set are sent to the first weather station.
例如,当参与模型训练的气象站还包括第三气象站P 3、第四气象站P 4、……、第M气象站P M时,第三气象站的终端根据第一气象站发送的样本标识集,找到第三气象站中与第一气象站相似的样本,计算出相似样本的梯度值发送给第一气象站,第四气象站的终端根据第一气象站发送的样本标识集,找到第四气象站中与第一气象站相似的样本,计算出相似样本的梯度值发送给第一气象站,并以此类推,从而第一气象站会得到第一样本集的梯度值外,还会得到参与模型训练的其他气象站中与第一样本集相似的样本的梯度值。 For example, when the weather model training involved in further comprising a third sample Station P 3, the fourth weather P 4, ......, the first weather M P M, the third terminal transmits a weather station in accordance with a first weather Identification set, find the sample similar to the first weather station in the third weather station, calculate the gradient value of the similar sample and send it to the first weather station, the terminal of the fourth weather station finds the sample identification set sent by the first weather station In the fourth weather station similar to the first weather station, the gradient value of the similar sample is calculated and sent to the first weather station, and so on, so that the first weather station will get the gradient value of the first sample set, The gradient values of samples similar to the first sample set in other weather stations participating in the model training will also be obtained.
S206:第一终端接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚 合二阶梯度集,并根据一阶梯度集、聚合一阶梯度集、二阶梯度集、聚合二阶梯度集以及第一样本集,对待训练模型进行训练,得到训练好的模型。S206: The first terminal receives the aggregated first degree set and aggregated second degree set calculated according to the second sample set sent by the second terminal, and aggregates the first degree set, aggregates first degree set, second degree set, and aggregates The second step set and the first sample set are trained on the model to be trained to obtain a trained model.
(1)、第一终端根据聚合一阶梯度集和一阶梯度集更新第一样本集的一阶梯度集得到一阶样本梯度集,根据聚合二阶梯度集和二阶梯度集更新第一样本集的二阶梯度集得到二阶样本梯度集。(1) The first terminal updates the first-order gradient set of the first sample set according to the aggregation of the first-order degree set and the first-order degree set to obtain the first-order sample gradient set, and updates the first-order sample gradient set according to the aggregated second-order degree set and the second-order degree set. The second-order gradient set of the sample set obtains the second-order sample gradient set.
当参与模型训练的气象站只包括第一气象站P 1和第二气象站P 2时,对于第一样本集中的某一样本数据,第一终端将该样本数据的损失函数的一阶梯度与第二气象站P 2中与该样本数据最相似的样本对应的聚合一阶梯度之和,作为该样本数据的一阶样本梯度,将该样本数据的损失函数的二阶梯度与第二气象站P 2中与该样本数据最相似的样本对应的聚合二阶梯度之和,作为该样本数据的二阶样本梯度。从而第一终端得到第一气象站P 1的第一样本集的一阶样本梯度集和二阶样本梯度集。 When the weather stations participating in the model training only include the first weather station P 1 and the second weather station P 2 , for a certain sample data in the first sample set, the first terminal has a step of the loss function of the sample data The sum of the aggregate first-order gradient corresponding to the sample most similar to the sample data in the second weather station P 2 is taken as the first-order sample gradient of the sample data, and the second-order gradient of the loss function of the sample data is compared with that of the second weather The sum of the aggregated second-order gradients corresponding to the samples most similar to the sample data in the station P 2 is used as the second-order sample gradient of the sample data. Whereby a first terminal to obtain a set of first-order gradient Sample Station P 1 of a first set of samples and the second order gradient of the sample set.
应理解,当参与模型训练涉及到M个终端时,第一气象站P 1的第一终端接收到其他气象站的终端发送的聚合一阶梯度集和聚合二阶梯度集,对于第一气象站P 1的任意一个样本q,第一气象站P 1得到聚合一阶梯度
Figure PCTCN2021083026-appb-000044
和聚合二阶梯度
Figure PCTCN2021083026-appb-000045
则第一气象站P 1的第一终端根据
Figure PCTCN2021083026-appb-000046
更新样本q的一阶样本梯度G 1q,根据
Figure PCTCN2021083026-appb-000047
更新
Figure PCTCN2021083026-appb-000048
的二阶样本梯度H 1q,并且,第一气象站P 1的每个样本都要更新一阶梯度和二阶梯度,为模型的训练做准备。
It should be understood that when M terminals are involved in participating in model training, the first terminal of the first weather station P 1 receives the aggregated first degree set and aggregated second degree set sent by terminals of other weather stations. For the first weather station, 1, a sample of any P q, P 1 obtained weather first step a degree of polymerization
Figure PCTCN2021083026-appb-000044
And the degree of aggregation
Figure PCTCN2021083026-appb-000045
Then the first terminal of the first weather station P 1 is based on
Figure PCTCN2021083026-appb-000046
Update the first-order sample gradient G 1q of sample q, according to
Figure PCTCN2021083026-appb-000047
renew
Figure PCTCN2021083026-appb-000048
The second-order sample gradient of H 1q , and each sample of the first weather station P 1 must update the first step and the second step to prepare for the training of the model.
(2)、第一终端使用第一样本集和一阶样本梯度集、二阶样本梯度集训练XGBOOST模型,从而得到针对第一气象站P 1的待预测模型。 (2) The first terminal uses the first sample set, the first-order sample gradient set, and the second-order sample gradient set to train the XGBOOST model, so as to obtain the model to be predicted for the first weather station P 1.
在训练第一气象站P 1的气象预测模型的过程中,将第一样本集的一阶样本梯度集和二阶样本梯度集作为第一样本集训练时的一阶梯度集和二阶梯度集,训练模型的第一棵梯度树。 In the process of training the meteorological prediction model of the first weather station P 1 , the first-order sample gradient set and the second-order sample gradient set of the first sample set are used as the first-order gradient set and the second-order gradient set during the training of the first sample set. Degree set, the first gradient tree of the training model.
由于训练模型的过程就是不断构建回归树的过程,具体地,在构建第一棵树时,需要在根节点处进行分裂,并在节点处把第一样本集分成左子节点和右子节点两个集合,并利用样本的样本梯度值计算两个集合的G L、G R、H L、H R,再利用公式: Since the process of training the model is the process of continuously building the regression tree, specifically, when building the first tree, it is necessary to split at the root node, and divide the first sample set into a left child node and a right child node at the node. Two sets, and use the sample gradient value of the sample to calculate the G L , G R , H L , H R of the two sets, and then use the formula:
Figure PCTCN2021083026-appb-000049
Figure PCTCN2021083026-appb-000049
计算出增益,将增益值Gain的最大值作为判断最优分裂点的标准。Calculate the gain, and use the maximum value of the gain value as the criterion for judging the optimal split point.
其中G L代表如果分裂后左叶子节点中样本点的集合的一阶样本梯度之和,G R代表如果分裂后右叶子节点中样本点的集合的一阶样本梯度之和,H L代表如果分裂后左叶子节点中样本点的集合的二阶样本梯度之和,H R代表如果分裂后右叶子节点中样本点的集合的二阶样本梯度之和。 Wherein the set of left leaf nodes of sample points after G L Representative if splitting a first order sample gradients and, first order sample gradients and, H L that represents a collection of G R representative of the right leaf node if dividing sample points if split The sum of the second-order sample gradients of the set of sample points in the rear left leaf node, and H R represents the sum of the second-order sample gradients of the set of sample points in the right leaf node after the split.
首先需要根据不同的分裂点来确定划分区间,将第一样本集划分成左子节点和右子节 点两个集合,那么,这个分裂点则是利用样本数据的样本特征集来确定的,然后重复计算不同划分点下的增益Gain。First, the division interval needs to be determined according to different split points. The first sample set is divided into two sets of left child nodes and right child nodes. Then, this split point is determined by the sample feature set of the sample data, and then Repeatedly calculate the gain under different division points.
例如,对于样本特征
Figure PCTCN2021083026-appb-000050
若对于样本特征
Figure PCTCN2021083026-appb-000051
在气象站P 1的样本数据中有{12,15,20,30,35}这些数据值,则分别以12、15、20、30、35为划分点计算增益Gain。再以同样的方法遍历下一个样本特征,计算增益Gain,并以此类推。
For example, for sample features
Figure PCTCN2021083026-appb-000050
If for sample characteristics
Figure PCTCN2021083026-appb-000051
There 12,15,20,30,35} {weather data values in the sample data P 1, respectively, to the division point is calculated as 12,15,20,30,35 gain Gain. Then traverse the next sample feature in the same way, calculate the gain Gain, and so on.
以增益Gain最大的分裂点作为根节点,并得出分裂后左右子节点的样本集合,然后根据树的深度判断是否继续分裂,若分裂后的子节点只剩一个样本时,则该节节点不需要再进行分裂,该节点变为叶子节点,则根据公式:Take the split point with the largest gain as the root node, and get the sample set of the left and right child nodes after the split, and then judge whether to continue the split according to the depth of the tree. If there is only one sample left in the child node after the split, the node is not Need to split again, the node becomes a leaf node, according to the formula:
Figure PCTCN2021083026-appb-000052
Figure PCTCN2021083026-appb-000052
计算该叶子节点的权重。其中,其中,
Figure PCTCN2021083026-appb-000053
为落入叶子i所有样本一阶样本梯度统计值的总和,
Figure PCTCN2021083026-appb-000054
为落入叶子i所有样本二阶样本梯度统计值总和。
Calculate the weight of the leaf node. Among them,
Figure PCTCN2021083026-appb-000053
Is the sum of the first-order sample gradient statistics of all samples falling into leaf i,
Figure PCTCN2021083026-appb-000054
It is the sum of the second-order sample gradient statistics of all samples falling into leaf i.
若未达到树的深度时,继续对左右子节点进行上述相同的分裂操作,即将子节节点看作根节点循环上述过程。If the depth of the tree is not reached, the same split operation is continued on the left and right child nodes, that is, the child node is regarded as the root node and the above process is repeated.
若达到树的深度时,则树的节点不能再进行分裂,计算叶子节点的权重
Figure PCTCN2021083026-appb-000055
从而训练完成第一棵梯度树。
If the depth of the tree is reached, the nodes of the tree can no longer be split, and the weight of the leaf nodes is calculated
Figure PCTCN2021083026-appb-000055
Thus, the first gradient tree is trained.
在构建第t(t>1)课树时,训练过程与前面t-1棵树的过程完全一样,但是树的输入参数不再是第一棵树所用到的初始输入参数G 1q、H 1q,由于第t棵树是在前t-1棵树的基础上进行拟合的,此时的一阶梯度
Figure PCTCN2021083026-appb-000056
和二阶梯度
Figure PCTCN2021083026-appb-000057
需要用到前t-1棵树组成的模型对第i个训练样本的预测值
Figure PCTCN2021083026-appb-000058
从而继续基于分裂点计算增益Gain,最终确定本轮梯度树构建所需的最优分割点和最优权重。
When constructing the tree for lesson t (t>1), the training process is exactly the same as that of the previous t-1 tree, but the input parameters of the tree are no longer the initial input parameters G 1q and H 1q used by the first tree. , Since the t-th tree is fitted on the basis of the previous t-1 trees, the first step at this time is
Figure PCTCN2021083026-appb-000056
And second degree
Figure PCTCN2021083026-appb-000057
Need to use the predicted value of the i-th training sample by the model composed of the first t-1 trees
Figure PCTCN2021083026-appb-000058
Therefore, the gain gain is calculated based on the split point, and the optimal split point and optimal weight required for the current round of gradient tree construction are finally determined.
当样本特征集中的所有样本特征都用在了模型的构建上时,该XGBOOST模型训练完成。When all the sample features in the sample feature set are used in the construction of the model, the XGBOOST model training is completed.
应理解,当参与模型训练涉及到M个终端时,进行模型训练的气象站的终端都要执行上述第一气象站P 1的第一终端的操作,参与模型训练的气象站的终端都要执行上述第二气象站P 2的第二终端的操作。可以看出,对于一个气象站而言,该气象站不仅使用到了其他气象站的样本数据来训练模型,还获得了一个针对本气象站的预测模型。 It should be understood, when it comes to training the model M participating terminals, a terminal model training weather stations have to perform a first operation of the first terminal Station P 1, model training weather stations participating terminal have to perform Operation of the second terminal of the second weather station P 2 described above. It can be seen that for a weather station, the weather station not only uses the sample data of other weather stations to train the model, but also obtains a prediction model for the weather station.
S207:第一终端基于训练好的模型,对待预测样本进行预测,确定待预测样本的预测结果。S207: The first terminal predicts the sample to be predicted based on the trained model, and determines the prediction result of the sample to be predicted.
第一终端在训练得到了气象事件预测模型后,可以使用待预测样本来预测某一事件的气象状况。即,将待预测样本中的样本特征集代入训练好的回归树,每个样本特征最终会落在一棵回归树的一个叶子节点,将所有树得到的叶子节点的权重值加起来即为该事件的气象预测值,然后通过比较该结果值最接近于哪一个样本标签的数值,该样本标签对应的气象状况(无雨、小雨、中雨、大雨、暴雨)即为该待预测样本的预测结果。After the first terminal has trained the meteorological event prediction model, it can use the sample to be predicted to predict the meteorological condition of a certain event. That is, the sample feature set in the sample to be predicted is substituted into the trained regression tree, and each sample feature will eventually fall on a leaf node of a regression tree. Add up the weight values of the leaf nodes obtained from all trees to obtain this The weather forecast value of the event, and then by comparing the result value to the value of which sample label is the closest, the meteorological condition (no rain, light rain, moderate rain, heavy rain, heavy rain) corresponding to the sample label is the forecast of the sample to be predicted result.
可以看出,本方法利用联邦学习的思想,从模型训练参与方的样本数据中寻找与模型训练方的样本相似的样本来扩大训练的样本集,从而构建出更准确的模型,同时,该方法找出相似样本后,并不是直接发送样本数据给模型训练方,而是发送相似样本的损失函数的梯度值,避免了数据泄露的问题,该方法还支持多个终端同时训练模型,有效提高了模型的计算效率。It can be seen that this method uses the idea of federated learning to find samples similar to the samples of the model training party from the sample data of the model training participants to expand the training sample set, thereby constructing a more accurate model. At the same time, this method After finding the similar samples, instead of sending the sample data directly to the model trainer, it sends the gradient value of the loss function of the similar sample, avoiding the problem of data leakage. This method also supports multiple terminals to train the model at the same time, which effectively improves The computational efficiency of the model.
图6是本申请实施例提供的一种气象事件预测装置的示意图,该装置能够执行上述第一终端和第二终端的操作,该气象事件预测装置100包括接收单元101、处理单元102以及发送单元103。其中,当该气象事件预测装置100执行第一终端的操作时:6 is a schematic diagram of a meteorological event prediction device provided by an embodiment of the present application, which can perform the operations of the first terminal and the second terminal described above. The meteorological event prediction device 100 includes a receiving unit 101, a processing unit 102, and a sending unit 103. Wherein, when the weather event prediction apparatus 100 performs the operation of the first terminal:
接收单元101,用于接受第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集,所述第二样本集包括与第一样本集中每个样本相似的样本;接收第二终端发送的第二哈希表,所述第二哈希表包括第三样本集中每个样本对应的样本标识以及每个样本对应的哈希值。The receiving unit 101 is configured to receive the aggregate first degree set and the aggregate second degree set calculated according to the second sample set sent by the second terminal, and the second sample set includes information similar to each sample in the first sample set. Sample; receiving a second hash table sent by the second terminal, the second hash table including a sample identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample.
处理单元102,用于根据第一样本集中的每个样本,计算待训练模型的损失函数的一阶梯度集和二阶梯度集,其中,所述一阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述二阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述第一样本集是第一气象站采集的样本的集合;根据一阶梯度集、聚合一阶梯度集、二阶梯度集、聚合二阶梯度集以及第一样本集,对待训练模型进行训练,得到训练好的模型;将所述第一样本集中的每个样本转换为哈希值,得到第一样本集对应的第一哈希表;根据第一哈希表和第二哈希表,在第三样本集中确定与所述第一样本集的每个样本最相似的样本对应的样本标识,得到样本标识集。The processing unit 102 is configured to calculate the first step set and the second step set of the loss function of the model to be trained according to each sample in the first sample set, wherein a gradient value in the first step set is based on the first step The same is calculated from a sample in this set, a gradient value in the second gradient set is calculated based on a sample in the first sample set, and the first sample set is a sample collected by the first weather station According to the first step set, the first step set, the second step set, the second step set, and the first sample set, the training model is trained to obtain a trained model; the first is the same Each sample in this set is converted into a hash value to obtain the first hash table corresponding to the first sample set; according to the first hash table and the second hash table, the third sample set is The sample ID corresponding to the most similar sample of each sample in the sample set is obtained.
发送单元103,用于将样本标识集发送给第二终端,以使第二终端根据样本标识集中的样本标识确定所述第二样本集。The sending unit 103 is configured to send the sample identification set to the second terminal, so that the second terminal determines the second sample set according to the sample identification in the sample identification set.
当该气象事件预测装置100执行第二终端的操作时:When the weather event prediction device 100 performs the operation of the second terminal:
接收单元101,用于接收第一终端发送的样本标识集,所述样本标识集中的每个样本标识指示第三样本集中的一个样本。The receiving unit 101 is configured to receive a sample identification set sent by the first terminal, where each sample identification in the sample identification set indicates a sample in the third sample set.
处理单元102,用于将第三样本集中的每个样本转换为哈希值,得到第三样本集对应的第二哈希表;根据标识集在所述第三样本集中确定第二样本集,根据第二样本集中的每个样本,计算待训练模型的损失函数的聚合一阶梯度集和聚合二阶梯度集,并将聚合一阶梯度集和聚合二阶梯度集发送给第一终端。The processing unit 102 is configured to convert each sample in the third sample set into a hash value to obtain a second hash table corresponding to the third sample set; determine the second sample set in the third sample set according to the identification set, According to each sample in the second sample set, calculate the aggregate first degree set and aggregate second degree set of the loss function of the model to be trained, and send the aggregate first degree set and aggregate second degree set to the first terminal.
发送单元103,用于将第二哈希表发送给第一终端,所述第二哈希表包括第三样本集中每个样本对应的样本标识以及每个样本对应的哈希值,所述第三样本集是第二气象站采集的样本。The sending unit 103 is configured to send a second hash table to the first terminal. The second hash table includes a sample identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample. The third sample set is the sample collected by the second weather station.
具体的,上述气象事件预测装置100实现对气象事件的预测可参照上述方法实施例中第一终端的相关操作,在此不再具体描述。Specifically, the meteorological event prediction apparatus 100 described above can refer to the related operations of the first terminal in the foregoing method embodiment for predicting meteorological events, which will not be described in detail here.
图7是本申请实施例提供的一种计算设备的结构示意图,该计算设备200包括:处理器210、通信接口220以及存储器230,处理器210、通信接口220以及存储器230通过总线240相互连接,其中,该处理器210用于执行该存储器230存储的指令。该存储器230存储程序代码,且处理器210可以调用存储器230中存储的程序代码执行以下操作:FIG. 7 is a schematic structural diagram of a computing device provided by an embodiment of the present application. The computing device 200 includes a processor 210, a communication interface 220, and a memory 230. The processor 210, the communication interface 220, and the memory 230 are connected to each other through a bus 240, The processor 210 is configured to execute instructions stored in the memory 230. The memory 230 stores program codes, and the processor 210 can call the program codes stored in the memory 230 to perform the following operations:
气象事件预测装置根据第一样本集中的每个样本,计算待训练模型的损失函数的一阶梯度集和二阶梯度集,其中,所述一阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述二阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述第一样本集是第一气象站采集的样本的集合;接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集,所述第二样本集包括与所述第一样本集中每个样本相似的样本;根据所述一阶梯度集、所述聚合一阶梯度集、所述二阶梯度集、所述聚合二阶梯度集以及所述第一样本集,对所述待训练模型进行训练,得到训练好的模型;基于所述训练好的模型,对待预测样本进行预测,确定待预测样本的预测结果。The meteorological event prediction device calculates the first step set and the second step set of the loss function of the model to be trained according to each sample in the first sample set, wherein a gradient value in the first step set is based on the first step. Calculated from a sample in this set, a gradient value in the second gradient set is calculated based on a sample in the first sample set, and the first sample set is a set of samples collected by the first weather station Receiving the aggregated first-order degree set and aggregated second-order degree set calculated according to the second sample set sent by the second terminal, the second sample set including samples similar to each sample in the first sample set; The first step degree set, the aggregated first step degree set, the second step degree set, the aggregated second step degree set, and the first sample set are trained on the model to be trained, and the training is good The model; based on the trained model, predict the sample to be predicted, and determine the prediction result of the sample to be predicted.
在本申请实施例中处理器210可以有多种具体实现形式,例如处理器210可以为中央处理器(central processing unit,CPU)、图形处理器(graphics processing unit,GPU)、张量处理单元(tensor processing unit,TPU)或神经网络处理器(neural network processing unit,NPU)等处理器中任意一种或多种的组合,处理器210还可以是单核处理器或多核处理器。处理器210可以由CPU(GPU、TPU或NPU)和硬件芯片的组合。上述硬件芯片可以是专用集成电路(application-specific integrated circuit,ASIC)、可编程逻辑器件(programmable logic device,PLD)或其组合。上述PLD复杂程序逻辑器件(complex programmable logical device,CPLD),现场可编程门阵列(field-programmable gate array,FPGA),通用阵列逻辑(generic array logic,GAL)或其任意组合。处理器210也可以单独采用内置处理逻辑的逻辑器件来实现,例如FPGA或数字信号处理器(digital signal processor,DSP)等。In the embodiment of the present application, the processor 210 may have a variety of specific implementation forms. For example, the processor 210 may be a central processing unit (CPU), a graphics processing unit (GPU), or a tensor processing unit ( A tensor processing unit (TPU) or a neural network processing unit (NPU) or a combination of any one or more of the processors. The processor 210 may also be a single-core processor or a multi-core processor. The processor 210 may be a combination of a CPU (GPU, TPU, or NPU) and a hardware chip. The above-mentioned hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The above-mentioned PLD complex programmable logic device (CPLD), field-programmable gate array (FPGA), generic array logic (GAL) or any combination thereof. The processor 210 may also be implemented solely by a logic device with built-in processing logic, such as an FPGA or a digital signal processor (digital signal processor, DSP).
通信接口220可以为有线接口或无线接口,用于与其他模块或设备进行通信,有线接口可以是以太接口、控制器局域网络(controller area network,CAN)接口或局域互联网络(local interconnect network,LIN)接口,无线接口可以是蜂窝网络接口或使用无线局域网接口等。The communication interface 220 can be a wired interface or a wireless interface for communicating with other modules or devices. The wired interface can be an Ethernet interface, a controller area network (CAN) interface, or a local interconnect network (local interconnect network, LIN) interface. The wireless interface can be a cellular network interface or a wireless LAN interface.
存储器230可以是非易失性存储器,例如,只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。存储器230也可以是易失性存储器,易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。The memory 230 may be a non-volatile memory, for example, read-only memory (ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), Electrically erasable programmable read-only memory (EPROM, EEPROM) or flash memory. The memory 230 may also be a volatile memory, and the volatile memory may be a random access memory (random access memory, RAM), which is used as an external cache.
存储器230也可用于存储指令和数据,以便于处理器210调用存储器230中存储的指令实现上述处理单元103执行的操作或述方法实施例气象事件预测装置执行的操作。此外,计算设备200可能包含相比于图7展示的更多或者更少的组件,或者有不同的组件配置方式。The memory 230 may also be used to store instructions and data, so that the processor 210 can call the instructions stored in the memory 230 to implement the operations performed by the processing unit 103 described above or the operations performed by the meteorological event prediction apparatus in the method embodiment. In addition, the computing device 200 may include more or fewer components than those shown in FIG. 7, or may have different component configurations.
总线240可以分为地址总线、数据总线、控制总线等。为便于表示,图6中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The bus 240 can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in FIG. 6, but it does not mean that there is only one bus or one type of bus.
可选地,该计算设备200还可以包括输入/输出接口250,输入/输出接口250连接有输入/输出设备,用于接收输入的信息,输出操作结果。Optionally, the computing device 200 may further include an input/output interface 250 to which an input/output device is connected to the input/output interface 250 for receiving input information and outputting operation results.
应理解,本申请实施例的计算设备200可对应于上述实施例中的数据处理装置100,并可执行上述方法实施例中气象事件预测装置执行的操作,在此不再赘述。It should be understood that the computing device 200 in the embodiment of the present application may correspond to the data processing apparatus 100 in the above-mentioned embodiment, and can perform operations performed by the meteorological event prediction apparatus in the above-mentioned method embodiment, which will not be repeated here.
本申请实施例还提供一种计算机(可读)存储介质,其中,所述计算机可读存储介质 存储有计算机程序(或指令),所述计算机程序被处理器执行以实现上述方法。可选的,本申请涉及的存储介质如计算机可读存储介质可以是非易失性的(如非瞬态计算机存储介质),也可以是易失性的。例如,本申请提供一种非瞬态计算机存储介质,计算机存储介质中存储有指令,当其在处理器上运行时,可以实现上述方法实施例中的方法步骤,计算机存储介质的处理器在执行上述方法步骤的具体实现可参照上述方法实施例的具体操作,在此不再赘述。An embodiment of the present application also provides a computer (readable) storage medium, wherein the computer readable storage medium stores a computer program (or instruction), and the computer program is executed by a processor to implement the above method. Optionally, the storage medium involved in this application, such as a computer-readable storage medium, may be non-volatile (such as a non-transitory computer storage medium) or volatile. For example, this application provides a non-transitory computer storage medium. The computer storage medium stores instructions. When it runs on a processor, it can implement the method steps in the above method embodiments, and the processor of the computer storage medium is executing For the specific implementation of the steps of the foregoing method, reference may be made to the specific operations of the foregoing method embodiments, and details are not described herein again.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the description of each embodiment has its own focus. For a part that is not described in detail in an embodiment, reference may be made to related descriptions of other embodiments.
上述实施例,可以全部或部分地通过软件、硬件、固件或其他任意组合来实现。当使用软件实现时,上述实施例可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载或执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以为通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集合的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质、或者半导体介质,半导体介质可以是固态硬盘。The above-mentioned embodiments may be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented using software, the above-mentioned embodiments may be implemented in the form of a computer program product in whole or in part. The computer program product includes one or more computer instructions. When the computer program instructions are loaded or executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center. Transmission to another website, computer, server or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more sets of available media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium, or a semiconductor medium, and the semiconductor medium may be a solid state hard disk.
以上所述,仅为本申请的具体实施方式。熟悉本技术领域的技术人员根据本申请提供的具体实施方式,可想到变化或替换,都应涵盖在本申请的保护范围之内。The above are only specific implementations of this application. Those skilled in the art can think of changes or substitutions according to the specific implementation manners provided by this application, and they should all be covered by the protection scope of this application.

Claims (20)

  1. 一种气象事件预测方法,其中,所述气象件预测方法应用于气象预测系统,所述气象预测系统包括位于第一气象站的第一终端和位于第二气象站的第二终端,所述方法包括:A method for predicting meteorological events, wherein the method for predicting meteorological items is applied to a meteorological forecasting system, and the meteorological forecasting system includes a first terminal located at a first weather station and a second terminal located at a second weather station, the method include:
    第一终端根据第一样本集中的每个样本,计算待训练模型的损失函数的一阶梯度集和二阶梯度集,其中,所述一阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述二阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述第一样本集是第一气象站采集的样本的集合;The first terminal calculates the first step set and the second step set of the loss function of the model to be trained according to each sample in the first sample set, wherein a gradient value in the first step set is based on the first sample A sample in the set is calculated, a gradient value in the second gradient set is calculated based on a sample in a first sample set, and the first sample set is a set of samples collected by a first weather station;
    所述第一终端接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集,所述第二样本集包括与所述第一样本集中每个样本相似的样本;The first terminal receives the aggregated first-stage degree set and aggregated second-stage degree set calculated according to a second sample set sent by the second terminal, and the second sample set includes each sample that is similar to each sample in the first sample set. Sample of
    所述第一终端根据所述一阶梯度集、所述聚合一阶梯度集、所述二阶梯度集、所述聚合二阶梯度集以及所述第一样本集,对所述待训练模型进行训练,得到训练好的模型;The first terminal performs an evaluation on the model to be trained according to the first degree set, the aggregated first degree set, the second degree set, the aggregated second degree set, and the first sample set Perform training and get a trained model;
    所述第一终端基于所述训练好的模型,对待预测样本进行预测,确定待预测样本的预测结果。The first terminal predicts the sample to be predicted based on the trained model, and determines the prediction result of the sample to be predicted.
  2. 根据权利要求1所述的方法,其中,所述每个样本包括样本特征集和样本标签,所述样本特征集包括温度、湿度、风速与气压,所述样本标签指示气象状况。The method according to claim 1, wherein each sample includes a sample feature set and a sample label, the sample feature set includes temperature, humidity, wind speed, and air pressure, and the sample label indicates meteorological conditions.
  3. 根据权利要求1或2所述的方法,其中,所述第二样本集包括在第三样本集中确定的与所述第一样本集中每个样本最相似的样本,所述第三样本集是所述第二气象站采集的样本。The method according to claim 1 or 2, wherein the second sample set includes a sample determined in a third sample set that is most similar to each sample in the first sample set, and the third sample set is The sample collected by the second weather station.
  4. 根据权利要求3所述的方法,其中,所述第一终端接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集之前,还包括:The method according to claim 3, wherein before the first terminal receives the aggregated first-order degree set and aggregated second-order degree set calculated according to the second sample set sent by the second terminal, the method further comprises:
    所述第一终端将所述第一样本集中的每个样本转换为哈希值,得到所述第一样本集对应的第一哈希表;The first terminal converts each sample in the first sample set into a hash value to obtain a first hash table corresponding to the first sample set;
    所述第一终端接收所述第二终端发送的第二哈希表,所述第二哈希表包括所述第三样本集中每个样本对应的标识以及每个样本对应的哈希值;Receiving, by the first terminal, a second hash table sent by the second terminal, where the second hash table includes an identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample;
    所述第一终端根据所述第一哈希表和所述第二哈希表,在所述第三样本集中确定与所述第一样本集的每个样本最相似的样本对应的样本标识,得到样本标识集;According to the first hash table and the second hash table, the first terminal determines, in the third sample set, the sample identifier corresponding to the sample most similar to each sample in the first sample set , Get the sample identification set;
    所述第一终端将所述样本标识集发送给所述第二终端,以使所述第二终端根据所述样本标识集中的样本标识确定所述第二样本集。The first terminal sends the sample identification set to the second terminal, so that the second terminal determines the second sample set according to the sample identifications in the sample identification set.
  5. 一种气象事件预测方法,其中,所述气象件预测方法应用于气象预测系统,所述气象预测系统包括位于第一气象站的第一终端和位于第二气象站的第二终端,所述方法包括:A method for predicting meteorological events, wherein the method for predicting meteorological items is applied to a meteorological forecasting system, and the meteorological forecasting system includes a first terminal located at a first weather station and a second terminal located at a second weather station, the method include:
    所述第二终端将第二哈希表发送给所述第一终端,所述第二哈希表包括所述第三样本集中每个样本对应的样本标识以及每个样本对应的哈希值,所述第三样本集是所述第二气象站采集的样本;The second terminal sends a second hash table to the first terminal, where the second hash table includes a sample identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample, The third sample set is samples collected by the second weather station;
    所述第二终端接收所述第一终端发送的样本标识集,所述标识集中的每个样本标识指示所述第三样本集中的一个样本;Receiving, by the second terminal, a sample identification set sent by the first terminal, each sample identification in the identification set indicating a sample in the third sample set;
    所述第二终端根据所述样本标识集在所述第三样本集中确定第二样本集,根据所述第二样本集中的每个样本,计算所述待训练模型的损失函数的聚合一阶梯度集和聚合二阶梯度集,并将所述聚合一阶梯度集和所述聚合二阶梯度集发送给所述第一终端。The second terminal determines a second sample set in the third sample set according to the sample identification set, and calculates the aggregation level of the loss function of the model to be trained according to each sample in the second sample set Collecting and aggregating a two-level degree set, and sending the aggregated first-level degree set and the aggregated two-level degree set to the first terminal.
  6. 根据权利要求5所述的方法,其中,所述第二终端将第二哈希表发送给所述第一终端之前,还包括:所述第二终端将所述第三样本集中的每个样本转换为哈希值,得到所述第三样本集对应的第二哈希表。The method according to claim 5, wherein before the second terminal sends the second hash table to the first terminal, the method further comprises: the second terminal compiling each sample in the third sample set It is converted into a hash value to obtain a second hash table corresponding to the third sample set.
  7. 根据权利要求5或6所述的方法,其中,所述每个样本包括样本特征集和样本标签,所述样本特征集包括温度、湿度、风速与气压,所述样本标签指示气象状况。The method according to claim 5 or 6, wherein each sample includes a sample feature set and a sample label, the sample feature set includes temperature, humidity, wind speed, and air pressure, and the sample label indicates meteorological conditions.
  8. 一种气象事件预测装置,其中,所述装置包括:A meteorological event prediction device, wherein the device includes:
    处理单元,用于根据第一样本集中的每个样本,计算待训练模型的损失函数的一阶梯度集和二阶梯度集,其中,所述一阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述二阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述第一样本集是第一气象站采集的样本的集合;The processing unit is configured to calculate the first step set and the second step set of the loss function of the model to be trained according to each sample in the first sample set, wherein a gradient value in the first step set is based on the first A sample in the sample set is calculated, a gradient value in the second gradient set is calculated based on a sample in the first sample set, and the first sample set is the sample collected by the first weather station gather;
    接收单元,用于接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集,所述第二样本集包括与所述第一样本集中每个样本相似的样本;The receiving unit is configured to receive the aggregated first-order degree set and aggregated second-order degree set calculated according to a second sample set sent by the second terminal, the second sample set including each sample similar to the first sample set Sample of
    所述处理单元,还用于根据所述一阶梯度集、所述聚合一阶梯度集、所述二阶梯度集、所述聚合二阶梯度集以及所述第一样本集,对所述待训练模型进行训练,得到训练好的模型;基于所述训练好的模型,对待预测样本进行预测,确定待预测样本的预测结果;The processing unit is further configured to perform processing on the first sample set according to the first degree set, the aggregated first degree set, the second degree set, the aggregated second degree set, and the first sample set. The model to be trained is trained to obtain a trained model; based on the trained model, the sample to be predicted is predicted, and the prediction result of the sample to be predicted is determined;
    或者,所述装置包括:Or, the device includes:
    发送单元,用于将第二哈希表发送给第一终端,所述第二哈希表包括所述第三样本集中每个样本对应的样本标识以及每个样本对应的哈希值,所述第三样本集是所述第二气象站采集的样本;The sending unit is configured to send a second hash table to the first terminal, where the second hash table includes a sample identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample. The third sample set is the samples collected by the second weather station;
    接收单元,用于接收所述第一终端发送的样本标识集,所述标识集中的每个样本标识指示所述第三样本集中的一个样本;A receiving unit, configured to receive a sample identification set sent by the first terminal, where each sample identification in the identification set indicates a sample in the third sample set;
    处理单元,用于根据所述样本标识集在所述第三样本集中确定第二样本集,根据所述第二样本集中的每个样本,计算所述待训练模型的损失函数的聚合一阶梯度集和聚合二阶梯度集;The processing unit is configured to determine a second sample set in the third sample set according to the sample identification set, and calculate the aggregation level of the loss function of the model to be trained according to each sample in the second sample set Set and aggregate two-level set;
    所述发送单元,还用于将所述聚合一阶梯度集和所述聚合二阶梯度集发送给所述第一终端。The sending unit is further configured to send the aggregated first-order degree set and the aggregated second-order degree set to the first terminal.
  9. 一种计算机设备,其中,所述计算设备包括处理器和存储器,所述存储器用于存储指令,所述处理器用于执行所述指令,当所述处理器执行所述指令时,执行以下方法:A computer device, wherein the computing device includes a processor and a memory, the memory is used to store instructions, the processor is used to execute the instructions, and when the processor executes the instructions, the following method is executed:
    根据第一样本集中的每个样本,计算待训练模型的损失函数的一阶梯度集和二阶梯度集,其中,所述一阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述二阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述第一样本集是第一气象站采集的样本的集合;According to each sample in the first sample set, calculate the first step set and the second step set of the loss function of the model to be trained, wherein a gradient value in the first step set is based on a value in the first sample set Obtained by sample calculation, a gradient value in the second gradient set is calculated based on a sample in a first sample set, and the first sample set is a set of samples collected by a first weather station;
    接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集,所述第二样本集包括与所述第一样本集中每个样本相似的样本;Receiving an aggregated first-order degree set and an aggregated second-order degree set calculated according to a second sample set sent by the second terminal, the second sample set including samples similar to each sample in the first sample set;
    根据所述一阶梯度集、所述聚合一阶梯度集、所述二阶梯度集、所述聚合二阶梯度集以及所述第一样本集,对所述待训练模型进行训练,得到训练好的模型;Training the model to be trained according to the first step degree set, the aggregate first step degree set, the second step degree set, the aggregate second step degree set, and the first sample set to obtain training Good model
    基于所述训练好的模型,对待预测样本进行预测,确定待预测样本的预测结果。Based on the trained model, the sample to be predicted is predicted, and the prediction result of the sample to be predicted is determined.
  10. 根据权利要求9所述的计算机设备,其中,所述每个样本包括样本特征集和样本标签,所述样本特征集包括温度、湿度、风速与气压,所述样本标签指示气象状况。9. The computer device according to claim 9, wherein each sample includes a sample feature set and a sample label, the sample feature set includes temperature, humidity, wind speed, and air pressure, and the sample label indicates meteorological conditions.
  11. 根据权利要求9或10所述的计算机设备,其中,所述第二样本集包括在第三样本集中确定的与所述第一样本集中每个样本最相似的样本,所述第三样本集是所述第二气象站采集的样本。The computer device according to claim 9 or 10, wherein the second sample set includes a sample determined in the third sample set that is most similar to each sample in the first sample set, and the third sample set It is a sample collected by the second weather station.
  12. 根据权利要求11所述的计算机设备,其中,所述接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集之前,所述处理器还用于执行:11. The computer device according to claim 11, wherein before the receiving the aggregated first-order degree set and the aggregated second-order degree set calculated according to the second sample set sent by the second terminal, the processor is further configured to execute:
    将所述第一样本集中的每个样本转换为哈希值,得到所述第一样本集对应的第一哈希表;Converting each sample in the first sample set into a hash value to obtain a first hash table corresponding to the first sample set;
    接收所述第二终端发送的第二哈希表,所述第二哈希表包括所述第三样本集中每个样本对应的标识以及每个样本对应的哈希值;Receiving a second hash table sent by the second terminal, where the second hash table includes an identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample;
    根据所述第一哈希表和所述第二哈希表,在所述第三样本集中确定与所述第一样本集的每个样本最相似的样本对应的样本标识,得到样本标识集;According to the first hash table and the second hash table, the sample identifier corresponding to the sample most similar to each sample of the first sample set is determined in the third sample set to obtain a sample identifier set ;
    将所述样本标识集发送给所述第二终端,以使所述第二终端根据所述样本标识集中的样本标识确定所述第二样本集。The sample identification set is sent to the second terminal, so that the second terminal determines the second sample set according to the sample identifications in the sample identification set.
  13. 一种计算机设备,其中,所述计算设备包括处理器和存储器,所述存储器用于存储指令,所述处理器用于执行所述指令,当所述处理器执行所述指令时,执行以下方法:A computer device, wherein the computing device includes a processor and a memory, the memory is used to store instructions, the processor is used to execute the instructions, and when the processor executes the instructions, the following method is executed:
    将第二哈希表发送给第一终端,所述第二哈希表包括所述第三样本集中每个样本对应的样本标识以及每个样本对应的哈希值,所述第三样本集是所述第二气象站采集的样本;Send a second hash table to the first terminal, where the second hash table includes a sample identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample. The third sample set is Samples collected by the second weather station;
    接收所述第一终端发送的样本标识集,所述标识集中的每个样本标识指示所述第三样本集中的一个样本;Receiving a sample identification set sent by the first terminal, where each sample identification in the identification set indicates a sample in the third sample set;
    根据所述样本标识集在所述第三样本集中确定第二样本集,根据所述第二样本集中的每个样本,计算所述待训练模型的损失函数的聚合一阶梯度集和聚合二阶梯度集,并将所述聚合一阶梯度集和所述聚合二阶梯度集发送给所述第一终端。Determine a second sample set in the third sample set according to the sample identification set, and calculate the aggregate first step set and aggregate second step of the loss function of the model to be trained according to each sample in the second sample set And send the aggregated first-order degree set and the aggregated second-order degree set to the first terminal.
  14. 根据权利要求13所述的计算机设备,其中,所述将第二哈希表发送给所述第一终端之前,所述处理器还用于执行:The computer device according to claim 13, wherein, before the sending the second hash table to the first terminal, the processor is further configured to execute:
    将所述第三样本集中的每个样本转换为哈希值,得到所述第三样本集对应的第二哈希表。Each sample in the third sample set is converted into a hash value to obtain a second hash table corresponding to the third sample set.
  15. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行以实现以下方法:A computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the following method:
    根据第一样本集中的每个样本,计算待训练模型的损失函数的一阶梯度集和二阶梯度集,其中,所述一阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述二阶梯度集中的一个梯度值是根据第一样本集中的一个样本计算得到的,所述第一样本集是第一气象站采集的样本的集合;According to each sample in the first sample set, calculate the first step set and the second step set of the loss function of the model to be trained, wherein a gradient value in the first step set is based on a value in the first sample set Obtained by sample calculation, a gradient value in the second gradient set is calculated based on a sample in a first sample set, and the first sample set is a set of samples collected by a first weather station;
    接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集,所述第二样本集包括与所述第一样本集中每个样本相似的样本;Receiving an aggregated first-order degree set and an aggregated second-order degree set calculated according to a second sample set sent by the second terminal, the second sample set including samples similar to each sample in the first sample set;
    根据所述一阶梯度集、所述聚合一阶梯度集、所述二阶梯度集、所述聚合二阶梯度集以及所述第一样本集,对所述待训练模型进行训练,得到训练好的模型;Training the model to be trained according to the first step degree set, the aggregate first step degree set, the second step degree set, the aggregate second step degree set, and the first sample set to obtain training Good model
    基于所述训练好的模型,对待预测样本进行预测,确定待预测样本的预测结果。Based on the trained model, the sample to be predicted is predicted, and the prediction result of the sample to be predicted is determined.
  16. 根据权利要求15所述的计算机可读存储介质,其中,所述每个样本包括样本特征集和样本标签,所述样本特征集包括温度、湿度、风速与气压,所述样本标签指示气象状况。15. The computer-readable storage medium according to claim 15, wherein each sample includes a sample feature set and a sample label, the sample feature set includes temperature, humidity, wind speed, and air pressure, and the sample label indicates meteorological conditions.
  17. 根据权利要求15或16所述的计算机可读存储介质,其中,所述第二样本集包括在第三样本集中确定的与所述第一样本集中每个样本最相似的样本,所述第三样本集是所述第二气象站采集的样本。The computer-readable storage medium according to claim 15 or 16, wherein the second sample set includes a sample determined in the third sample set that is most similar to each sample in the first sample set, and the first sample set The three-sample set is the samples collected by the second weather station.
  18. 根据权利要求17所述的计算机可读存储介质,其中,所述接收第二终端发送的根据第二样本集计算得到的聚合一阶梯度集和聚合二阶梯度集之前,所述计算机程序被处理器执行时还用于实现:The computer-readable storage medium according to claim 17, wherein the computer program is processed before receiving the aggregated first-order degree set and aggregated second-order degree set calculated according to the second sample set sent by the second terminal It is also used to implement:
    将所述第一样本集中的每个样本转换为哈希值,得到所述第一样本集对应的第一哈希表;Converting each sample in the first sample set into a hash value to obtain a first hash table corresponding to the first sample set;
    接收所述第二终端发送的第二哈希表,所述第二哈希表包括所述第三样本集中每个样本对应的标识以及每个样本对应的哈希值;Receiving a second hash table sent by the second terminal, where the second hash table includes an identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample;
    根据所述第一哈希表和所述第二哈希表,在所述第三样本集中确定与所述第一样本集的每个样本最相似的样本对应的样本标识,得到样本标识集;According to the first hash table and the second hash table, the sample identifier corresponding to the sample most similar to each sample of the first sample set is determined in the third sample set to obtain a sample identifier set ;
    将所述样本标识集发送给所述第二终端,以使所述第二终端根据所述样本标识集中的样本标识确定所述第二样本集。The sample identification set is sent to the second terminal, so that the second terminal determines the second sample set according to the sample identifications in the sample identification set.
  19. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序, 所述计算机程序被处理器执行以实现以下方法:A computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the following method:
    将第二哈希表发送给第一终端,所述第二哈希表包括所述第三样本集中每个样本对应的样本标识以及每个样本对应的哈希值,所述第三样本集是所述第二气象站采集的样本;Send a second hash table to the first terminal, where the second hash table includes a sample identifier corresponding to each sample in the third sample set and a hash value corresponding to each sample. The third sample set is Samples collected by the second weather station;
    接收所述第一终端发送的样本标识集,所述标识集中的每个样本标识指示所述第三样本集中的一个样本;Receiving a sample identification set sent by the first terminal, where each sample identification in the identification set indicates a sample in the third sample set;
    根据所述样本标识集在所述第三样本集中确定第二样本集,根据所述第二样本集中的每个样本,计算所述待训练模型的损失函数的聚合一阶梯度集和聚合二阶梯度集,并将所述聚合一阶梯度集和所述聚合二阶梯度集发送给所述第一终端。Determine a second sample set in the third sample set according to the sample identification set, and calculate the aggregate first step set and aggregate second step of the loss function of the model to be trained according to each sample in the second sample set And send the aggregated first-order degree set and the aggregated second-order degree set to the first terminal.
  20. 根据权利要求19所述的计算机可读存储介质,其中,所述将第二哈希表发送给所述第一终端之前,所述计算机程序被处理器执行时还用于实现:The computer-readable storage medium according to claim 19, wherein, before the second hash table is sent to the first terminal, the computer program is further used to implement when the computer program is executed by the processor:
    将所述第三样本集中的每个样本转换为哈希值,得到所述第三样本集对应的第二哈希表。Each sample in the third sample set is converted into a hash value to obtain a second hash table corresponding to the third sample set.
PCT/CN2021/083026 2020-11-20 2021-03-25 Meteorological event prediction method and apparatus, and related device WO2021203980A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011312818.9A CN112381307B (en) 2020-11-20 2020-11-20 Meteorological event prediction method and device and related equipment
CN202011312818.9 2020-11-20

Publications (1)

Publication Number Publication Date
WO2021203980A1 true WO2021203980A1 (en) 2021-10-14

Family

ID=74584503

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/083026 WO2021203980A1 (en) 2020-11-20 2021-03-25 Meteorological event prediction method and apparatus, and related device

Country Status (2)

Country Link
CN (1) CN112381307B (en)
WO (1) WO2021203980A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114091624A (en) * 2022-01-18 2022-02-25 蓝象智联(杭州)科技有限公司 Federal gradient lifting decision tree model training method without third party
CN114239862A (en) * 2021-12-23 2022-03-25 电子科技大学 anti-Byzantine attack federal learning method for protecting user data privacy
CN114626458A (en) * 2022-03-15 2022-06-14 中科三清科技有限公司 High-voltage rear part identification method and device, storage medium and terminal
CN115794981A (en) * 2022-12-14 2023-03-14 广西电网有限责任公司 Method and system for counting meteorological data by using model

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112381307B (en) * 2020-11-20 2023-12-22 平安科技(深圳)有限公司 Meteorological event prediction method and device and related equipment
CN113722739B (en) * 2021-09-06 2024-04-09 京东科技控股股份有限公司 Gradient lifting tree model generation method and device, electronic equipment and storage medium
CN113762805A (en) * 2021-09-23 2021-12-07 国网湖南省电力有限公司 Mountain forest fire early warning method applied to power transmission line

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170102482A1 (en) * 2015-10-07 2017-04-13 Howard Gregory Altschule Forensic weather system
CN109472283A (en) * 2018-09-13 2019-03-15 中国科学院计算机网络信息中心 A kind of hazardous weather event prediction method and apparatus based on Multiple Incremental regression tree model
CN111144576A (en) * 2019-12-13 2020-05-12 支付宝(杭州)信息技术有限公司 Model training method and device and electronic equipment
CN111695697A (en) * 2020-06-12 2020-09-22 深圳前海微众银行股份有限公司 Multi-party combined decision tree construction method and device and readable storage medium
CN112381307A (en) * 2020-11-20 2021-02-19 平安科技(深圳)有限公司 Meteorological event prediction method and device and related equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109165683B (en) * 2018-08-10 2023-09-12 深圳前海微众银行股份有限公司 Sample prediction method, device and storage medium based on federal training
CN109783682B (en) * 2019-01-19 2021-01-15 北京工业大学 Point-to-point similarity-based depth non-relaxed Hash image retrieval method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170102482A1 (en) * 2015-10-07 2017-04-13 Howard Gregory Altschule Forensic weather system
CN109472283A (en) * 2018-09-13 2019-03-15 中国科学院计算机网络信息中心 A kind of hazardous weather event prediction method and apparatus based on Multiple Incremental regression tree model
CN111144576A (en) * 2019-12-13 2020-05-12 支付宝(杭州)信息技术有限公司 Model training method and device and electronic equipment
CN111695697A (en) * 2020-06-12 2020-09-22 深圳前海微众银行股份有限公司 Multi-party combined decision tree construction method and device and readable storage medium
CN112381307A (en) * 2020-11-20 2021-02-19 平安科技(深圳)有限公司 Meteorological event prediction method and device and related equipment

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114239862A (en) * 2021-12-23 2022-03-25 电子科技大学 anti-Byzantine attack federal learning method for protecting user data privacy
CN114091624A (en) * 2022-01-18 2022-02-25 蓝象智联(杭州)科技有限公司 Federal gradient lifting decision tree model training method without third party
CN114626458A (en) * 2022-03-15 2022-06-14 中科三清科技有限公司 High-voltage rear part identification method and device, storage medium and terminal
CN115794981A (en) * 2022-12-14 2023-03-14 广西电网有限责任公司 Method and system for counting meteorological data by using model
CN115794981B (en) * 2022-12-14 2023-09-26 广西电网有限责任公司 Method and system for counting meteorological data by using model

Also Published As

Publication number Publication date
CN112381307A (en) 2021-02-19
CN112381307B (en) 2023-12-22

Similar Documents

Publication Publication Date Title
WO2021203980A1 (en) Meteorological event prediction method and apparatus, and related device
CN110263280B (en) Multi-view-based dynamic link prediction depth model and application
CN110968426B (en) Edge cloud collaborative k-means clustering model optimization method based on online learning
CN110837602A (en) User recommendation method based on representation learning and multi-mode convolutional neural network
WO2020211482A1 (en) Network topology information acquisition method, apparatus, device, and storage medium
CN114039918B (en) Information age optimization method and device, computer equipment and storage medium
WO2021008675A1 (en) Dynamic network configuration
CN116489038A (en) Network traffic prediction method, device, equipment and medium
WO2015165230A1 (en) Social contact message monitoring method and device
Gao et al. A deep learning framework with spatial-temporal attention mechanism for cellular traffic prediction
CN113988160A (en) Semi-asynchronous layered federal learning updating method based on timeliness
CN115002031B (en) Federal learning network flow classification model training method, model and classification method based on unbalanced data distribution
CN114565105B (en) Data processing method and training method and device of deep learning model
WO2023029944A1 (en) Federated learning method and device
CN115392481A (en) Federal learning efficient communication method based on real-time response time balancing
Ke et al. Spark-based feature selection algorithm of network traffic classification
CN115766475A (en) Semi-asynchronous power federal learning network based on communication efficiency and communication method thereof
CN114785692A (en) Virtual power plant aggregation regulation and control communication network flow balancing method and device
CN114492849A (en) Model updating method and device based on federal learning
Hoiles et al. Risk-averse caching policies for YouTube content in femtocell networks using density forecasting
WO2019114481A1 (en) Cluster type recognition method, apparatus, electronic apparatus, and storage medium
Yang et al. An incremental learning classification algorithm based on forgetting factor for eHealth networks
CN116991337B (en) Cloud storage method and device for educational resources of remote educational system
Li et al. Distributed computing framework of intelligent sensor network for electric power internet of things
CN116778363B (en) Low-traffic reservoir area water environment risk identification method based on federal learning

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21784113

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205N DATED 11/07/2023)

122 Ep: pct application non-entry in european phase

Ref document number: 21784113

Country of ref document: EP

Kind code of ref document: A1