Method and apparatus for training prediction models and predicting data
By calculating sample weights and combining standard gradient descent and convex function difference planning algorithms, the robust prediction problem under non-stationary time series data is solved, the robustness and interpretability of the model are realized, and the accuracy and interpretability of the prediction results are ensured. .
Patent Information
- Application Number
- CN202111272908.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2041-10-29
AI Technical Summary
The prior art is difficult to achieve robust prediction and interpretable inference when processing non-stationary timing data, and the difference operation will lose the original information of the data, resulting in a lack of interpretability of the results.
By calculating the sample weight of the training sample, the objective function is solved according to the preset loss function and penalty term to train the prediction model, the Huber loss function and L1/L2 norm penalty term are used, and the standard gradient descent and convex function difference planning algorithm are combined to ensure the model robustness and explainability.
It realizes robust prediction and reasonable inference under non-stationary sequences, retains the original information of the data, and provides reliable statistical theoretical guarantees.
Smart Images

Figure CN113962319B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computer technology, and more particularly to methods and devices for training prediction models and predicting data. Background Art
[0002] Time series algorithms have been extensively studied and applied in fields such as finance, medicine, and meteorology. Most algorithms usually assume that the distribution of time series data is stationary and that the noise follows a Gaussian distribution with finite variance. Both assumptions are too strict for heavy-tailed and non-stationary time series data that often appear in practice in fields such as finance and medicine.
[0003] Existing methods cannot achieve both robust prediction and interpretable inference for non-stationary time series data. Specifically, most robust algorithm studies are only for simple linear models and require the data to meet stationarity conditions. However, the estimation of non-stationary series through differentiation often loses the original information of the data in the differentiation operation, resulting in a lack of interpretability of the results. Summary of the invention
[0004] Embodiments of the present disclosure provide methods and devices for training prediction models and predicting data.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for training a prediction model, comprising: obtaining a training sample set and an estimation function set, wherein the training sample includes an input variable sequence and an output variable sequence; performing the following training steps: selecting a target sample from the training sample set; calculating a sample weight sequence based on the target sample; for each estimation function in the estimation function set, inputting the input variable sequence of the target sample into the estimation function for prediction to obtain a prediction value sequence corresponding to the estimation function; calculating a loss value sequence for each estimation function based on a preset loss function, a prediction value sequence corresponding to each estimation function, and an output variable sequence of the target sample; solving the estimation function corresponding to the minimum of the first objective function as a prediction model, wherein the first objective function includes a weighted sum of a loss value sequence and a sample weight sequence and a penalty term; if the sample weight sequence converges and the prediction model converges, outputting the trained prediction model; if the sample weight sequence does not converge or the prediction model does not converge, repeating the above training steps.
[0006] In some embodiments, the calculation of the sample weight sequence based on the target sample includes: obtaining the associated weight sequence between the data distributions; calculating the difference between the associated weight sequence and the initial sample weight sequence to obtain a weight difference sequence; solving the estimation function corresponding to the maximum second objective function as the target prediction model, wherein the second objective function is the sum of the products of each loss value in the loss value sequence and the weight difference corresponding to the same time point; solving the sample weight sequence corresponding to the minimum third objective function as the final sample weight sequence, wherein the objective function is the weighted sum of the second objective function, the L2 norm of the difference between the associated weight sequence and the sample weight sequence, and the L2 norm of the sample weight sequence.
[0007] In some embodiments, solving the estimation function corresponding to the maximum of the second objective function as the target prediction model includes: solving the estimation function corresponding to the maximum of the second objective function as the target prediction model through a planning algorithm based on the difference of convex functions.
[0008] In some embodiments, the method of solving the sample weight sequence corresponding to the minimum of the third objective function as the final sample weight sequence includes: for each time point, using the standard gradient descent algorithm to solve the sample weight that minimizes the loss value at that time point. The sample weights with the minimum loss value at each time point constitute the sample weight sequence.
[0009] In some embodiments, the loss function is a Huber loss function, and the penalty term uses an L1 norm or an L2 norm.
[0010] In a second aspect, an embodiment of the present disclosure provides a method for predicting data, comprising: obtaining a time series data set; inputting each time series data in the time series data set into a prediction model trained according to any method of the first aspect, and outputting a predicted value for each time series data.
[0011] In a third aspect, an embodiment of the present disclosure provides a device for training a prediction model, comprising: an acquisition unit, configured to acquire a training sample set and an estimation function set, wherein the training sample includes an input variable sequence and an output variable sequence; a training unit, configured to perform the following training steps: selecting a target sample from the training sample set; calculating a sample weight sequence based on the target sample; for each estimation function in the estimation function set, inputting the input variable sequence of the target sample into the estimation function for prediction to obtain a prediction value sequence corresponding to the estimation function; calculating a loss value sequence for each estimation function based on a preset loss function, a prediction value sequence corresponding to each estimation function and an output variable sequence of the target sample; solving the estimation function corresponding to the minimum of the first objective function as a prediction model, wherein the first objective function includes a weighted sum of a loss value sequence and a sample weight sequence and a penalty term; if the sample weight sequence converges and the prediction model converges, outputting the trained prediction model; a repetition unit, configured to repeat the above training steps if the sample weight sequence does not converge or the prediction model does not converge.
[0012] In some embodiments, the training unit is further configured to: obtain an association weight sequence between data distributions; calculate the difference between the association weight sequence and the initial sample weight sequence to obtain a weight difference sequence; solve the estimation function corresponding to the maximum second objective function as the target prediction model, wherein the second objective function includes the sum of the products of each loss value in the loss value sequence and the weight difference corresponding to the same time point; solve the sample weight sequence corresponding to the minimum third objective function as the final sample weight sequence, wherein the objective function includes the weighted sum of the sum of the products of each loss value in the loss value sequence and the weight difference corresponding to the same time point, the L2 norm of the difference between the association weight sequence and the sample weight sequence, and the L2 norm of the sample weight sequence.
[0013] In some embodiments, the training unit is further configured to: solve the estimation function corresponding to the maximum of the second objective function as the target prediction model, including: solving the estimation function corresponding to the maximum of the second objective function as the target prediction model through a planning algorithm based on the difference of convex functions.
[0014] In some embodiments, the training unit is further configured to: for each time point, use a standard gradient descent algorithm to solve the sample weight that minimizes the loss value at that time point; the sample weights with the minimum loss value at each time point constitute a sample weight sequence.
[0015] In some embodiments, the loss function is a Huber loss function, and the penalty term uses an L1 norm or an L2 norm.
[0016] In a fourth aspect, an embodiment of the present disclosure provides a device for predicting data, comprising: an acquisition unit, configured to acquire a set of time series data; a prediction unit, configured to input each time series data in the time series data set into a prediction model trained according to any one of the methods in the first aspect, and output a predicted value for each time series data.
[0017] In a fifth aspect, an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a storage device on which one or more computer programs are stored, and when the one or more computer programs are executed by the one or more processors, the one or more processors implement the method described in the first aspect or the second aspect.
[0018] In a sixth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method as described in the first aspect or the second aspect.
[0019] The method and device for training prediction models and prediction data provided by the embodiments of the present disclosure first calculate the sample weights of the training samples, and then calculate the loss value of each candidate prediction model according to the training sample weights, and solve the prediction model with the minimum loss value. It is used to simultaneously achieve robust prediction and reasonable inference of non-stationary series (such as variable selection and Granger causal inference). The modeling scheme has a reliable statistical theory guarantee. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Other features, objects and advantages of the present disclosure will become more apparent from a reading of the detailed description of non-limiting embodiments made with reference to the following drawings:
[0021] Figure 1 is an exemplary system architecture diagram in which the present disclosure may be applied;
[0022] Figure 2 is a flowchart of an embodiment of a method for training a prediction model according to the present disclosure;
[0023] Figure 3 is a schematic diagram of an application scenario of a method for training a prediction model according to the present disclosure;
[0024] Figure 4 is a flow chart of an embodiment of a method for predicting data according to the present disclosure;
[0025] Figure 5 is a structural schematic diagram of an embodiment of a device for training a prediction model according to the present disclosure;
[0026] Figure 6 is a schematic structural diagram of an embodiment of a device for predicting data according to the present disclosure;
[0027] Figure 7 It is a schematic diagram of the structure of a computer system suitable for implementing the electronic device of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] The present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.
[0029] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0030] Figure 1 An exemplary system architecture 100 is shown to which the method for training a prediction model, the apparatus for training a prediction model, the method for predicting data, or the apparatus for predicting data according to the embodiments of the present disclosure can be applied.
[0031] like Figure 1 As shown, the system architecture 100 may include terminals 101, 102, a network 103, a database server 104, and a server 105. The network 103 is used to provide a medium for communication links between the terminals 101, 102, the database server 104, and the server 105. The network 103 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0032] The user 110 can use the terminals 101 and 102 to interact with the server 105 through the network 103 to receive or send messages, etc. Various client applications can be installed on the terminals 101 and 102, such as model training applications, data prediction applications, shopping applications, payment applications, web browsers, and instant messaging tools.
[0033] The terminals 101 and 102 here can be hardware or software. When the terminals 101 and 102 are hardware, they can be various electronic devices with display screens, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Dynamic Image Experts Compression Standard Audio Layer 3), laptops and desktop computers, etc. When the terminals 101 and 102 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0034] The database server 104 may be a database server that provides various services. For example, a sample set may be stored in the database server. The sample set contains a large number of samples. The samples may include an input variable sequence and an output variable sequence. For example, the training sample S = {(x1, y1), ..., (x T ,y T )}, where x t is the value of the input variable at time t, y t is the value of the output variable at the time t. In this way, the user 110 can also select samples from the sample set stored in the database server 104 through the terminals 101 and 102.
[0035] The server 105 may also be a server that provides various services, such as a background server that supports various applications displayed on the terminals 101 and 102. The background server may train the initial model using samples in the sample set sent by the terminals 101 and 102, and may send the training results (such as the generated prediction model) to the terminals 101 and 102. In this way, the user may use the generated prediction model to perform data prediction.
[0036] The database server 104 and server 105 here can also be hardware or software. When they are hardware, they can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When they are software, they can be implemented as multiple software or software modules (for example, used to provide distributed services), or as a single software or software module. No specific limitation is made here. The database server 104 and server 105 can also be servers of a distributed system, or servers combined with blockchain. The database server 104 and server 105 can also be cloud servers, or intelligent cloud computing servers or intelligent cloud hosts with artificial intelligence technology.
[0037] It should be noted that the method for training a prediction model or the method for predicting data provided in the embodiments of the present disclosure is generally executed by the server 105. Accordingly, the device for training a prediction model or the device for predicting data is generally also provided in the server 105.
[0038] It should be pointed out that, in the case where the server 105 can implement the related functions of the database server 104 , the database server 104 may not be provided in the system architecture 100 .
[0039] It should be understood that Figure 1 The number of terminals, networks, database servers and servers in the embodiment is only for illustration. Any number of terminals, networks, database servers and servers may be provided according to the implementation requirements.
[0040] Continue to see Figure 2 , which shows a process 200 of an embodiment of a method for training a prediction model according to the present disclosure. The method for training a prediction model may include the following steps:
[0041] Step 201: Obtain a training sample set and an estimation function set.
[0042] In this embodiment, the execution subject (eg, Figure 1 The training sample set and the estimation function set can be obtained in a variety of ways. For example, the execution subject can obtain the training sample set and the estimation function set from a database server (e.g. Figure 1 The database server 104 shown in FIG. 104 is used to obtain the existing training sample set and estimation function set stored therein. For another example, a user may use a terminal (eg Figure 1 In this way, the execution subject can receive the training samples and estimation functions collected by the terminal, and store these training samples and estimation functions locally, thereby generating a training sample set and an estimation function set.
[0043] The training samples include input variable sequences and output variable sequences. For example, the training sample set S = {(x1, y1),…, (x T ,y T )}, where x t is the value of the input variable at time t, y t is the value of the output variable at time t. x1, x2, …x T is the sequence of input variables. y1, y2, …y T is the output variable sequence, that is, the label of the sample, which is used to compare with the predicted value.
[0044] The estimated function set H is a hypothesis space, where it is assumed that this space is an additive space, that is, H = H1 + ... + H dim(x) This additive structure allows the estimation function (prediction model) to be expressed as the sum of multiple one-dimensional functions, each of which acts on a one-dimensional subspace in the input space. The hypothesis space with an additive structure not only allows the algorithm to avoid the "curse of dimensionality", but also makes the estimation function interpretable (i.e., it can determine the role of each dimension in the decision).
[0045] The estimation function can be a linear model. Linear model is a general term for a type of statistical model. The production method is to connect various links with a certain process, including linear regression model and variance analysis model, which is applied to biology, medicine, economics, and management.
[0046] Step 202: Select target samples from the training sample set.
[0047] In this embodiment, the execution subject may select a training sample from the sample set obtained in step 201 as a target sample, and perform the training steps from step 203 to step 208. The selection method and the number of selected training samples are not limited in the present disclosure. For example, at least one training sample may be randomly selected, or a training sample with a longer training input sequence may be selected.
[0048] This application designs the following optimization problem to solve a model that can simultaneously achieve robust prediction and reasonable inference of non-stationary series That is, the first objective function:
[0049]
[0050] in As the loss function, the Huber loss function can be selected, p=(p1,…,p T ) is the sample weight sequence of the training sample, referred to as the training sample weight. The predicted loss value of the sample at each moment corresponds to a sample weight, Ω(f) is the penalty term, and λ is the regularization coefficient. The penalty term here can use L1 norm or L2 norm regularization to achieve sparsity, so as to further realize the interpretability of the estimated function. When the training sample weight p is given, the objective function can be solved by the proximal gradient descent method.
[0051] The key to solving the optimization problem in formula 1 is to calculate the training sample weight p = (p1, ..., p T ). Next, the calculation method of training sample weights is described in detail.
[0052] Step 203: Calculate a sample weight sequence according to the target sample.
[0053] In this embodiment, the sample weight sequence can be calculated by a given loss function based on the prior association weights between the input variable sequence and the output variable sequence distribution.
[0054] In some optional implementations of this embodiment, calculating a sample weight sequence according to a target sample includes:
[0055] S2031, obtaining a sequence of association weights between data distributions;
[0056] In order to minimize the assumptions about data distribution, we can assume that the distribution at the T+1th moment and the distribution at the previous T moments obey the following relationship:
[0057]
[0058] Where E is the expected calculation, f is the estimated function, f(x t ) is the predicted value, q t,t=1,..,T,is the potential association weight between distributions. Note that this weight set is a priori knowledge, so it can be given in advance based on empirical knowledge.
[0059] S2032, calculating the difference between the associated weight sequence and the initial sample weight sequence to obtain a weight difference sequence;
[0060] The weight difference sequence is denoted as q t -p t , where t=1,..,T.
[0061] S2033, solving the estimation function corresponding to the maximum of the second objective function as the target prediction model, wherein the second objective function includes the sum of the products of each loss value in the loss value sequence and the weight difference corresponding to the same time point;
[0062] The loss value sequence is expressed as Where t=1,..,T.
[0063] The second objective function is:
[0064]
[0065] Where k is the number of iterations, f (k) For a given When
[0066] Take the maximum value of the estimation function. Traverse all estimation functions from the estimation function set H and calculate f when formula 3 is maximized. The DC planning algorithm can be used to solve it. The DC (difference of convex) planning problem can be expressed as the difference of two convex functions. DC planning has a wide range of applications in economics, management, and engineering, and its optimization algorithm has been fully studied.
[0067] S2034, solving the sample weight sequence corresponding to the minimum of the third objective function as the final sample weight sequence, wherein the third objective function includes the weighted sum of the sum of the products of each loss value in the loss value sequence and the weight difference corresponding to the same time point, the L2 norm of the difference between the associated weight sequence and the sample weight sequence, and the L2 norm of the sample weight sequence.
[0068] The following third objective function is given to calculate the training sample weights:
[0069]
[0070] where q=(q1,…,q T ); p=(p1,…,p T);λ1 and λ2 are regularization parameters;||·|| is the vector L2 norm;H is the hypothesis space, which can be assumed to be an additive space, that is, H=H1+…+H dim(x) This additive structure allows the estimated function to be expressed as the sum of multiple one-dimensional functions, each of which acts on a one-dimensional subspace in the input space. The hypothesis space with an additive structure not only allows the algorithm to avoid the "curse of dimensionality", but also makes the estimated function interpretable (i.e., it can determine the role of each dimension in the decision).
[0071] In order to calculate the weight of each sample through Formula 4, this application integrates the standard gradient descent and DC planning algorithms. The key steps of the algorithm are as follows: For the objective function in Formula 4, use standard gradient descent to solve the weight p that minimizes the loss function. Assuming k is the number of iterations, the update steps are:
[0072]
[0073] The sample weights are updated once per training iteration to find the prediction model with the minimum loss.
[0074] Step 204: for each estimation function in the estimation function set, input the input variable sequence of the target sample into the estimation function for prediction to obtain a prediction value sequence corresponding to the estimation function.
[0075] In this embodiment, by traversing each estimation function in the H space and calculating the input variable sequence once with each estimation function, the predicted value sequence f(x t ).
[0076] Step 205 , calculating the loss value sequence of each estimation function according to the preset loss function, the prediction value sequence corresponding to each estimation function and the output variable sequence of the target sample.
[0077] In this embodiment, the loss function may be an L1 loss function or an L2 loss function, preferably a Huber loss function. The loss value sequence is expressed as
[0078] Step 206, solving the estimation function corresponding to the minimum of the first objective function as the prediction model.
[0079] In this embodiment, as shown in Formula 1, the first objective function may include a weighted sum of a loss value sequence and a sample weight sequence and a penalty term.
[0080]
[0081] The proximal gradient descent method can be used to solve the estimation function corresponding to the minimum of the first objective function.
[0082] Step 207: If the sample weight sequence converges and the prediction model converges, the trained prediction model is output.
[0083] In this embodiment, if the weight sequence does not change after iteration, it means convergence. If the prediction model does not change after iteration, it means the prediction model converges. When both items converge, the prediction model training is completed.
[0084] Step 208: If the sample weight sequence does not converge or the prediction model does not converge, then the training steps 202-207 are repeated.
[0085] In this embodiment, if any item does not converge, it is necessary to continue training and repeat steps 202-207 until the sample weight sequence converges and the prediction model converges.
[0086] The method for training the prediction model in this embodiment can find an estimation function that can achieve robust prediction and reasonable inference of non-stationary sequences as a prediction model through dual training of sample weights and prediction models. The original information of the data will not be lost, and it can be applied to data prediction in more scenarios to improve the accuracy of data prediction.
[0087] See also Figure 3 , Figure 3 FIG. 1 is a schematic diagram of an application scenario of the method for training a prediction model according to this embodiment. Figure 3 In the application scenario, the user selects the target training sample from the training data set and calculates the sample weight according to the target training sample. Then the sample weight is used to calculate the loss value of different estimation functions, and the estimation function with the smallest weighted sum of the sample weight and the loss value is selected as the prediction model. The target training sample is reselected, and the sample weight is recalculated using the prediction model selected in the previous round. Then the updated sample weight is used to calculate the loss value of different estimation functions, and the estimation function with the smallest weighted sum of the sample weight and the loss value is selected as the prediction model. The above process is repeated until the sample weight and the prediction model converge.
[0088] See also Figure 4 , which shows a process 400 of an embodiment of a method for predicting data provided by the present disclosure. The method for predicting data may include the following steps:
[0089] Step 401, obtaining a time series data set.
[0090] In this embodiment, the execution subject of the method for predicting data (for example Figure 1 The server 105 shown in FIG. 104 may obtain the time series data set in a variety of ways. For example, the execution subject may obtain the time series data set from a database server (e.g. Figure 1For another example, the execution subject may also receive a terminal (e.g. Figure 1 The time series data may be data in the fields of finance, medicine, meteorology, etc., for example, the temperature of each day in the previous year.
[0091] Step 402: Input each time series data in the time series data set into the prediction model respectively, and output the prediction value of each time series data.
[0092] In this embodiment, the time series data of each field corresponds to a corresponding prediction model. For example, weather data corresponds to a weather prediction model. The prediction model is trained based on T-scale historical data of the same field. For the prediction of the unknown time T+1, the input data x T+1 , get the predicted value
[0093] It should be noted that the method for predicting data in this embodiment can be used to test the prediction model generated by the above embodiments. Then, the prediction model can be continuously optimized according to the test results. This method can also be a practical application method of the prediction model generated by the above embodiments. Using the prediction model generated by the above embodiments to perform data prediction helps to improve the performance of the prediction model. For example, the predicted value is more accurate.
[0094] Continue to see Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for training a prediction model. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0095] like Figure 5As shown, the apparatus 500 for training a prediction model in this embodiment may include: an acquisition unit 501, a training unit 502, and a repeating unit 503. The acquisition unit 501 is configured to acquire a training sample set and an estimation function set, wherein the training sample includes an input variable sequence and an output variable sequence; the training unit 502 is configured to perform the following training steps: select a target sample from the training sample set; calculate a sample weight sequence according to the target sample; for each estimation function in the estimation function set, input the input variable sequence of the target sample into the estimation function for prediction to obtain a prediction value sequence corresponding to the estimation function; calculate the loss value sequence of each estimation function according to a preset loss function, a prediction value sequence corresponding to each estimation function, and an output variable sequence of the target sample; solve the estimation function corresponding to the minimum of the first objective function as a prediction model, wherein the first objective function includes a weighted sum of a loss value sequence and a sample weight sequence and a penalty term; if the sample weight sequence converges and the prediction model converges, output the trained prediction model; the repeating unit 503 is configured to repeat the above training steps if the sample weight sequence does not converge or the prediction model does not converge.
[0096] In some optional implementations of this embodiment, the training unit 502 is further configured to: obtain an association weight sequence between data distributions; calculate the difference between the association weight sequence and the initial sample weight sequence to obtain a weight difference sequence; solve the estimation function corresponding to the maximum value of the second objective function as the target prediction model, wherein the second objective function includes the sum of the products of each loss value in the loss value sequence and the weight difference corresponding to the same time point; solve the sample weight sequence corresponding to the minimum value of the third objective function as the final sample weight sequence, wherein the objective function includes the weighted sum of the sum of the products of each loss value in the loss value sequence and the weight difference corresponding to the same time point, the L2 norm of the difference between the association weight sequence and the sample weight sequence, and the L2 norm of the sample weight sequence.
[0097] In some optional implementations of this embodiment, the training unit 502 is further configured to: solve the estimation function corresponding to the maximum of the second objective function as the target prediction model, including: solving the estimation function corresponding to the maximum of the second objective function as the target prediction model through a planning algorithm based on the difference of convex functions.
[0098] In some optional implementations of this embodiment, the training unit 502 is further configured to: for each time point, use the standard gradient descent algorithm to solve the sample weight that minimizes the loss value at that time point; the sample weights with the smallest loss value at each time point constitute a sample weight sequence.
[0099] In some optional implementations of this embodiment, the loss function is a Huber loss function, and the penalty term uses an L1 norm or an L2 norm.
[0100] Continue to see Figure 6 , as a response to the above Figure 4 The present disclosure provides an embodiment of a device for predicting data. Figure 4 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0101] like Figure 6 As shown, the device 600 for predicting data of this embodiment may include: an acquisition unit 601 and a prediction unit 602. The acquisition unit 601 is configured to acquire a time series data set; the prediction unit 602 is configured to input each time series data in the time series data set into a prediction model trained according to any one of the methods in the first aspect, and output a predicted value of each time series data.
[0102] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0103] An electronic device comprises: one or more processors; a storage device having one or more computer programs stored thereon, wherein when the one or more computer programs are executed by the one or more processors, the one or more processors implement a method as described in any one of processes 200 or 400.
[0104] A computer-readable medium having a computer program stored thereon, wherein the computer program implements the method as described in any one of the processes 200 or 400 when executed by a processor.
[0105] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0106] like Figure 7As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0107] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0108] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as a method for outputting information. For example, in some embodiments, the method for outputting information may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the method for outputting information described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to execute a method for outputting information in any other appropriate manner (e.g., by means of firmware).
[0109] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0110] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0111] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0112] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0113] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0114] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the respective computers and having a client-server relationship with each other. The server may be a server of a distributed system, or a server combined with a blockchain. The server may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. The server may be a server of a distributed system, or a server combined with a blockchain. The server may also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.
[0115] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0116] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for training a weather prediction model, comprising: Obtain a training sample set and an estimation function set, wherein the training sample includes an input variable sequence and an output variable sequence, and the input variable sequence is the daily temperature of the previous year; The following training steps are performed: selecting a target sample from the training sample set; calculating a sample weight sequence according to the target sample; for each estimation function in the estimation function set, inputting the input variable sequence of the target sample into the estimation function for prediction to obtain a prediction value sequence corresponding to the estimation function; calculating a loss value sequence for each estimation function according to a preset loss function, a prediction value sequence corresponding to each estimation function and an output variable sequence of the target sample; solving the estimation function corresponding to the minimum of the first objective function as a weather prediction model, wherein the first objective function includes a weighted sum of a loss value sequence and a sample weight sequence and a penalty term; if the sample weight sequence converges and the weather prediction model converges, outputting the trained weather prediction model; If the sample weight sequence does not converge or the weather prediction model does not converge, the above training steps are repeated.
2. The method according to claim 1, wherein: The step of calculating a sample weight sequence according to the target sample includes: Obtain the association weight sequence between data distributions; Calculate the difference between the associated weight sequence and the initial sample weight sequence to obtain the weight difference sequence; Solving the estimation function corresponding to the maximum of the second objective function as the target weather prediction model, wherein the second objective function includes the sum of the products of each loss value in the loss value sequence and the weight difference corresponding to the same time point; The sample weight sequence corresponding to the minimum of the third objective function is solved as the final sample weight sequence, wherein the third objective function includes the weighted sum of the sum of the products of each loss value in the loss value sequence and the weight difference corresponding to the same time point, the L2 norm of the difference between the associated weight sequence and the sample weight sequence, and the L2 norm of the sample weight sequence.
3. The method according to claim 2, wherein: The method of solving the estimation function corresponding to the maximum of the second objective function as the target weather prediction model includes: The estimated function corresponding to the maximum second objective function is solved by a planning algorithm based on the difference of convex functions as the target weather prediction model.
4. The method according to claim 2, wherein: The sample weight sequence corresponding to the minimum of the third objective function is used as the final sample weight sequence, including: For each time point, the standard gradient descent algorithm is used to solve the sample weight that minimizes the loss value at that time point; The sample weights with the smallest loss value at each time point constitute the sample weight sequence.
5. The method according to any one of claims 1 to 4, wherein: The loss function is a Huber loss function, and the penalty term uses an L1 norm or an L2 norm.
6. A method for predicting data, comprising: Get a collection of time series data; Each time series data in the time series data set is input into the weather prediction model trained according to the method according to any one of claims 1 to 5, and the predicted value of each time series data is output, wherein the time series data is the temperature of each day in the previous year.
7. A device for training a weather prediction model, comprising: An acquisition unit is configured to acquire a training sample set and an estimation function set, wherein the training sample includes an input variable sequence and an output variable sequence, and the input variable sequence is the temperature of each day in the previous year; The training unit is configured to perform the following training steps: selecting a target sample from the training sample set; calculating a sample weight sequence according to the target sample; for each estimation function in the estimation function set, inputting the input variable sequence of the target sample into the estimation function for prediction to obtain a prediction value sequence corresponding to the estimation function; calculating a loss value sequence of each estimation function according to a preset loss function, a prediction value sequence corresponding to each estimation function and an output variable sequence of the target sample; solving the estimation function corresponding to the minimum of the first objective function as a weather prediction model, wherein the first objective function includes a weighted sum of a loss value sequence and a sample weight sequence and a penalty term; if the sample weight sequence converges and the weather prediction model converges, outputting the trained weather prediction model; The repeating unit is configured to repeat the above training steps if the sample weight sequence does not converge or the weather prediction model does not converge.
8. A device for predicting data, comprising: An acquisition unit, configured to acquire a time series data set; The prediction unit is configured to input each time series data in the time series data set into the weather prediction model trained according to the method of any one of claims 1-5, and output the predicted value of each time series data, wherein the time series data is the temperature of each day in the previous year.
9. An electronic device, comprising: one or more processors; a storage device having one or more computer programs stored thereon, When the one or more computer programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
10. A computer readable medium having a computer program stored thereon, wherein: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method, device and equipment for training model and storage medium
CN114021635A
Model training method and apparatus, and prediction method and apparatus
US20210406599A1