Electricity price prediction method based on weighted K nearest neighbor and Gaussian process regression
By adopting the weighted K nearest neighbor and Gaussian process regression method in electricity price prediction, combined with dynamic time interval adjustment and uncertainty evaluation, the shortcomings of traditional electricity price prediction methods in adapting to market fluctuations are solved, and the accuracy and reliability of the prediction are improved.
Patent Information
- Application Number
- CN202510285602.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-11
- Publication Date
- 2025-06-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional electricity price prediction methods are difficult to adapt to the dynamic changes in market fluctuations, resulting in insufficient representation of electricity price data, affecting the accuracy and reliability of the prediction.
The electricity price prediction method based on weighted K nearest neighbor and Gaussian process regression is adopted to provide confidence intervals by dynamically adjusting the acquisition time interval, combining short-term and long-term characteristics, and conducting prediction uncertainty evaluation.
It improves the reliability and application value of electricity price prediction, can capture market changes more accurately, and provide more accurate electricity price prediction ranges.
Smart Images

Figure CN120163601A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electricity price prediction, and more particularly to an electricity price prediction method based on weighted K-nearest neighbor and Gaussian process regression. Background Art
[0002] Electricity price prediction plays an important role in the modern power market and affects the decision-making of power companies, institutions, large industrial users, and end consumers. With the growth of global energy demand and the increase in the proportion of new energy, the volatility of electricity prices has become increasingly severe. Accurate electricity price prediction can not only optimize power dispatching, improve the operation efficiency of the power grid, but also reduce the trading risks in the power market and promote the rational allocation of energy resources.
[0003] Existing electricity price prediction methods mainly use statistical methods and machine learning methods to predict electricity prices. These methods are based on historical electricity price data and influencing factors, and predict the future electricity price trend through model training.
[0004] However, in the process of implementing the technical solutions of the present invention in the embodiments of the present application, it is found that the above technologies have at least the following technical problems: In practical applications, traditional electricity price prediction methods use fixed-time interval sampling, which is difficult to adapt to the dynamic changes of market fluctuations, resulting in insufficient representativeness of electricity price data, and thus affecting the accuracy of prediction. In addition, existing methods mostly use a single time window for training, fail to combine short-term and long-term features, and lack an assessment of prediction uncertainty, making it difficult to provide a confidence interval, thereby reducing the reliability and application value of electricity price prediction. Summary of the Invention
[0005] In order to overcome the above defects of the prior art, the present invention provides an electricity price prediction method based on weighted K-nearest neighbor and Gaussian process regression to solve the problems existing in the above background art.
[0006] To achieve the above object, the present invention provides the following technical solutions: Power price prediction method based on weighted K-nearest neighbor and Gaussian process regression, comprising the following steps: Step 1: During the detection time period, set an initial historical data collection time interval, and obtain historical power price data and historical external influence data at each collection time interval point. The external influence data includes temperature data, supply data, and demand data; Step 2: Evaluate the adjustment index based on the historical external influence data, and determine whether time interval adjustment is required according to the adjustment index; Step 3: If it is determined that time interval adjustment is required, perform time interval adjustment according to the adjustment index to obtain the actual collection time interval; Step 4: Collect historical power price data and historical external influence data for the next time according to the actual collection time interval, and continue to evaluate the external influence data to obtain the next collection time interval; Step 5: Traverse the detection time period to obtain historical power price data and historical external influence data within the detection time period. All historical power price data and historical external influence data are used to form a data set. Each data point in the data set includes the collection time, historical power price data, and historical external influence data. Use weighted K-nearest neighbor to perform preliminary prediction on the data set to obtain a preliminary prediction result; Step 6: Perform Gaussian process regression based on the preliminary prediction result to obtain the final predicted power price interval.
[0007] Preferably, the adjustment index acquisition steps are as follows: Obtain historical temperature data within the collection time period, and evaluate the temperature change coefficient based on the historical temperature data; Obtain historical supply data within the collection time period, calculate the mean value of the historical supply data according to the historical supply data within the collection time period, and calculate the standard deviation of the historical supply data according to the mean value of the historical supply data; Calculate the ratio of the standard deviation of the historical supply data to the mean value of the historical supply data to obtain the supply change coefficient; Obtain historical demand data within the collection time period, and evaluate the demand change coefficient using the singular value decomposition method according to the historical demand data; Normalize the temperature change coefficient, supply change coefficient, and demand change coefficient, and evaluate the adjustment index according to the normalized temperature change coefficient, supply change coefficient, and demand change coefficient. The specific acquisition steps are as follows: ; In the formula, AT represents the adjustment index, TV represents the temperature change coefficient, CS represents the supply change coefficient, CD represents the demand change coefficient, 、 、 represent the weight coefficients of the temperature change coefficient, the weight coefficient of the supply change coefficient, and the weight coefficient of the demand change coefficient.
[0008] Preferably, the temperature change coefficient obtaining step is as follows: set a sliding time window, obtain the temperature data within the time window, and form a temperature time series with the historical temperature data within the time window; use Fourier transform to convert the data in the temperature time series from the time domain to the frequency domain; calculate the amplitude of the result of the Fourier transform; calculate the ratio of the high-frequency energy to the total energy to obtain the temperature change coefficient.
[0009] Preferably, the step of evaluating and obtaining the demand change coefficient using the singular value decomposition method according to the historical demand data is as follows: obtain the historical demand data within the detection time period, form a time series, and use a sliding window to convert the time series into a matrix form to obtain a data matrix; perform standardization processing on the data matrix to obtain a standardized matrix; perform singular value decomposition on the standardized matrix to obtain the singular values of the standardized matrix, obtain the total number of singular values and the number of non-zero singular values, and calculate the demand change coefficient according to the singular values of the standardized matrix. The specific obtaining steps are as follows: ; where CD represents the demand change coefficient, represents the jth singular value, is the measure of the number of non-zero singular values, is the fraction of the total number of singular values.
[0010] Preferably, the step of determining whether to adjust the time interval according to the adjustment index is as follows: compare the adjustment index with the adjustment threshold. If the adjustment index is greater than or equal to the adjustment threshold, it is determined that the time interval needs to be adjusted; if the adjustment index is less than the adjustment threshold, it is determined that the time interval does not need to be adjusted.
[0011] Preferably, the step of adjusting the time interval according to the adjustment index to obtain the actual acquisition time interval is as follows: calculate the ratio of the adjustment threshold to the adjustment index to obtain an adjustment factor; calculate the product of the adjustment factor and the initial historical data acquisition time interval to obtain the actual acquisition time interval.
[0012] Preferably, the step of using weighted K-nearest neighbor to perform a preliminary prediction on the data set to obtain a preliminary prediction result is as follows: determine the target time point to be predicted, obtain the external influence data of the target time point, and calculate the Euclidean distance between each data point in the data set and the target time point. The specific obtaining steps are as follows: ; where represents the Euclidean distance between the ith data point and the target time point, , and represent the temperature data, supply data, and demand data of the ith data point, , and Temperature data, supply data, and demand data represented as target time points; select K data points with the smallest Euclidean distance as the nearest neighbors, and for each nearest neighbor, calculate the weight using inverse weights; perform a weighted average on the historical electricity prices of the K nearest neighbors to obtain a preliminary prediction result for the target time point.
[0013] Preferably, the step of performing Gaussian process regression based on the preliminary prediction result to obtain the final predicted electricity price range is as follows: define the mean function and covariance function of the Gaussian distribution; obtain historical electricity price data, train the covariance matrix between historical electricity price data, obtain the covariance vector between the target time point and historical electricity price data, and obtain the autocovariance of the target time point; obtain the column vector of historical electricity price data according to the covariance matrix, and calculate the final predicted electricity price based on the column vector of historical electricity price data, the covariance vector between the target time point and historical electricity price data, and the autocovariance of the target time point; predict the variance of the electricity price to obtain the confidence interval of the electricity price prediction, and obtain the final predicted electricity price range based on the final predicted electricity price and the confidence interval.
[0014] The technical effects and advantages of the present invention: Set the initial historical data collection time interval, obtain historical electricity price data and historical external influence data, evaluate to obtain an adjustment index, and determine whether time interval adjustment is required. If it is determined that time interval adjustment is required, then obtain the actual collection time interval according to the adjustment index, traverse the detection time period, obtain the historical electricity price data and historical external influence data within the detection time period, and form a data set. Use weighted K-nearest neighbors to perform a preliminary prediction on the data set to obtain a preliminary prediction result, and perform Gaussian process regression based on the preliminary prediction result to obtain the final predicted electricity price range, effectively improving the reliability and application value of electricity price prediction. Description of the Drawings
[0015] Figure 1 It is a flowchart of the electricity price prediction method based on weighted K-nearest neighbors and Gaussian process regression provided by the embodiment of the present application. Detailed Embodiments
[0016] Next, the technical solutions in the present invention will be clearly and completely described in conjunction with the drawings in the present invention. In addition, the forms of the various structures described in the following embodiments are merely examples, and the electricity price prediction method based on weighted K-nearest neighbors and Gaussian process regression involved in the present invention is not limited to the various structures described in the following embodiments. All other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.
[0017] The present invention provides an electricity price prediction method based on weighted K-nearest neighbors and Gaussian process regression, as Figure 1 shown, including the following steps: Step 1: During the detection time period, first set an initial historical data collection time interval, and obtain historical electricity price data and historical external influence data at each collection time interval point. The external influence data includes temperature data, supply data, and demand data; Step 2: Evaluate the adjustment index based on the historical external influence data, and then determine whether time interval adjustment is required according to the adjustment index; In this embodiment, it should be specifically noted that the steps for obtaining the adjustment index are as follows: Obtain the historical temperature data within the collection time period, and evaluate the temperature change coefficient based on the historical temperature data; Obtain the historical supply data within the collection time period, calculate the mean value of the historical supply data based on the historical supply data within the collection time period, and calculate the standard deviation of the historical supply data based on the mean value of the historical supply data. The specific obtaining steps are as follows: ; In the formula, represents the standard deviation of the historical supply data, N is the total number of historical supply data, represents the i-th historical supply data, represents the mean value of the historical supply data; Calculate the ratio of the standard deviation of the historical supply data to the mean value of the historical supply data to obtain the supply change coefficient; Obtain the historical demand data within the collection time period, and evaluate the demand change coefficient based on the historical demand data using the singular value decomposition method; The singular value decomposition method is a matrix decomposition technique used for dimensionality reduction, denoising, and extracting the main features of data. The singular value decomposition method decomposes the original data matrix into three sub-matrices, which respectively represent the main direction (left singular vector), feature importance (singular value), and pattern (right singular vector) of the data, so as to be able to analyze the change trend and main influencing factors of the data. In power demand forecasting, the singular value decomposition method can be used to analyze the principal components of the historical demand data matrix and calculate the change rate of the singular values to evaluate the volatility of demand, so as to obtain the demand change coefficient. Compared with simple statistical methods, the singular value decomposition method can remove data noise, identify the core patterns of demand changes, make the time interval adjustment more adaptable, and improve the prediction accuracy and stability.
[0018] Normalize the temperature change coefficient, supply change coefficient, and demand change coefficient. The advantage of normalization is to convert the temperature change coefficient, supply change coefficient, and demand change coefficient to the same numerical range, avoiding the unbalanced impact of features with different dimensions on the adjustment index calculation. Since the numerical ranges and fluctuation amplitudes of temperature, supply, and demand may vary significantly, direct addition or calculation may lead to a certain feature dominating the adjustment index. After normalization, the contribution weights of all features can be more reasonable, making the calculation of the adjustment index more stable, enhancing the generalization ability of the model, improving the accuracy and robustness of the time interval adjustment decision. The adjustment index is evaluated based on the normalized temperature change coefficient, supply change coefficient, and demand change coefficient. The specific acquisition steps are as follows: ; In the formula, AT represents the adjustment index, and TV represents the temperature change coefficient. In electricity price forecasting, temperature is an important factor affecting electricity demand. For example, high temperatures will lead to an increase in air-conditioning load, and low temperatures will increase heating demand, thus affecting electricity demand and electricity prices. Therefore, when the temperature changes drastically (such as a sudden increase or decrease), the fluctuation of electricity prices may intensify, and the model needs to shorten the time interval to adapt to market changes more quickly; on the contrary, when the temperature change is small, the market is relatively stable, and the time interval can be kept longer to reduce unnecessary adjustments and calculation costs. This proportional relationship ensures that the adjustment index can reflect the dynamic changes of the market environment, making the time interval adjustment more flexible and intelligent. CS represents the supply change coefficient. In electricity price forecasting, the instability of power supply (such as generator failures, fluctuations in renewable energy, scheduling adjustments, etc.) may lead to large fluctuations in electricity prices. For example, the output of wind power or photovoltaic power generation is greatly affected by weather. If the supply suddenly decreases, there may be a power shortage in the market, leading to an increase in electricity prices; conversely, if the supply suddenly increases (such as the large-scale grid connection of hydropower or thermal power), the electricity price may decrease. Therefore, when the supply changes drastically, it is necessary to shorten the time interval and increase the forecasting frequency to adapt to market fluctuations more quickly. CD represents the demand change coefficient. In electricity price forecasting, the fluctuation of electricity demand directly affects the supply-demand balance of the electricity market. For example, during peak hours (such as during high temperatures in summer or cold snaps in winter), the electricity demand surges, which may lead to an increase in electricity prices; while during low-demand periods (such as late at night or holidays), the decrease in demand may lead to a decrease in electricity prices. Therefore, when the demand changes drastically, it is necessary to shorten the time interval and increase the forecasting frequency to adjust the forecasting model in a timely manner and accurately capture market changes. 、 、 Represent the weight coefficients of the temperature change coefficient, supply change coefficient, and demand change coefficient, and , 、 、 Obtained through the analytic hierarchy process, for example , , It can be 0.4, 0.3, 0.3.
[0019] In this embodiment, it should be specifically noted that the steps for obtaining the temperature change coefficient are as follows: Set a sliding time window, obtain the temperature data within the time window. Assume the current time is t and the window size is 6, then obtain the temperature data for the last 6 hours, and form a temperature time series from the historical temperature data within the time window; Use the Fourier transform to convert the data in the temperature time series from the time domain to the frequency domain to analyze the intensity of its different frequency components. The Fourier transform is a mathematical method used to convert time series data from the time domain to the frequency domain and analyze the energy distribution of the signal at different frequencies. The core idea is that any complex time series (such as temperature changes) can be decomposed into the superposition of multiple sine waves with different frequencies. The Fourier transform can identify the periodic components in the data and distinguish between low-frequency (long-term trends) and high-frequency (short-term violent fluctuations) information. In temperature analysis, the Fourier transform can be used to detect the periodic changes in temperature (such as diurnal temperature differences) and sudden fluctuations (such as extreme weather), thereby calculating the temperature change coefficient, assisting in dynamically adjusting the prediction time interval, and improving the accuracy of electricity price prediction; The result of the Fourier transform is a complex number, and its magnitude needs to be calculated. The specific acquisition steps are as follows: ; In the formula, is the magnitude at frequency , that is, the energy magnitude, and are the real part and the imaginary part respectively; Generally, high-frequency components represent rapid fluctuations in temperature, while low-frequency components represent long-term trends. Set a high-frequency threshold to distinguish between low-frequency and high-frequency components, and calculate the ratio of high-frequency energy to total energy to obtain the temperature change coefficient. The specific acquisition steps are as follows: ; In the formula, TV represents the temperature change coefficient, N is the size of the sliding window, is the magnitude at frequency , is the physical frequency, is the high-frequency threshold.
[0020] In this embodiment, it should be specifically noted that the steps for evaluating the demand change coefficient using the singular value decomposition method based on historical demand data are as follows: Obtain the historical demand data within the detection time period to form a time series , m is the number of historical demand data, and the sliding window is used to convert the time series into a matrix form to obtain a data matrix. For example, if the sliding window size is 3, the data matrix can be expressed as , where each row represents a local time window, reflecting the power demand situation within the local time range, and each column represents the same time point in different time windows, which can be used to analyze the change pattern of demand over time; Since the magnitude of power demand in different time periods may be different, the data matrix is standardized to obtain the standardized matrix , to eliminate the influence of individual differences, where is the mean of the matrix M, is the standard deviation of the matrix M, and after standardization, the mean of each column is 0 and the variance is 1; Perform singular value decomposition on the standardized matrix to obtain the singular values of the standardized matrix, obtain the total number of singular values and the number of non-zero singular values, and calculate the demand change coefficient based on the singular values of the standardized matrix. The specific acquisition steps are: ; In the formula, CD represents the demand change coefficient, is represented as the jth singular value, is the number of non-zero singular values, indicating the contribution of the main demand change mode, is the total number of singular values, representing all possible demand change components. The larger the CD, the more complex the demand change pattern and the more drastic the demand fluctuation.
[0021] In this embodiment, it should be specifically explained that the steps of determining whether the time interval adjustment is required according to the adjustment index are: The adjustment index is compared with the adjustment threshold. If the adjustment index is greater than or equal to the adjustment threshold, it is determined that the time interval adjustment is required; if the adjustment index is less than the adjustment threshold, it is determined that the time interval adjustment is not required. The adjustment threshold is obtained through statistical analysis. The statistical analysis method is a method for setting thresholds based on the distribution characteristics of historical data. By calculating statistical indicators such as the mean, standard deviation, and quantile, the range of data changes is analyzed, and a reasonable adjustment threshold is set.
[0022] Step 3: If it is determined that the time interval adjustment is required, the time interval is adjusted according to the adjustment index to obtain the actual collection time interval; The advantage of dynamically adjusting the time interval according to the adjustment index is that it can adapt to the changes in the electricity market, improve the accuracy and stability of prediction, and at the same time optimize the utilization of computing resources. When the market fluctuates greatly (such as drastic changes in temperature, supply, and demand), the acquisition time interval is shortened, enabling the model to capture market changes faster and ensuring the timeliness of prediction; while when the market is relatively stable, the acquisition time interval is extended to reduce unnecessary data acquisition and computational burden and improve system efficiency. This method can avoid the lag or computational redundancy caused by a fixed time interval, making the electricity price prediction more flexible and intelligent, adapting to different market conditions, and improving the overall prediction reliability.
[0023] In this embodiment, it should be specifically noted that the steps for obtaining the actual acquisition time interval by adjusting the time interval according to the adjustment index are as follows: Calculate the ratio of the adjustment threshold to the adjustment index to obtain the adjustment factor; Multiply the adjustment factor by the initial historical data acquisition time interval to obtain the actual acquisition time interval.
[0024] Step 4: Perform the next acquisition of historical electricity price data and historical external influence data according to the actual acquisition time interval, and continue to evaluate the external influence data to obtain the next acquisition time interval; Step 5: Traverse the detection time period to obtain the historical electricity price data and historical external influence data within the detection time period. Construct a data set from all historical electricity price data and historical external influence data. Each data point in the data set includes the acquisition time, historical electricity price data, and historical external influence data. Use weighted K-nearest neighbors to perform a preliminary prediction on the data set to obtain a preliminary prediction result; Weighted K-nearest neighbors is an improved K-nearest neighbor algorithm used for classification and regression tasks. In electricity price prediction, weighted K-nearest neighbors calculates the similarity between the target time point and historical data points (usually using Euclidean distance or other distance metrics), selects the K most similar historical data points as neighbors, and performs a weighted average prediction based on the electricity prices of these neighbors. Different from traditional K-nearest neighbors, K-nearest neighbors assigns higher weights to neighbors closer to the target point, making historical data with higher similarity have a greater impact on the prediction result.
[0025] In this embodiment, it should be specifically noted that the steps for using weighted K-nearest neighbors to perform a preliminary prediction on the data set to obtain a preliminary prediction result are as follows: Determine the target time point to be predicted, such as 12:00 today, obtain the external influence data of the target time point, and calculate the Euclidean distance between each data point in the data set and the target time point. The specific acquisition steps are as follows: ; In the formula, is expressed as the Euclidean distance between the i-th data point and the target time point, and and is expressed as the temperature data, supply data, and demand data of the i-th data point, and and is expressed as the temperature data, supply data, and demand data of the target time point. The supply data and demand data of the target time point are obtained using a long short-term memory neural network, which is a special type of recurrent neural network used to process time series data and is particularly suitable for capturing long-term dependencies. Different from traditional neural networks, the long short-term memory neural network controls the storage, forgetting, and output of information by introducing a "gating mechanism" (input gate, forget gate, and output gate), enabling it to effectively learn and remember data features over long time spans. In electricity price forecasting, the long short-term memory neural network can be used to predict the supply data and demand data of the target time point. By inputting historical data over a past period, it automatically learns the temporal relationships between the data and outputs predicted values of future supply data and demand data. This method can effectively cope with market changes and improve the accuracy of forecasting, especially performing excellently in situations of demand fluctuations and unstable energy supply; Select K data points with the smallest Euclidean distances as the nearest neighbors. For example, when K is 3, for each nearest neighbor, calculate the weights using inverse distance weights. The specific acquisition steps are as follows: ; In the formula, is expressed as the weight of the i-th data point, is expressed as the Euclidean distance between the i-th data point and the target time point. Inverse distance weights is a distance-based weighting method commonly used in the weighted K-nearest neighbor algorithm to calculate the contribution of each nearest neighbor to the target point. The core idea is that the nearer the neighbor is to the target point, the greater its influence on the prediction result and the higher the weight; the farther the neighbor is, the smaller the influence and the lower the weight, which can reduce the interference of data points far from the target point and improve the local accuracy of the prediction; Perform a weighted average of the historical electricity prices of the K nearest neighbors to obtain a preliminary prediction result for the target time point.
[0026] Step 6: Perform Gaussian process regression based on the preliminary prediction result to obtain the final predicted electricity price range.
[0027] Gaussian process regression is a non-parametric Bayesian regression method used to predict continuous variables and provide prediction uncertainty. It first assumes that there is a certain smooth statistical relationship between data points and uses a probability distribution to model the unknown function. The patterns of historical electricity prices are learned through the mean function and covariance function, and future electricity prices are speculated. Different from traditional regression methods, Gaussian process regression not only provides the most likely electricity price value during prediction but also calculates the uncertainty of the prediction, thus giving a confidence interval. This makes Gaussian process regression particularly suitable for market environments with large electricity price fluctuations and complex data distributions, improving prediction accuracy and stability.
[0028] In this embodiment, it should be specifically noted that the steps to obtain the final predicted electricity price interval through Gaussian process regression based on the preliminary prediction results are as follows: In Gaussian process regression, the electricity price is not a fixed value but a random variable that follows a Gaussian distribution. First, the mean function and covariance function of the Gaussian distribution are defined. The mean function describes the average trend of the electricity price, and the covariance function is used to measure the similarity between electricity prices at different time points; Obtain historical electricity price data, train the covariance matrix between historical electricity price data, obtain the covariance vector between the target time point and historical electricity price data, which describes the correlation between the target time point and all historical data points, and obtain the autocovariance of the target time point, which is used to measure the uncertainty of the target time point itself; Obtain the column vector of historical electricity price data according to the covariance matrix, and calculate the final predicted electricity price based on the column vector of historical electricity price data, the covariance vector between the target time point and historical electricity price data, and the autocovariance of the target time point. The specific obtaining steps are as follows: ; In the formula, represents the final predicted electricity price, represents the transpose of the covariance vector between the target time point and historical electricity price data, represents the inverse matrix of the covariance matrix between historical electricity price data, represents the column vector of historical electricity price data; Predict the variance of the electricity price to obtain the confidence interval of the electricity price prediction, and obtain the final predicted electricity price interval based on the final predicted electricity price and the confidence interval.
[0029] Finally: The above are only the preferred embodiments of the present invention and are not used to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
[0030] As described above, it is only the specific implementation manner of the present application. However, the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of changes or substitutions, which should all be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims described above.
Claims
1. The electricity price prediction method based on weighted K nearest neighbor and Gaussian process regression is characterized by: The following steps are involved: Step 1: During the detection period, set an initial historical data collection time interval, and obtain historical electricity price data and historical external impact data at each collection time interval. The external impact data includes temperature data, supply data, and demand data; Step 2: Evaluate the adjustment index based on historical external impact data, and then determine whether time interval adjustment is needed based on the adjustment index; Step 3: If it is determined that the time interval adjustment is required, the time interval is adjusted according to the adjustment index to obtain the actual collection time interval; Step 4: Collect the next historical electricity price data and historical external impact data according to the actual collection time interval, and continue to evaluate the external impact data to obtain the next collection time interval; Step 5: Traverse the detection time period to obtain the historical electricity price data and historical external impact data within the detection time period, and form a data set with all the historical electricity price data and historical external impact data. Each data point in the data set includes the collection time, historical electricity price data and historical external impact data. Use weighted K nearest neighbors to make a preliminary prediction of the data set to obtain a preliminary prediction result. Step 6: Perform Gaussian process regression based on the preliminary prediction results to obtain the final predicted electricity price range.
2. The electricity price prediction method based on weighted K nearest neighbor and Gaussian process regression according to claim 1 is characterized in that: The adjustment index acquisition steps are: Obtain historical temperature data within the collection period, and evaluate the temperature change coefficient based on the historical temperature data; Obtain the historical supply data within the collection period, calculate the mean of the historical supply data based on the historical supply data within the collection period, and calculate the standard deviation of the historical supply data based on the mean of the historical supply data; The supply variation coefficient is calculated by comparing the standard deviation of the historical supply data with the mean of the historical supply data; Obtain historical demand data within the collection period, and use the singular value decomposition method to evaluate the demand change coefficient based on the historical demand data; The temperature variation coefficient, supply variation coefficient and demand variation coefficient are normalized, and the adjustment index is obtained according to the normalized temperature variation coefficient, supply variation coefficient and demand variation coefficient. The specific acquisition steps are as follows: ; In the formula, AT is the adjustment index, TV is the temperature change coefficient, CS is the supply change coefficient, and CD is the demand change coefficient. , , Expressed as the weight coefficient of temperature variation coefficient, the weight coefficient of supply variation coefficient, and the weight coefficient of demand variation coefficient.
3. The electricity price prediction method based on weighted K nearest neighbor and Gaussian process regression according to claim 2 is characterized in that: The temperature variation coefficient acquisition steps are: Set a sliding time window, obtain the temperature data within the time window, and combine the historical temperature data within the time window into a temperature time series; The data in the temperature time series are converted from the time domain to the frequency domain using Fourier transform; Calculate the magnitude of the Fourier transformed result; The temperature variation coefficient is calculated by ratioing the high frequency energy to the total energy.
4. The electricity price prediction method based on weighted K nearest neighbor and Gaussian process regression according to claim 2 is characterized in that: The steps of evaluating the demand change coefficient using the singular value decomposition method based on historical demand data are as follows: Obtain historical demand data within the detection period to form a time series, and use a sliding window to convert the time series into a matrix form to obtain a data matrix; Standardize the data matrix to obtain a standardized matrix; Perform singular value decomposition on the standardized matrix to obtain the singular values of the standardized matrix, obtain the total number of singular values and the number of non-zero singular values, and calculate the demand change coefficient based on the singular values of the standardized matrix. The specific acquisition steps are: ; In the formula, CD represents the demand change coefficient, is represented as the jth singular value, is the number of non-zero singular values, is the total number of singular values.
5. The electricity price prediction method based on weighted K nearest neighbor and Gaussian process regression according to claim 1 is characterized in that: The step of judging whether the time interval adjustment is required according to the adjustment index is as follows: The adjustment index is compared with the adjustment threshold. If the adjustment index is greater than or equal to the adjustment threshold, it is determined that the time interval adjustment is required; if the adjustment index is less than the adjustment threshold, it is determined that the time interval adjustment is not required.
6. The electricity price prediction method based on weighted K nearest neighbor and Gaussian process regression according to claim 1 is characterized in that: The steps of adjusting the time interval according to the adjustment index to obtain the actual collection time interval are: The adjustment threshold is calculated by ratio with the adjustment index to obtain the adjustment factor; The adjustment factor is multiplied by the initial historical data collection time interval to obtain the actual collection time interval.
7. The electricity price prediction method based on weighted K nearest neighbor and Gaussian process regression according to claim 1 is characterized in that: The steps of using weighted K nearest neighbors to make a preliminary prediction on the data set and obtain the preliminary prediction result are as follows: Determine the target time point to be predicted, obtain the external impact data of the target time point, and calculate the Euclidean distance between each data point in the data set and the target time point. The specific acquisition steps are: ; In the formula, It is expressed as the Euclidean distance between the i-th data point and the target time point, , as well as Represented as the temperature data, supply data, and demand data of the i-th data point, , as well as Represented as temperature data, supply data, and demand data at a target time point; Select K data points with the smallest Euclidean distance as the nearest neighbors, and for each nearest neighbor, calculate the weight using the inverse weight; The weighted average of the historical electricity prices of the K nearest neighbors is used to obtain the preliminary prediction result at the target time point.
8. The electricity price prediction method based on weighted K nearest neighbor and Gaussian process regression according to claim 1 is characterized in that: The steps of performing Gaussian process regression based on the preliminary prediction results to obtain the final predicted electricity price range are: Define the mean function and covariance function of Gaussian distribution; Obtain historical electricity price data, train the covariance matrix between historical electricity price data, obtain the covariance vector between the target time point and the historical electricity price data, and obtain the autocovariance at the target time point; According to the covariance matrix, the column vector of the historical electricity price data is obtained, and according to the covariance matrix, the column vector of the historical electricity price data, the covariance vector of the target time point and the historical electricity price data, and the autocovariance calculation of the target time point are obtained to obtain the final predicted electricity price; The variance of the predicted electricity price is used to obtain the confidence interval of the electricity price prediction, and the final predicted electricity price interval is obtained based on the final predicted electricity price and the confidence interval.