Method and device for determining predicted value
By screening training points close to the test point, forming a second training point set, and determining the prediction value based on the set, the problem of insufficient correlation between training data and test data in Gaussian process regression is solved, and the accuracy of the prediction results is improved.
Patent Information
- Application Number
- CN202510080308.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-05-06
AI Technical Summary
In Gaussian process regression, the training data and the test data are less correlated, resulting in the inaccurate prediction results of the test data.
By obtaining the first set of training points and the test points, the training points are screened according to the distance between the test points and each training point, the second set of training points is obtained, and the target prediction value is determined based on the set and the test points.
The correlation between training data and test data is improved, thereby improving the accuracy of the prediction results of test data, and solving the problem of inaccurate prediction results in the prior art.
Smart Images

Figure CN119939253A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of machine learning, and more specifically, to a method and device for determining a prediction value. Background Art
[0002] Generally, distributed machine learning uses deep neural networks as machine learning models, which have achieved unprecedented success in many applications, such as model classification and pattern recognition. However, deep learning is mainly limited to offline learning. In practical applications, working machines will obtain data streams in real-time applications. Therefore, online learning will become a means to solve this problem. Gaussian process regression is one of the effective means. However, using Gaussian process regression for local training generally encounters the following problems. Generally, in the supervised learning framework, similar input data will correspond to similar target values. However, in order to reduce the computational complexity, the nearest neighbor method is selected to handle the inference and prediction process. Although the training process time will be greatly reduced, since only one corresponding projection training point is used for the test point, there is no correlation between the training data. Then, using Gaussian process regression, especially for data points outside the training set, the prediction results of the test data are not accurate enough.
[0003] There is currently no effective solution to the above problems. Summary of the invention
[0004] The embodiments of the present application provide a method and device for determining a prediction value, so as to at least solve the problem in the related art that the correlation between training data and test data is low, resulting in inaccurate prediction results of test data.
[0005] According to one embodiment of the present application, a method for determining a prediction value is provided, comprising: obtaining a first training point set and a test point, wherein the first training point set includes multiple training points, the training points include training input data and training labels, and the test points include: test input data and test labels; screening the training points in the first training point set according to the distance between the test point and each of the training points to obtain a second training point set; and determining a target prediction value based on the second training point set and the test point.
[0006] In an exemplary embodiment, the screening of the training points in the first training point set based on the distance between the test point and each of the training points includes: determining the distance between each of the training points in the first training point set and the test point to obtain a plurality of distance values; determining a distance reference value based on the plurality of distance values; and screening the training points in the first training point set by the distance reference value to obtain the second training point set.
[0007] In an exemplary embodiment, determining a distance reference value based on the multiple distance values includes: sorting the multiple distance values to obtain a distance set, wherein the distance set is sorted in the order of the multiple distance values from small to large or from large to small; determining a distance value in the middle of the distance set as the distance reference value; or determining an average of the multiple distance values as the distance reference value.
[0008] In an exemplary embodiment, the training points in the first training point set are screened by the distance reference value to obtain the second training point set, including: determining the training points in the first training point set that are less than or equal to the distance reference value as the second training point set.
[0009] In an exemplary embodiment, determining the target prediction value based on the second training point set and the test point includes: determining the prediction expectation between each of the training points in the second training point set and the test point to obtain a plurality of prediction expectations; determining the prediction variance between each of the training points in the second training point set and the test point to obtain a plurality of prediction variances; and determining the target prediction value through the plurality of prediction expectations and the plurality of prediction variances.
[0010] In an exemplary embodiment, the target prediction value is determined by the multiple prediction expectations and the multiple prediction variances, including: determining a prediction expectation reference value based on the multiple prediction expectations; determining a prediction variance reference value based on the multiple prediction variances; and determining the target prediction value by the prediction expectation reference value and the prediction variance reference value.
[0011] In an exemplary embodiment, determining a prediction expectation reference value based on the multiple prediction expectations includes: sorting the multiple prediction expectations to obtain a prediction expectation set, wherein the prediction expectation set is sorted in the order of the multiple prediction expectations from small to large or from large to small; determining the prediction expectation ranked in the middle of the prediction expectation set as the prediction expectation reference value; or, determining the mean of the multiple prediction expectations as the prediction expectation reference value; determining a prediction variance reference value based on the multiple prediction variances includes: sorting the multiple prediction variances to obtain a prediction variance set, wherein the prediction variance set is sorted in the order of the multiple prediction variances from small to large or from large to small; determining the prediction variance ranked in the middle of the prediction variance set as the prediction variance reference value; or, determining the mean of the multiple prediction variances as the prediction variance reference value.
[0012] In an exemplary embodiment, the target prediction value is determined by the prediction expectation reference value and the prediction variance reference value, including: filtering the multiple prediction expectations by the prediction expectation reference value to obtain a first prediction expectation set; filtering the multiple prediction variances by the prediction variance reference value to obtain a first prediction variance set; and determining the target prediction value by the first prediction expectation set and the first prediction variance set.
[0013] In an exemplary embodiment, the target prediction value is determined by the first prediction expectation set and the first prediction variance set, including: screening the training points in the second training point set by the first prediction expectation set and the first prediction variance set to obtain a third training point set; and determining the target prediction value by the third training point set.
[0014] In an exemplary embodiment, the training points in the second training point set are screened by the first prediction expectation set and the first prediction variance set to obtain a third training point set, including: determining the training points in the second training point set corresponding to each prediction expectation in the first prediction expectation set as first target training points to obtain a first target training point set; determining the training points in the second training point set corresponding to each prediction variance in the first prediction variance set as second target training points to obtain a second target training point set; and determining the third training point set by the intersection of the first target training point set and the second target training point set.
[0015] In an exemplary embodiment, determining the target prediction value by using the third training point set includes: determining the target prediction variance by using the following formula:
[0016]
[0017] Wherein, the target prediction value includes the target prediction variance, is the third training point set, is the number of training points in the third training point set, cov i,j (f * ) is the prediction variance of each training point in the third training point set.
[0018] In an exemplary embodiment, determining the target prediction value by the third training point set further includes: determining the target prediction expectation by the following formula:
[0019]
[0020] Wherein, the target prediction value includes the target prediction expectation, cov i(f * ) is the target prediction variance, is the third training point set, is the number of training points in the third training point set, cov i,j (f * ) is the prediction variance of each training point in the third training point set, is the predicted expectation of each training point in the third training point set.
[0021] In an exemplary embodiment, the multiple predicted expectations are screened by the predicted expectation reference value to obtain a first predicted expectation set, including: determining the predicted expectations among the multiple predicted expectations whose differences with the predicted expectation reference value are less than or equal to a preset expectation threshold as the first predicted expectation set.
[0022] In an exemplary embodiment, the multiple prediction variances are screened by the prediction variance reference value to obtain a first prediction variance set, including: determining the prediction variance among the multiple prediction variances whose difference with the predicted expected variance value is less than or equal to a preset variance threshold as the first prediction variance set.
[0023] In an exemplary embodiment, determining the prediction expectation between each of the training points in the second training point set and the test point to obtain multiple prediction expectations includes: determining the prediction expectation between the jth training point and the test point by the following formula:
[0024]
[0025] Wherein, the jth training point is any training point in the second training point set, k() is a kernel function, is the training input data of the j-th training point, x * (t) is the test input data of the test point, is the training label of the j-th training point, σ n is the default value and I is the identity matrix.
[0026] In an exemplary embodiment, determining the prediction variance between each of the training points in the second training point set and the test point to obtain a plurality of prediction variances includes: determining the prediction variance between the jth training point and the test point by the following formula:
[0027]
[0028] Wherein, the jth training point is any training point in the second training point set, k() is a kernel function, is the training input data of the j-th training point, x * (t) is the test input data of the test point, σ n is the default value and I is the identity matrix.
[0029] According to another embodiment of the present application, a device for determining a prediction value is provided, comprising: an acquisition module, used to acquire a first training point set and a test point, wherein the first training point set includes multiple training points, the training points include training input data and training labels, and the test points include: test input data and test labels; a screening module, used to screen the training points in the first training point set according to the distance between the test point and each of the training points to obtain a second training point set; a determination module, used to determine a target prediction value based on the second training point set and the test point.
[0030] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0031] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0032] According to another embodiment of the present application, a computer program product is provided, including a computer program, wherein the computer program is executed by a processor to perform the steps in any of the above method embodiments.
[0033] Through the present application, a first training point set and a test point are obtained, wherein the first training point set includes multiple training points, the training points include training input data and training labels, and the test points include: test input data and test labels; the training points in the first training point set are screened according to the distance between the test point and each training point to obtain a second training point set; and the target prediction value is determined according to the second training point set and the test point. Therefore, the problem that the correlation between the training data and the test data is low in the related art, resulting in inaccurate test data prediction results, can be solved, and the accuracy of the test data prediction results can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is a schematic diagram of Gaussian process regression GPR and nearest neighbor Gaussian process regression NNGPR;
[0035] Figure 2It is a hardware structure block diagram of a terminal device or a computer device of a method for determining a prediction value in an embodiment of the present application;
[0036] Figure 3 is a flow chart of a method for determining a prediction value according to an embodiment of the present application;
[0037] Figure 4 is a schematic diagram of constructing a second training set according to an embodiment of the present invention;
[0038] Figure 5 is a schematic diagram of a prediction curve according to an embodiment of the present invention;
[0039] Figure 6 It is a structural block diagram of a device for determining a prediction value according to an embodiment of the present application. DETAILED DESCRIPTION
[0040] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0041] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0042] The key terms of the embodiments of the present invention are explained as follows:
[0043] Distributed machine learning: refers to algorithms and systems that use multiple computing nodes (also called working machines) for machine learning or deep learning, aiming to improve performance, protect privacy, and scale to larger training data and larger models.
[0044] Working machine: A smart terminal, device, or intelligent entity that has its own private data, such as a personal mobile phone or computer.
[0045] Internet of Things: Internet of Things. The Internet of Things refers to a network system that uses the Internet and sensor technology to achieve interconnection between various objects, enabling them to collect, transmit, and exchange data, and realize intelligent control and management. The Internet of Things allows different objects to share information and interact, thereby realizing intelligent monitoring, management and control, and improving production efficiency and quality of life.
[0046] GPR: Gaussian process regression. Gaussian regression is a regression analysis method that assumes that the relationship between the dependent variable and the independent variable is Gaussian distributed. In Gaussian regression, the model is fitted by the maximum likelihood estimation method, and the density function of the Gaussian distribution is used to model the conditional distribution of the dependent variable. In this way, the predicted value of the dependent variable can be obtained and the confidence interval of the model parameters can be estimated. Gaussian regression is often used for predictive analysis of continuous variables.
[0047] The technical background of the embodiments of the present invention is as follows:
[0048] Nowadays, the Internet of Things (IOT) generates a large amount of distributed data. A typical training method is to store this data on the server and let the server train the model. However, communication efficiency and computing efficiency issues are prominent. For example, a car can generate hundreds of Gb of data in a few hours, which is a huge burden in the transmission and computing process.
[0049] The birth of distributed machine learning mainly solves the following problems: first, the amount of calculation is too large, second, there is too much training data, and third, the model scale is too large. For the case of too much calculation, multi-threaded or multi-machine parallel computing based on shared memory (or virtual memory) can be adopted. For the case of too much training data, we can group the data and distribute it to multiple workers for training, so that the local data of each worker is within the specified capacity. Each worker will train a local model based on local data, and will communicate with other workers according to certain rules to transmit necessary information to ensure that the training results from each worker can be effectively integrated and the global machine learning model can be obtained. For the case of a model scale that is too large, the model needs to be divided and distributed to different workers for training. Unlike data parallelism, the dependency between local models in the framework of model parallelism is very strong, because the output of a local model may be the input of another local model. If the intermediate calculation results are not communicated, the entire model training cannot be completed.
[0050] Generally, distributed machine learning uses deep neural networks as machine learning models, which have achieved unprecedented success in many applications, such as model classification and pattern recognition. However, deep learning is mainly limited to offline learning. In practical applications, working machines will obtain data streams in real-time applications. Therefore, online learning will become a means to solve this problem. Gaussian process regression is one of the effective means. In fact, the Gaussian process model can be equivalent to the existing machine learning models, including Bayesian linear models and multi-layer neural networks in a certain sense. According to the central limit theorem, assuming that the weights in the neural network obey the Gaussian distribution, as the width of the neural network approaches infinity, such a neural network is equivalent to Gaussian process regression. However, Gaussian process regression is a non-hyperparameter statistical probability model. Unlike traditional learning models, such as linear regression, logistic regression, and neural networks, which require solving optimization problems to minimize the loss function to obtain the optimal model parameters, Gaussian process regression does not need to solve optimization problems. Given training data and test inputs, the prediction of Gaussian process regression is divided into two steps: inference and prediction. The inference process assumes that the function to be learned obeys the Gaussian process, gives the Gaussian prior probability distribution of the model, and then uses the observed values and the Bayesian rule to find the Gaussian posterior probability distribution of the model. However, using Gaussian process regression for local training generally encounters two problems. The specific description is as follows:
[0051] First, if each worker uses all the data in the local dataset for training, then as the amount of data increases and the data dimension increases, the computational efficiency will become low when calculating the kernel function, and it will not be time-effective. Although Gaussian process regression can perform online predictions for test inputs, since each worker must use all the training data in the dataset for each test input, the inverse of the covariance matrix must be calculated during prediction, and the computational complexity of this operation is where n x is the dimension of the training data. As time goes by, the dimension of the training data n x If the number of requests continues to increase, it will undoubtedly be difficult to ensure real-time performance.
[0052] Second, generally in a supervised learning framework, similar input data will correspond to similar target values. If the training data is very close to the test data, then the training data will provide more effective and useful information for this test point. In the context of Gaussian processes, this similarity is reflected in the covariance matrix. In other words, the covariance matrix defines proximity or similarity. However, in order to reduce computational complexity, the nearest neighbor method is selected to handle the inference and prediction process. Although the training process time will be greatly reduced, since only one corresponding projected training point is used for the test point, there is no correlation between the training data. Then, using Gaussian process regression, especially for data points outside the training set, the prediction results of the test data are not accurate enough. For example, we consider a trigonometric function curve, and then the training data is uniformly sampled in [0, 1]. The test set is sampled in the interval [0, 1.2]. Figure 1 It is a schematic diagram of Gaussian process regression GPR and nearest neighbor Gaussian process regression NNGPR, as shown Figure 1 As shown in the figure, the dotted line indicates the prediction of the test output of the test set using all the training data, while the solid line is the estimation of the test output by the nearest neighbor method. As can be seen from the figure, the prediction results of the nearest neighbor method are not accurate enough, especially in the interval [1, 1.2] outside the training set. The reason is that the training data is not enough to describe the correlation between the data and cannot provide accurate predictions.
[0053] In addition, if individual training points in the training data are subjected to data poisoning attacks, the local prediction expectation and prediction variance obtained by the working machine during local prediction will not be accurate, and robustness to data poisoning attacks cannot be achieved.
[0054] Therefore, as analyzed above, there is a trade-off between computational efficiency and prediction accuracy when using all data or predicting one data, and there is also the problem of not being robust enough to data poisoning attacks.
[0055] The method for determining the prediction value provided in the embodiments of the present application can be executed in a terminal device or a computer device or a similar computing device. Taking running on a terminal device or a computer device as an example, Figure 2 1 is a hardware structure block diagram of a terminal device or a computer device for a method of determining a prediction value in an embodiment of the present application. Figure 2 As shown, the terminal device or computer device may include one or more ( Figure 2 Only one is shown in the figure) a processor 202 (the processor 202 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 204 for storing data, wherein the above terminal device or computer device may also include a transmission device 206 and an input / output device 208 for communication functions. It can be understood by those skilled in the art that Figure 2The structure shown is only for illustration and does not limit the structure of the above terminal device or computer device. Figure 2 More or fewer components as shown, or with Figure 2 Different configurations are shown.
[0056] The memory 204 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for determining the predicted value in the embodiment of the present application. The processor 202 executes various functional applications and data processing by running the computer program stored in the memory 204, that is, the above method is implemented. The memory 204 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 204 may further include a memory remotely arranged relative to the processor 202, and these remote memories can be connected to the terminal device or computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0057] The transmission device 206 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of a terminal device or a computer device. In one example, the transmission device 206 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 206 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0058] In this embodiment, a method for determining a prediction value is provided. Figure 3 is a flow chart of a method for determining a prediction value according to an embodiment of the present application, such as Figure 3 As shown, the process includes the following steps:
[0059] Step S302, obtaining a first training point set and a test point, wherein the first training point set includes a plurality of training points, the training points include training input data and training labels, and the test points include test input data and test labels;
[0060] The first training point set is the initial data set for training. In this embodiment, the training set D = (X, y) is defined as follows, where X = {x(1), x(2), ..., x(n s)} is the input data set, i.e., the above training input data, y = [y(1), y(2), ..., y(n s )] T is the column vector of the aggregated output, i.e., the training label. The test points are data used to test the training effect of the model. The structure of the test points is similar to that of the training point set, and contains test input data and test labels. By dividing the data into training data and test data through the above operations, the performance of the model on unseen data can be evaluated, so as to better understand the generalization ability of the model. Secondly, by using test data to verify the accuracy and stability of the model, the performance of the model can be evaluated more reliably. In addition, by continuously adjusting and optimizing the model, the predictive ability and efficiency of the model can be maximized.
[0061] Step S304, screening the training points in the first training point set according to the distance between the test point and each of the training points to obtain a second training point set;
[0062] Specifically, the distance between each of the training points in the first training point set and the test point is determined to obtain a plurality of distance values; a distance reference value is determined based on the plurality of distance values; and the training points in the first training point set are screened by the distance reference value to obtain the second training point set.
[0063] In distributed machine learning, consider a network with n workers. Define this set as V = {1, 2, ..., n}. At each time t, each worker i∈V uses local training data D i (t) = (X i (t), y i (t)) to predict the function for the test input X * In the embodiment of the present invention, the distance between two training data points x and x′ is defined as d(x, x′) = ||xx′||. Consider each worker i∈V and its local training data set X i , for a test data ix * , calculate the test data ix * To the training set X i The distance of each training point in is marked as d(x * , x′)=||x * -x′||x′∈X i (t). Through the above steps, the distance value between each training point in the first training point set and the test point can be calculated, and the distance reference value can be determined according to the above distance value. The specific determination method is as follows:
[0064] The multiple distance values are sorted to obtain a distance set, wherein the distance set is sorted in the order of the multiple distance values from small to large or from large to small; the distance value in the middle of the distance set is determined as the distance reference value; or the average of the multiple distance values is determined as the distance reference value.
[0065] The distance values can be sorted from small to large or from large to small. For example, assuming d1(x * , x1) is the first training point x1 and the test input x * , and this distance is the smallest; similarly, let For nth i Training points With test input x * And this distance is the largest.
[0066]
[0067] Then, the distance value in the middle after sorting can be determined as the distance reference value, that is, in the calculated distance set, a median is selected, that is, d med (x * , x j ), where j∈[1,n i ]. Then the training data corresponding to the distance smaller than the median distance can be used to calculate the test input x * The posterior probability expectation and posterior probability variance. The mean of the above multiple distance values can also be calculated as the above distance reference value, that is, Then the training data corresponding to the distance smaller than the mean Can also be used to calculate the test input x * Through the above operation, the training points close to the test points can be determined, which improves the correlation between the training data and the test data, and thus improves the accuracy of the prediction results of the test data.
[0068] The training points in the first training point set that are less than or equal to the distance reference value are determined as the second training point set.
[0069] The training points whose distance from the test point is less than or equal to the distance reference value are selected from the first training point set as the second training point set. Figure 4 is a schematic diagram of constructing a second training set according to an embodiment of the present invention. Figure 4As shown in FIG. 1 , a training point that is closer to the test point is selected from multiple training points as a training subset (the second training point set mentioned above), and then the model is trained using the training subset to improve the accuracy of the test data prediction results. In this embodiment, for each worker i∈V, a new training set is constructed according to the above steps. Through the above operations, the training data that is closer to the test point is screened out, the correlation between the training data and the test data is improved, and the accuracy of the prediction results of the test data is improved.
[0070] Step S306: determining a target prediction value according to the second training point set and the test point.
[0071] In an exemplary embodiment, the prediction expectation between each of the training points in the second training point set and the test point is determined to obtain a plurality of prediction expectations; the prediction variance between each of the training points in the second training point set and the test point is determined to obtain a plurality of prediction variances; and the target prediction value is determined by the plurality of prediction expectations and the plurality of prediction variances.
[0072] Specifically, the predicted expectation between the jth training point in the second training point set and the test point is determined by the following formula:
[0073]
[0074] Wherein, the jth training point is any training point in the second training point set, k() is a kernel function, is the training input data of the j-th training point, x * (t) is the test input data of the test point, is the training label of the j-th training point, σ n is the default value and I is the identity matrix.
[0075] Through the above operation, the above expected value is used as one of the evaluation criteria for the correlation between the training points in the second training point set and the test points, and then the training points with high correlation with the test points are screened out in the second training point set to improve the accuracy of the test point prediction results.
[0076] The prediction variance (cov) between the jth training point and the test point is determined by the following formula i,j (f * )):
[0077]
[0078] Wherein, the jth training point is any training point in the second training point set, k() is a kernel function, is the training input data of the j-th training point, x * (t) is the test input data of the test point, σ n is the default value and I is the identity matrix.
[0079] Through the above operation, the above variance is used as one of the evaluation criteria for the correlation between the training points in the second training point set and the test points, and then the training points with high correlation with the test points are screened out in the second training point set to improve the accuracy of the test point prediction results.
[0080] In the second training set The above formula is used to obtain the predicted expected value between each training point and test point and the prediction variance cov i,j (f * ).
[0081] In an exemplary embodiment, a prediction expectation reference value is determined based on the multiple prediction expectations; a prediction variance reference value is determined based on the multiple prediction variances; and the target prediction value is determined by the prediction expectation reference value and the prediction variance reference value.
[0082] Specifically, the multiple prediction expectations are sorted to obtain a prediction expectation set, wherein the prediction expectation set is sorted in the order of the multiple prediction expectations from small to large or from large to small; the prediction expectation ranked in the middle of the prediction expectation set is determined as the prediction expectation reference value; or, the average of the multiple prediction expectations is determined as the prediction expectation reference value.
[0083] The predicted expected values are sorted from small to large or from large to small. The above-mentioned predicted expected reference value can also be determined as the average of the above-mentioned multiple predicted expectations. Determined as the expected reference value for the above prediction.
[0084] In an exemplary embodiment, the multiple predicted expectations are screened by the predicted expectation reference value to obtain a first predicted expectation set; the predicted expectations among the multiple predicted expectations whose difference with the predicted expectation reference value is less than or equal to a preset expectation threshold are determined as the first predicted expectation set.
[0085] The above prediction expectation threshold is ε f , the method for screening the first prediction expectation set can be It can also be The predicted expected values that are less than or equal to the predicted expected threshold are selected from the above-mentioned multiple predicted expected values as the above-mentioned first predicted expected set. Through the above-mentioned steps, the training points that are closer to the test points can be further selected to improve the correlation between the test data and the training data, thereby improving the accuracy of the prediction results of the test data.
[0086] Specifically, the multiple prediction variances are sorted to obtain a prediction variance set, wherein the prediction variance set is sorted in the order of the multiple prediction variances from small to large or from large to small; the prediction variance ranked in the middle of the prediction variance set is determined as the prediction variance reference value; or, the mean of the multiple prediction variances is determined as the prediction variance reference value.
[0087] The above prediction variances can be sorted from small to large or from large to small. Then the sorted prediction variance cov in the middle can be i,mean (f * ) The above-mentioned prediction variance reference value can also be the mean of the above-mentioned multiple prediction variances Determined as the above-mentioned prediction variance reference value.
[0088] In an exemplary embodiment, the multiple prediction variances are screened by the prediction variance reference value to obtain a first prediction variance set; and the prediction variance among the multiple prediction variances whose difference with the predicted expected variance value is less than or equal to a preset variance threshold is determined as the first prediction variance set.
[0089] The above prediction variance threshold is ε cov , the method for selecting the first prediction variance set can be |cov i,j (f * )-cov i ,mean (f * )|≤ε cov , or Prediction variance values that are less than or equal to the prediction variance threshold are selected from the multiple prediction variance values as the first prediction variance set. Through the above steps, training points that are closer to the test points can be further selected to improve the correlation between the test data and the training data, thereby improving the accuracy of the prediction results of the test data.
[0090] The training points in the second training point set are screened by using the first prediction expectation set and the first prediction variance set to obtain a third training point set; and the target prediction value is determined by using the third training point set.
[0091] Specifically, the training points in the second training point set corresponding to each predicted expectation in the first predicted expectation set are determined as first target training points to obtain a first target training point set; the training points in the second training point set corresponding to each predicted variance in the first predicted variance set are determined as second target training points to obtain a second target training point set; the third training point set is determined by the intersection of the first target training point set and the second target training point set.
[0092] After obtaining the first prediction expectation set and the first prediction variance set, the training points corresponding to the prediction expectations in the first prediction expectation set are selected from the second training point set as the first target training point set, and the training points corresponding to the prediction expectations in the first prediction variance set are selected from the second training point set as the second target training point set, and then the intersection of the first target training point set and the second target training point set is used as the third training point set. Through the above steps, training points that are closer to the test points can be further selected to improve the correlation between the test data and the training data, thereby improving the accuracy of the prediction results of the test data.
[0093] In an exemplary embodiment, the target prediction value is determined by the third set of training points.
[0094] Specifically, the target prediction variance is determined by the following formula:
[0095]
[0096] Wherein, the target prediction value includes the target prediction variance, is the third training point set, is the number of training points in the third training point set, cov i,j (f * ) is the prediction variance of each training point in the third training point set.
[0097] Specifically, the target prediction expectation is determined by the following formula:
[0098]
[0099] Wherein, the target prediction value includes the target prediction expectation, cov i (f * ) is the target prediction variance, is the third training point set, is the number of training points in the third training point set, cov i,j (f *) is the prediction variance of each training point in the third training point set, is the predicted expectation of each training point in the third training point set.
[0100] Through the above steps, the local target prediction expectation and target prediction variance of the working machine of this embodiment can be obtained. The user local learning method of this embodiment can not only improve the correlation between training data, but also improve the correctness of test output. The most important point is that it can resist data poisoning attacks in the data set.
[0101] The specific implementation of the embodiment of the present invention is as follows:
[0102] Define the objective function as f(x):X→Y, where Yes x dimensional input space. Without loss of generality, we assume that the output is one-dimensional, that is, At time t, given x(t)∈X, the corresponding output is
[0103] Less = f(x) + ε
[0104] Here, ε is subject to mean 0 and variance is Gaussian noise with a Gaussian probability distribution, that is Define a training set D = (X, y) in the following form, where is the input data set, y=[y(1), y(2), ..., y(n s )] T is a column vector of aggregated outputs. The Gaussian process regression goal is to use the training set D = (X, y) on the test data set Approximate function f on.
[0105] Define a symmetric positive semidefinite kernel function That is, ∫k(x,x′)f(x)f(x′)dv(x)dv(x′)≥0.
[0106] where f∈L2(X,v), v is the measure. Let f(X) return a column vector such that its i-th element is equal to f(x(i)). Assume that function f is a sample from a Gaussian process prior probability distribution, the mean function of this prior distribution is μ, and the kernel function is k. Then the training output and test output f(X * ) obeys the joint probability distribution
[0107]
[0108] where μ(X) and μ(X * ) returns the value of μ(x(i)) and μ(x * (i)) composed of a vector, k(X, X* ) returns a matrix such that the element in the i-th row and j-th column is k(x(i), x * (j)).
[0109] Using the properties of Gaussian process, Gaussian process regression uses the training set D = (X, y) to predict the test data set X * The output of this output ff(X * ) still obeys the normal distribution, that is, here
[0110]
[0111] The specific steps of distributed training in the embodiment of the present invention are as follows:
[0112] 1. Construction of distance sets based on local training points
[0113] The distance between two training data points x and x′ is defined as d(x, x′) = ||xx′||.
[0114] Step 1: Consider each worker i∈V and its local training dataset X i , for a test data ix * , calculate the test data ix * To the training set X i The distance of each training point in is marked as
[0115] d(x * , x′)=||x * -x′|| x′∈X i (t)
[0116] At each time t, this scheme defines n i is the number of training data of the i-th worker. Then, this scheme sorts all the calculated distances from small to large. Without loss of generality, this scheme assumes that d1(x * , x1) is the first training point x1 and the test input x * , and this distance is the smallest; similarly, let For nth i Training points With test input x * And this distance is the largest.
[0117]
[0118] Step 2: Select a median from the distance set calculated in the previous step, i.e. d med (x * , x j ), where j∈[1,ni ]. Then the training data corresponding to the distance smaller than the median distance can be used to calculate the test input x * The posterior probability expectation and posterior probability variance. The mean of the multiple distance values calculated in the previous step can also be calculated as the above distance reference value, that is, Then the training data corresponding to the distance smaller than the mean Can also be used to calculate the test input x * The expected posterior probability and the variance of the posterior probability.
[0119] Step 3: For each worker i∈V, construct a new training set according to the above steps
[0120] 2. Choose the kernel function
[0121] Generally, the kernel function chooses the squared exponential (SE) function
[0122]
[0123] 3. For each worker i∈V, at each training point The Gaussian posterior probability distribution is calculated on
[0124]
[0125] In the training subset Using the above formula, we can get multiple predictions. and cov i,j (f * ).
[0126] In the above training subset Sort the multiple predictions and then use the median to select and cov i,mean (f * ), and then choose the threshold ε f and ε cov .
[0127] definition
[0128]
[0129] |cov i,j (f * )-cov i,mean (f * )|≤ε cov
[0130] or
[0131]
[0132] According to the above inequality, find all data sets that satisfy this inequality and Finally, perform the intersection operation
[0133] This scheme calculates the prediction and cov i,j (f * ) Perform the following linear convex combination operation to obtain the local prediction of each working machine
[0134]
[0135] 6. Send this local prediction to the server. The server uses an aggregation algorithm to aggregate the local prediction values and give a global prediction.
[0136] Through the above steps, the problem in the related art that the correlation between training data and test data is low, resulting in inaccurate test data prediction results, is solved, and the accuracy of the test data prediction results is improved.
[0137] For example, suppose the objective function is
[0138]
[0139] The sampling is uniform in the interval [0, 8], and the sampling interval is 0.1. The variance of the Gaussian noise is 0.01. According to the objective function, the measurement value of the training data can be obtained.
[0140] The kernel function uses the squared exponential function, where the parameters are l=1, test data x * The samples are uniformly sampled in [0, 10] with a sampling interval of 0.05. Figure 5 Schematic diagram of the prediction curve of the embodiment of the present invention. Figure 3 As shown, the circles are observed values, the black curve is the predicted curve, and the gray shaded part is the confidence interval. It can be seen that in the interval [8, 10], the prediction uses the correlation of the covariance matrix of the training data, which has a certain correlation with the prediction.
[0141] The above examples prove that the double screening of the embodiment of the present invention, i.e., the first step is screening by distance value, and the second step is screening by mean and variance, so as to obtain training data with higher correlation with the test data, thereby improving the accuracy of the test data prediction results.
[0142] Under the framework of distributed machine learning, an embodiment of the present invention proposes a local online learning algorithm for a working machine based on median prediction average. The learning model uses Gaussian process regression (GPR) to process streaming data. Specifically, for a test input, the embodiment of the present invention calculates the distance between all training points and test points in the training set and sorts them; by selecting the median of the distance, a feasible set of local training points is constructed, and each training data is used to calculate the posterior prediction expectation and prediction variance; then, among all the expectations and variances obtained, the median prediction is selected, and then the prediction expectation and variance within a certain range are linearly convexly combined to obtain the local prediction expectation and prediction variance of the working machine. This user local learning method can not only improve the correlation between training data, but also improve the correctness of test output. The most important point is that it can resist data poisoning attacks in the data set.
[0143] The advantages of the embodiments of the present invention lie in the following three aspects: first, the computational efficiency of the algorithm is greatly improved, so that the model training and output prediction time are greatly reduced; second, by utilizing the correlation between the data in the constructed training subset, there is no need to calculate the covariance matrix of Gaussian process regression GPR, and the correctness of the output prediction of new test data can be guaranteed; third, by truncation of the median, the robustness of the local prediction results to data poisoning attacks can be guaranteed.
[0144] The key points of the embodiments of the present invention are the adoption of online learning models, the construction method of training subsets, and the solution to resist data poisoning attacks.
[0145] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0146] In the present embodiment, a device for determining predicted values is also provided, and the device is used to implement the above-mentioned embodiments and preferred embodiments, and the descriptions thereof are omitted. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and contemplated.
[0147] Figure 6 is a structural block diagram of a device for determining a prediction value according to an embodiment of the present application, such as Figure 6 As shown, the device includes an acquisition module 602, which is used to acquire a first training point set and a test point, wherein the first training point set includes multiple training points, the training points include training input data and training labels, and the test points include: test input data and test labels; a screening module 604, which is used to screen the training points in the first training point set according to the distance between the test point and each of the training points to obtain a second training point set; a determination module 606, which is used to determine the target prediction value according to the second training point set and the test point.
[0148] In an exemplary embodiment, the above-mentioned device is also used to determine the distance between each of the training points in the first training point set and the test point to obtain multiple distance values; determine a distance reference value based on the multiple distance values; and filter the training points in the first training point set by the distance reference value to obtain the second training point set.
[0149] In an exemplary embodiment, the above-mentioned device is also used to sort the multiple distance values to obtain a distance set, wherein the distance set is sorted in the order of the multiple distance values from small to large or from large to small; the distance value sorted in the middle of the distance set is determined as the distance reference value; or, the average of the multiple distance values is determined as the distance reference value.
[0150] In an exemplary embodiment, the apparatus is further configured to determine training points in the first training point set that are less than or equal to the distance reference value as the second training point set.
[0151] In an exemplary embodiment, the above-mentioned device is also used to determine the prediction expectation between each of the training points in the second training point set and the test point to obtain multiple prediction expectations; determine the prediction variance between each of the training points in the second training point set and the test point to obtain multiple prediction variances; determine the target prediction value through the multiple prediction expectations and the multiple prediction variances.
[0152] In an exemplary embodiment, the above-mentioned device is also used to determine a prediction expectation reference value based on the multiple prediction expectations; determine a prediction variance reference value based on the multiple prediction variances; and determine the target prediction value through the prediction expectation reference value and the prediction variance reference value.
[0153] In an exemplary embodiment, the above-mentioned device is also used to sort the multiple prediction expectations to obtain a prediction expectation set, wherein the prediction expectation set is sorted in the order of the multiple prediction expectations from small to large or from large to small; the prediction expectation ranked in the middle of the prediction expectation set is determined as the prediction expectation reference value; or, the mean of the multiple prediction expectations is determined as the prediction expectation reference value; sort the multiple prediction variances to obtain a prediction variance set, wherein the prediction variance set is sorted in the order of the multiple prediction variances from small to large or from large to small; the prediction variance ranked in the middle of the prediction variance set is determined as the prediction variance reference value; or, the mean of the multiple prediction variances is determined as the prediction variance reference value.
[0154] In an exemplary embodiment, the above-mentioned device is also used to filter the multiple prediction expectations through the prediction expectation reference value to obtain a first prediction expectation set; filter the multiple prediction variances through the prediction variance reference value to obtain a first prediction variance set; and determine the target prediction value through the first prediction expectation set and the first prediction variance set.
[0155] In an exemplary embodiment, the above-mentioned device is also used to screen the training points in the second training point set through the first prediction expectation set and the first prediction variance set to obtain a third training point set; and determine the target prediction value through the third training point set.
[0156] In an exemplary embodiment, the above-mentioned device is also used to determine the training points in the second training point set corresponding to each predicted expectation in the first predicted expectation set as first target training points, so as to obtain a first target training point set; determine the training points in the second training point set corresponding to each predicted variance in the first predicted variance set as second target training points, so as to obtain a second target training point set; and determine the third training point set by the intersection of the first target training point set and the second target training point set.
[0157] In an exemplary embodiment, the apparatus is further configured to determine the target prediction variance by the following formula:
[0158]
[0159] Wherein, the target prediction value includes the target prediction variance, is the third training point set, is the number of training points in the third training point set, cov i,j (f * ) is the prediction variance of each training point in the third training point set.
[0160] In an exemplary embodiment, the above device is also used to determine the target prediction expectation by the following formula:
[0161]
[0162] Wherein, the target prediction value includes the target prediction expectation, cov i (f * ) is the target prediction variance, is the third training point set, is the number of training points in the third training point set, cov i,j (f * ) is the prediction variance of each training point in the third training point set, is the predicted expectation of each training point in the third training point set.
[0163] In an exemplary embodiment, the above-mentioned device is also used to determine the predicted expectations among the multiple predicted expectations whose differences with the predicted expectation reference value are less than or equal to a preset expectation threshold as the first predicted expectation set.
[0164] In an exemplary embodiment, the apparatus is further configured to determine the prediction variances among the multiple prediction variances whose difference with the predicted expected variance value is less than or equal to a preset variance threshold as the first prediction variance set.
[0165] In an exemplary embodiment, the apparatus is further used to determine the predicted expectation between the j-th training point and the test point by the following formula:
[0166]
[0167] Wherein, the jth training point is any training point in the second training point set, k() is a kernel function, is the training input data of the j-th training point, x * (t) is the test input data of the test point, is the training label of the j-th training point, σ n is the default value and I is the identity matrix.
[0168] In an exemplary embodiment, the apparatus is further configured to determine the prediction variance between the jth training point and the test point by the following formula:
[0169]
[0170] Wherein, the jth training point is any training point in the second training point set, k() is a kernel function, is the training input data of the j-th training point, x * (t) is the test input data of the test point, σ n is the default value and I is the identity matrix.
[0171] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0172] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0173] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0174] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0175] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0176] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0177] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0178] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for determining a predicted value, characterized in that include: Acquire a first training point set and a test point, wherein the first training point set includes a plurality of training points, the training points include training input data and training labels, and the test points include test input data and test labels; Filter the training points in the first training point set according to the distance between the test point and each of the training points to obtain a second training point set; A target prediction value is determined based on the second training point set and the test point.
2. The method according to claim 1, characterized in that: The screening of the training points in the first training point set according to the distance between the test point and each of the training points includes: Determine the distance between each of the training points in the first training point set and the test point to obtain a plurality of distance values; determining a distance reference value according to the plurality of distance values; The training points in the first training point set are screened by using the distance reference value to obtain the second training point set.
3. The method according to claim 2, characterized in that Determining a distance reference value according to the multiple distance values comprises: Sorting the multiple distance values to obtain a distance set, wherein the distance set is sorted in the order of the multiple distance values from small to large or from large to small; determining the distance value in the middle of the distance set as the distance reference value; or, An average value of the plurality of distance values is determined as the distance reference value.
4. The method according to claim 3, characterized in that: The training points in the first training point set are screened by the distance reference value to obtain the second training point set, including: The training points in the first training point set that are less than or equal to the distance reference value are determined as the second training point set.
5. The method according to claim 1, characterized in that: The determining the target prediction value according to the second training point set and the test point comprises: Determine the prediction expectation between each of the training points in the second training point set and the test point to obtain a plurality of prediction expectations; Determine the prediction variance between each of the training points in the second training point set and the test point to obtain a plurality of prediction variances; The target prediction value is determined by the multiple prediction expectations and the multiple prediction variances.
6. The method according to claim 5, characterized in that Determining the target prediction value by using the multiple prediction expectations and the multiple prediction variances includes: Determining a predicted expectation reference value according to the plurality of predicted expectations; determining a prediction variance reference value according to the plurality of prediction variances; The target prediction value is determined by the prediction expectation reference value and the prediction variance reference value.
7. The method according to claim 6, characterized in that Determining a prediction expectation reference value according to the multiple prediction expectations includes: Sorting the multiple prediction expectations to obtain a prediction expectation set, wherein the prediction expectation set is sorted in the order of the multiple prediction expectations from small to large or from large to small; determining the prediction expectation in the middle of the prediction expectation set as the prediction expectation reference value; or determining the average of the multiple prediction expectations as the prediction expectation reference value; Determining a prediction variance reference value according to the multiple prediction variances includes: The multiple prediction variances are sorted to obtain a prediction variance set, wherein the prediction variance set is sorted in the order of the multiple prediction variances from small to large or from large to small; the prediction variance ranked in the middle of the prediction variance set is determined as the prediction variance reference value; or, the mean of the multiple prediction variances is determined as the prediction variance reference value.
8. The method according to claim 6, characterized in that Determining the target prediction value by using the prediction expectation reference value and the prediction variance reference value includes: Filtering the plurality of prediction expectations by using the prediction expectation reference value to obtain a first prediction expectation set; Filtering the plurality of prediction variances by using the prediction variance reference value to obtain a first prediction variance set; The target prediction value is determined by the first prediction expectation set and the first prediction variance set.
9. The method according to claim 8, characterized in that Determining the target prediction value by using the first prediction expectation set and the first prediction variance set includes: The training points in the second training point set are screened by using the first prediction expectation set and the first prediction variance set to obtain a third training point set; The target prediction value is determined by the third training point set.
10. The method according to claim 9, characterized in that The training points in the second training point set are screened by using the first prediction expectation set and the first prediction variance set to obtain a third training point set, including: Determine the training points in the second training point set corresponding to each predicted expectation in the first predicted expectation set as first target training points to obtain a first target training point set; Determine the training points in the second training point set corresponding to the respective prediction variances in the first prediction variance set as second target training points, to obtain a second target training point set; The third training point set is determined by the intersection of the first target training point set and the second target training point set.
11. The method according to claim 9, characterized in that Determining the target prediction value by using the third training point set includes: The target prediction variance is determined by the following formula: Wherein, the target prediction value includes the target prediction variance, is the third training point set, is the number of training points in the third training point set, cov i,j (f * ) is the prediction variance of each training point in the third training point set.
12. The method according to claim 11, characterized in that Determining the target prediction value by using the third training point set also includes: The target forecast expectation is determined by the following formula: Wherein, the target prediction value includes the target prediction expectation, cov i (f * ) is the target prediction variance, is the third training point set, is the number of training points in the third training point set, cov i,j (f * ) is the prediction variance of each training point in the third training point set, is the predicted expectation of each training point in the third training point set.
13. The method according to claim 11, characterized in that The plurality of prediction expectations are screened by the prediction expectation reference value to obtain a first prediction expectation set, including: The predicted expectations among the multiple predicted expectations whose differences with the predicted expectation reference value are less than or equal to a preset expectation threshold are determined as the first predicted expectation set.
14. The method according to claim 11, characterized in that The plurality of prediction variances are screened by using the prediction variance reference value to obtain a first prediction variance set, including: The prediction variances among the multiple prediction variances whose difference with the predicted expected variance value is less than or equal to a preset variance threshold are determined as the first prediction variance set.
15. The method according to claim 5, characterized in that Determining the prediction expectation between each of the training points in the second training point set and the test point to obtain a plurality of prediction expectations includes: The prediction expectation between the jth training point and the test point is determined by the following formula: Wherein, the jth training point is any training point in the second training point set, k() is a kernel function, is the training input data of the j-th training point, x * (t) is the test input data of the test point, is the training label of the j-th training point, σ n is the default value and I is the identity matrix.
16. The method according to claim 5, characterized in that Determining the prediction variance between each of the training points in the second training point set and the test point to obtain a plurality of prediction variances includes: The prediction variance between the jth training point and the test point is determined by the following formula: Wherein, the jth training point is any training point in the second training point set, k() is a kernel function, is the training input data of the j-th training point, x * (t) is the test input data of the test point, σ n is the default value and I is the identity matrix.
17. A device for determining a predicted value, characterized in that include: An acquisition module, configured to acquire a first training point set and a test point, wherein the first training point set includes a plurality of training points, the training points include training input data and training labels, and the test points include test input data and test labels; A screening module, configured to screen the training points in the first training point set according to the distance between the test point and each of the training points, to obtain a second training point set; A determination module is used to determine a target prediction value according to the second training point set and the test point.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 16 when executed by a processor.
19. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 16 are implemented.
20. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 16 are implemented.