Lightning activity prediction method and device, electronic equipment and storage medium

By training and optimizing the KNN model, combining distance and weights, and adjusting the lightning prediction model using the cost of misclassification, the problem of insufficient recognition ability in lightning prediction methods is solved, the prediction accuracy and reliability are improved, and the adaptability of the model is enhanced.

CN121328841APending Publication Date: 2026-01-13GUIZHOU POWER GRID CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511504957.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-21
Publication Date
2026-01-13

AI Technical Summary

Technical Problem

Existing lightning prediction methods are not good at identifying lightning patterns and are prone to underfitting or overfitting, resulting in insufficient accuracy and reliability of prediction results.

Method used

By acquiring lightning sample data, an initial KNN model is trained. Combining various distance and weight combinations, the optimal combination parameters when the local analysis indicator POD and the global analysis indicator FAR are optimal are selected. The cost of misclassification is incorporated to optimize and adjust the KNN model to reduce false alarms and improve prediction accuracy.

Benefits of technology

It improves the accuracy and reliability of lightning activity prediction, reduces sensitivity to noisy data, enhances the model's adaptability to different lightning scenarios, and reduces the risk of overfitting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121328841A_ABST
    Figure CN121328841A_ABST
Patent Text Reader

Abstract

The invention discloses a thunder and lightning activity prediction method and device, electronic equipment and a storage medium, which are used for solving the technical problem of insufficient precision and reliability of a prediction result caused by insufficient recognition capability of a current thunder and lightning prediction method on a thunder and lightning mode. Obtaining thunder and lightning sample data and an initial KNN model; training the initial KNN model in combination with a distance measurement mode and a weight mode according to thunder and lightning sample data to obtain an optimal combination parameter when a local analysis index POD and a global analysis index FAR are optimal, and generating an expected KNN model based on the optimal combination parameter; taking the false lightning stroke misclassification condition as misclassification cost, performing optimization adjustment on the expected KNN model based on the lightning sample data, and obtaining a target KNN model; and predicting the lightning activity by using the target KNN model to obtain a prediction result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for predicting lightning activity. Background Technology

[0002] Lightning is a common physical phenomenon in nature. While its individual distribution is random, its overall distribution exhibits certain regularities. With the expansion of power grids and the increase in voltage levels, the application of intelligent power equipment and low-voltage equipment is becoming increasingly widespread. Lightning not only has a powerful destructive force on communication systems and power facilities but also poses a serious threat to human life. Therefore, it is essential to predict and warn of lightning activity in advance.

[0003] The focus of lightning proximity warning work is to predict the risk assessment parameters related to lightning strikes, providing preparation time for lightning protection and estimating disaster losses. One of its key aspects is predicting the occurrence of lightning. Due to the characteristics of lightning phenomena, such as small range, rapid change, and strong randomness, previous forecasting methods based on numerical models have insufficient data volume and spatiotemporal resolution to meet the needs of industrial early warning, resulting in relatively limited application and research. Therefore, more prediction methods that do not rely on numerical models have been proposed. For example, by extracting and analyzing features from real-time observation data such as atmospheric electric field data, ground lightning location data, and weather radar data, lightning proximity warnings can be achieved based on changes in feature data strongly correlated with lightning phenomena.

[0004] However, current lightning prediction methods are not good at identifying lightning patterns and are prone to underfitting or overfitting, which leads to problems such as insufficient accuracy and reliability of prediction results. Summary of the Invention

[0005] This invention provides a lightning activity prediction method, apparatus, electronic device, and storage medium, which solves or partially solves the technical problem that the current lightning prediction methods have insufficient ability to identify lightning patterns, resulting in insufficient accuracy and reliability of prediction results.

[0006] This invention provides a method for predicting lightning activity, the method comprising:

[0007] Obtain lightning sample data and an initial KNN model;

[0008] The initial KNN model is trained using a combination of distance metric and weighting based on the lightning sample data to obtain the optimal combination parameters when the local analysis index POD and the global analysis index FAR are at their best. The desired KNN model is then generated based on the optimal combination parameters.

[0009] The misclassification of false reporting of lightning strikes is taken as a misclassification cost, and the expected KNN model is optimized and adjusted based on the lightning sample data to obtain a target KNN model;

[0010] The lightning activity is predicted by using the target KNN model to obtain a prediction result.

[0011] Optionally, the initial KNN model is trained according to the lightning sample data in terms of a combination of distance measurement methods and weight forms to obtain optimal combination parameters when a local analysis indicator POD and a global analysis indicator FAR are optimal, and an expected KNN model is generated based on the optimal combination parameters, including:

[0012] The initial KNN model is trained according to the lightning sample data to determine combination parameters under different combinations of distance measurement methods and weight forms; each set of combination parameters corresponds to a set of local analysis indicators POD and global analysis indicators FAR;

[0013] The optimal combination parameters are selected from a plurality of sets of combination parameters according to the local analysis indicators POD and the global analysis indicators FAR of each set;

[0014] The initial KNN model is optimized according to the optimal combination parameters to obtain an expected KNN model.

[0015] Optionally, each set of combination parameters includes a distance measurement method and a weight form; the different distance measurement methods include Euclidean distance, block distance, and cosine distance; the initial KNN model is trained according to the lightning sample data to determine combination parameters under different combinations of distance measurement methods and weight forms, including:

[0016] The initial KNN model is trained according to the lightning sample data to determine first local analysis indicators POD and first global analysis indicators FAR corresponding to different weight forms under the Euclidean distance, second local analysis indicators POD and second global analysis indicators FAR corresponding to different weight forms under the block distance, and third local analysis indicators POD and third global analysis indicators FAR corresponding to different weight forms under the cosine distance;

[0017] The first class combination parameters of the Euclidean distance under different weight forms are determined according to the first local analysis indicators POD and the first global analysis indicators FAR;

[0018] The second class combination parameters of the block distance under different weight forms are determined according to the second local analysis indicators POD and the second global analysis indicators FAR;

[0019] According to the third local analysis indicator POD and the third global analysis indicator FAR, a third type of combination parameter of the cosine distance under different weight forms is determined.

[0020] The different weight forms include equal distance weight, inverse distance weight, and inverse distance square weight.

[0021] Optionally, the filtering of the optimal combination parameter from the multiple groups of combination parameters according to the local analysis indicators POD and the global analysis indicators FAR of each group comprises:

[0022] According to the local analysis indicators POD and the global analysis indicators FAR of each group, an optimal combination parameter when the local analysis indicators POD and the global analysis indicators FAR are optimal is filtered from the first type of combination parameter, the second type of combination parameter, and the third type of combination parameter; the optimal combination parameter comprises a target distance measurement method and a target weight form.

[0023] Optionally, the optimization of the initial KNN model according to the optimal combination parameter to obtain an expected KNN model comprises:

[0024] According to the optimal combination parameter, the optimization of the initial KNN model is performed to determine optimized local analysis indicators POD and optimized global analysis indicators FAR corresponding to different K values.

[0025] According to the optimized local analysis indicators POD and the optimized global analysis indicators FAR of each group, a plurality of target K values are determined from the different K values, and a target K value interval is determined based on the plurality of target K values.

[0026] An optimal K value is filtered from the target K value interval, and an expected KNN model under the optimal K value is determined.

[0027] Optionally, the filtering of the optimal K value from the target K value interval comprises:

[0028] According to the optimized local analysis indicators POD corresponding to each target K value, a POD indicator curve is generated, and according to the optimized global analysis indicators FAR corresponding to each target K value, a FAR curve is generated.

[0029] The POD indicator curve and the FAR curve are weightedly fused based on a weight coefficient to obtain a comprehensive indicator curve.

[0030] A K value corresponding to a maximum comprehensive indicator in the comprehensive indicator curve is determined as the optimal K value.

[0031] Optionally, the thunder sample data includes positive sample points of thunder activities and negative sample points of no thunder activities; the false classification of false reporting of lightning strokes is taken as a misclassification cost, the expected KNN model is adjusted and optimized based on the thunder sample data, and a target KNN model is obtained, including:

[0032] The thunder sample data is divided into a training set and a verification set, and a plurality of misclassification costs related to the positive sample points are generated;

[0033] The training set is classified and trained by using the expected KNN model, and the expected KNN model is adjusted according to the misclassification cost generated by each classification training;

[0034] The verification set is used to verify the expected KNN model after each adjustment, and the expected KNN model after adjustment with the highest classification accuracy is determined as the target KNN model.

[0035] The application also provides a thunder activity prediction device, including:

[0036] A data acquisition unit is configured to acquire thunder sample data and an initial KNN model;

[0037] A model training unit is configured to train the initial KNN model in a combined distance measurement mode and a weight form according to the thunder sample data, obtain optimal combined parameters when a partial analysis index POD and a global analysis index FAR are best, and generate an expected KNN model based on the optimal combined parameters;

[0038] An optimization and adjustment unit is configured to take the false classification of false reporting of lightning strokes as a misclassification cost, adjust and optimize the expected KNN model based on the thunder sample data, and obtain a target KNN model;

[0039] A thunder prediction unit is configured to predict thunder activities by using the target KNN model and obtain a prediction result.

[0040] The application also provides an electronic device, which includes a processor and a memory:

[0041] The memory is configured to store program code and transmit the program code to the processor;

[0042] The processor is configured to execute the thunder activity prediction method according to the instructions in the program code.

[0043] The application also provides a computer readable storage medium, which is configured to store program code, and the program code is configured to execute the thunder activity prediction method.

[0044] From the above technical solutions, the present application has the following advantages:

[0045] A lightning activity prediction method is provided. First, lightning sample data and an initial KNN model are obtained, the initial KNN model is trained according to the lightning sample data in terms of distance measurement mode and weight form, the optimal combination parameters at which the local analysis index POD and the global analysis index FAR are optimal are obtained, and an expected KNN model is generated based on the optimal combination parameters. Thus, the initial KNN model is trained by using the lightning sample data, a variety of distance and weight combinations are combined, the optimal combination parameters at which the local analysis index POD and the global analysis index FAR are optimal are screened, and the model parameters most sensitive to lightning data distribution are determined. On this basis, the misclassification cost is integrated to adjust the model decision boundary, which can reduce false positives and improve the prediction accuracy of the model. Then, the false positive lightning misclassification is taken as the misclassification cost, the expected KNN model is optimized and adjusted based on the lightning sample data, a target KNN model is obtained, and the target KNN model is used to predict lightning activity to obtain a prediction result. Thus, the model is adjusted by the misclassification cost to pay more attention to learning lightning events and reduce the sensitivity to noise data. BRIEF DESCRIPTION OF DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0047] Figure 1 A step flow chart of a lightning activity prediction method;

[0048] Figure 2 A schematic diagram of the principle of a K nearest neighbor algorithm;

[0049] Figure 3 A schematic diagram of the local analysis index POD and the global analysis index FAR corresponding to different numbers of neighbor points K;

[0050] Figure 4 A prediction result of different misclassification cost models in a sparse case;

[0051] Figure 5 A prediction result of different misclassification cost models in a low frequency case;

[0052] Figure 6 A prediction result of different misclassification cost models in a medium frequency case;

[0053] Figure 7 A prediction result for different misclassification cost models in a dense case;

[0054] Figure 8 A structural block diagram of a lightning activity prediction device;

[0055] Figure 9 A structural schematic diagram of an electronic device. DETAILED DESCRIPTION

[0056] The embodiment of the application provides a lightning activity prediction method and device, electronic equipment and storage medium, and is used for solving or partially solving the technical problems that the current lightning prediction method has insufficient recognition ability for lightning mode, is prone to model underfitting or overfitting, and thus causes insufficient precision and reliability of a prediction result.

[0057] In order to make the inventive purposes, features and advantages of the application more obvious and easy to understand, the technical solutions in the embodiments of the application will be clearly and completely described below in combination with the drawings in the embodiments of the application. Obviously, the following described embodiments are only some of the embodiments of the application, rather than all the embodiments. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the application.

[0058] In order to make those skilled in the art better understand the technical solutions provided by the embodiments of the application, first, some technical features involved in the solutions will be briefly described:

[0059] KNN (K-Nearest Neighbors, K-Nearest Neighbor Algorithm) model: a supervised learning algorithm based on instances, mainly applied to classification and regression tasks. Its core idea is to measure the distance between data points, find the K nearest neighbors of the new data point, and predict the result of the new data point according to the categories or values of these neighbors.

[0060] Misclassification cost: refers to the cost or loss caused by the incorrect classification of samples by the classifier in the classification task of machine learning. Misclassification cost is defined by a cost matrix (Cost Matrix). Each misclassification has a corresponding cost value. These cost values reflect the actual impact of different misclassifications, helping the classifier make more reasonable decisions when facing class imbalance and other problems. By adjusting the values in the cost matrix, the classifier can be guided to pay more attention to certain types of errors during the training process, thereby optimizing its overall performance.

[0061] As an example, the lightning approaching warning focuses on the prediction of lightning related risk assessment parameters, providing preparation time and estimated disaster loss for lightning protection work. One of the focuses is to predict the occurrence of lightning. Due to the characteristics of lightning phenomenon such as small range, rapid change and strong randomness, the data quantity and spatio-temporal resolution of the previous prediction method based on numerical mode are difficult to meet the industrial warning demand, and the application and research are relatively limited. Therefore, more prediction methods not relying on numerical mode are proposed. For example, through feature extraction and analysis of real-time observation data such as atmospheric electric field data, lightning location data and weather radar data, lightning approaching warning is realized based on the change of feature data strongly related to lightning phenomenon.

[0062] However, the current lightning prediction method has insufficient recognition ability for lightning mode, and is prone to model underfitting or overfitting, thereby causing problems such as insufficient accuracy and reliability of the prediction result.

[0063] Therefore, one of the core invention points of the embodiment of the present application is that a lightning activity prediction method based on misclassification cost optimization is proposed to overcome the deficiencies of the prior art. On the one hand, the initial KNN model is trained by using lightning sample data, a variety of distances and weight combinations are combined, the optimal combination parameters when the local analysis index POD and the global analysis index FAR are optimal are screened, and the model parameters most sensitive to the distribution of lightning data are determined. On this basis, the misclassification cost is integrated to adjust the model decision boundary, reduce false positives, and improve the prediction accuracy of the model. On the other hand, through misclassification cost adjustment, the model pays more attention to learning of lightning events and reduces the sensitivity to noise data. After each misclassification cost adjustment, the validation set is used to evaluate the model performance and serve as the basis for model adjustment for multiple improvements, which can ensure the generalization ability of the model on lightning data, reduce the risk of model overfitting, improve the performance of the prediction model on new data, and enhance the adaptability of the prediction model to different lightning scenarios.

[0064] Reference Figure 1 Fig. 1 shows a step flowchart of a lightning activity prediction method provided by an embodiment of the present application, which can specifically include the following steps:

[0065] Step 101, acquiring lightning sample data and an initial KNN model;

[0066] The lightning sample data can mainly include positive sample points of lightning activity and negative sample points of non-lightning activity.

[0067] Step 102, training the initial KNN model according to the lightning sample data in terms of distance measurement mode and weight form to obtain optimal combination parameters when the local analysis index POD and the global analysis index FAR are optimal, and generating an expected KNN model based on the optimal combination parameters;

[0068] In this step, the initial KNN model is mainly trained using lightning sample data to determine the corresponding local analysis indicators POD (Proper Orthogonal Decomposition) and global analysis indicators FAR (Frequency Amplitude Relationship) under different distance measurement methods and different weight forms, and the optimal combination parameters (target distance measurement method and target weight form) when the local analysis indicators POD and the global analysis indicators FAR are optimal are selected from them to further determine the expected KNN model.

[0069] In some embodiments, the initial KNN model is trained according to the lightning sample data in combination with the distance measurement method and the weight form, the optimal combination parameters when the local analysis indicators POD and the global analysis indicators FAR are optimal are obtained, and the expected KNN model is generated based on the optimal combination parameters. Specifically, first, the initial KNN model is trained according to the lightning sample data to determine the combination parameters under different distance measurement methods and different weight forms; each set of combination parameters corresponds to a set of local analysis indicators POD and global analysis indicators FAR; then, according to each set of local analysis indicators POD and global analysis indicators FAR, the optimal combination parameters are selected from the multiple sets of combination parameters; finally, the initial KNN model is optimized according to the optimal combination parameters to obtain the expected KNN model.

[0070] In the embodiments of the present application, the different distance measurement methods can mainly include Euclidean distance, block distance and cosine distance. The different weight forms can mainly include equal distance weight, inverse distance weight and inverse distance square weight.

[0071] For the determination of the combination parameters and the optimization process of the KNN model, the principle is that: first, the initial KNN model is trained using lightning sample data to determine the local analysis indicators POD and the global analysis indicators FAR corresponding to different weight forms under Euclidean distance, the local analysis indicators POD and the global analysis indicators FAR corresponding to different weight forms under block distance, and the local analysis indicators POD and the global analysis indicators FAR corresponding to different weight forms under cosine distance. Each set of indicators corresponds to a set of combination parameters of distance measurement method and weight form (a total of 9 sets of parameter combination forms); then, based on each set of local analysis indicators POD and global analysis indicators FAR, comparison and analysis are performed to determine the optimal combination parameters when the POD and FAR indicators are optimal from each set of combination parameters; wherein, the optimal combination parameters include the target distance measurement method and the target weight form; finally, the initial KNN model is optimized using the optimal combination parameters to obtain the expected KNN model.

[0072] In a specific implementation, the initial KNN model is trained according to the lightning sample data to determine the combined parameters under different distance measurement methods and different weight forms, which can be:

[0073] The initial KNN model is trained according to the lightning sample data to determine the first local analysis index POD and the first global analysis index FAR corresponding to different weight forms under the Euclidean distance, the second local analysis index POD and the second global analysis index FAR corresponding to different weight forms under the city block distance, and the third local analysis index POD and the third global analysis index FAR corresponding to different weight forms under the cosine distance.

[0074] According to the first local analysis index POD and the first global analysis index FAR, the first type of combined parameters of the Euclidean distance under different weight forms is determined; wherein the first type of combined parameters includes Euclidean distance-equal distance weight, Euclidean distance-inverse distance weight, and Euclidean distance-inverse distance square weight.

[0075] According to the second local analysis index POD and the second global analysis index FAR, the second type of combined parameters of the city block distance under different weight forms is determined; wherein the second type of combined parameters includes city block distance-equal distance weight, city block distance-inverse distance weight, and city block distance-inverse distance square weight.

[0076] According to the third local analysis index POD and the third global analysis index FAR, the third type of combined parameters of the cosine distance under different weight forms is determined; wherein the third type of combined parameters includes cosine distance-equal distance weight, cosine distance-inverse distance weight, and cosine distance-inverse distance square weight.

[0077] Further, according to each group of local analysis indexes POD and global analysis indexes FAR, the optimal combined parameters are selected from the multiple groups of combined parameters, which can be: according to each group of local analysis indexes POD and global analysis indexes FAR, the optimal combined parameters when the local analysis indexes POD and global analysis indexes FAR are optimal are selected from the first type of combined parameters, the second type of combined parameters, and the third type of combined parameters; the optimal combined parameters include the target distance measurement method and the target weight form.

[0078] Preferably, through actual calculation, the target distance measurement method and the target weight form can be one of the following parameter combinations: Euclidean distance and inverse distance square weight, or city block distance and inverse distance square weight, or cosine distance and inverse distance weight.

[0079] In some embodiments, the process of optimizing an initial KNN model using optimal combined parameters to obtain a desired KNN model first involves optimizing the initial KNN model using the optimal combined parameters to determine the local analysis index POD and the global analysis index FAR corresponding to different K values. Then, through index comparison, target K values ​​that meet preset thresholds are selected from all K values ​​to construct a target K value range. Furthermore, the optimal K value is determined from the target K value range to obtain the desired KNN model under the optimal K value. It is understood that the POD and / or FAR corresponding to the target K value range are superior to the POD and FAR corresponding to values ​​outside the target K value range.

[0080] In the specific implementation, the initial KNN model is optimized based on the optimal combination parameters to obtain the desired KNN model. This can be done as follows: First, the initial KNN model is optimized based on the optimal combination parameters to determine the local analysis index POD and the global analysis index FAR corresponding to different K values. Then, based on each set of local analysis index POD and global analysis index FAR, multiple target K values ​​are determined from different K values, and the target K value range is determined based on the multiple target K values. Finally, the optimal K value is selected from the target K value range, and the desired KNN model under the optimal K value is determined.

[0081] In some embodiments, selecting the optimal K value from the target K value range can be achieved by: generating a POD index curve based on the optimized local analysis index POD corresponding to each target K value, and generating a FAR curve based on the optimized global analysis index FAR corresponding to each target K value; performing a weighted fusion of the POD index curve and the FAR curve based on weight coefficients to obtain a comprehensive index curve; and determining the K value corresponding to the maximum comprehensive index in the comprehensive index curve as the optimal K value.

[0082] More specifically, determining the optimal K value from the target K value range includes: for multiple target K values ​​within the target K value range (or, based on actual needs, selecting multiple K values ​​from the target K value range), obtaining the local analysis index POD and the global analysis index FAR corresponding to each K value, and generating initial index curves; wherein, the initial index curves include the POD index curve and the FAR curve; combining the first weight coefficient corresponding to the local analysis index POD and the second weight coefficient corresponding to the global analysis index FAR, performing weighted fusion of the POD index curve and the FAR curve based on the weight coefficients to obtain a comprehensive index curve; and determining the K value corresponding to the maximum comprehensive index in the comprehensive index curve as the optimal K value.

[0083] Preferably, the first weighting coefficient is greater than the second weighting coefficient.

[0084] Step 103: Using the false lightning strike misclassification as the misclassification cost, optimize and adjust the expected KNN model based on the lightning sample data to obtain the target KNN model;

[0085] In this step, the main goal is to use the false lightning strike misclassification as a misclassification cost to optimize and adjust the expected KNN model obtained in the previous steps, thereby obtaining the target KNN model.

[0086] In some embodiments, the misclassification of false lightning strikes is used as the misclassification cost. The expected KNN model is optimized and adjusted based on the lightning sample data to obtain the target KNN model. Specifically, the lightning sample data can be divided into a training set and a validation set, and multiple misclassification costs associated with positive sample points can be generated. The expected KNN model is used to perform classification training on the training set, and the expected KNN model is adjusted according to the misclassification cost generated in each classification training. The validation set is used to validate each adjusted expected KNN model, and the adjusted expected KNN model with the highest classification accuracy is determined as the target KNN model.

[0087] Step 104: Use the target KNN model to predict lightning activity and obtain the prediction results.

[0088] Finally, the target KNN model, obtained through training and optimization, can be used to predict actual lightning activity and obtain the corresponding prediction results.

[0089] This invention proposes a lightning activity prediction method based on misclassification cost optimization. On one hand, an initial KNN model is trained using lightning sample data. By combining various distance and weight combinations, the optimal combination parameters that best reflect the local analysis metric POD and the global analysis metric FAR are selected to determine the model parameters most sensitive to lightning data distribution. Based on this, a misclassification cost is incorporated to adjust the model's decision boundary, reduce false alarms, and improve prediction accuracy. On the other hand, by adjusting the misclassification cost, the model focuses more on learning about lightning events, reducing its sensitivity to noisy data. After each misclassification cost adjustment, a validation set is used to evaluate model performance, and this evaluation serves as the basis for further model refinement. This ensures the model's generalization ability on lightning data, reduces the risk of overfitting, improves the prediction model's performance on new data, and enhances its adaptability to different lightning scenarios.

[0090] To enable those skilled in the art to better understand the technical solutions of the present invention, the foregoing embodiments will be described in detail below with reference to specific examples.

[0091] S110, acquire lightning sample data;

[0092] The lightning sample data includes positive sample points where lightning activity occurred and negative sample points where no lightning activity occurred.

[0093] In practical applications, lightning sample data can be obtained through a Lightning Location System (LLS), an atmospheric electric field meter, or weather radar. For example, multiple detection stations receive the electromagnetic waves generated by lightning discharges, and the lightning location is determined using the time difference method. Furthermore, the lightning sample data can include information such as the time, location, polarity, and peak current of the lightning event.

[0094] S120: The initial KNN model is trained using lightning sample data. The local analysis index POD and the global analysis index FAR are determined under different distance measurement methods and different weight combinations. Based on the optimal combination parameters when the local analysis index POD and the global analysis index FAR are optimal, the expected KNN model is determined.

[0095] The distance metrics include Euclidean distance, street distance, and cosine distance. The weighting methods include equal distance weighting, inverse distance weighting, and inverse distance squared weighting.

[0096] In this embodiment of the invention, the nearest neighbor (KNN) classification model is mainly applied. The nearest neighbor classifier is a classification method that assigns a sample to its nearest neighbor based on the distance between the sample to be classified and known samples. Specifically, this embodiment uses the K-nearest neighbor algorithm. By setting the number of neighboring points K, the range of the number of nearest neighbor samples is determined, thereby achieving the classification of the sample to be classified. Its principle diagram is shown below. Figure 2 As shown.

[0097] Figure 2 In the diagram, green sample points represent the unclassified sample points, while blue and orange sample points represent the already classified sample points. Without distance weighting, when the number of neighbors K=5, there are 3 blue sample points and 2 orange sample points among the 5 nearest neighbors; therefore, the unclassified sample point is classified as blue. When K=15, there are 8 orange sample points and 7 blue sample points among the 15 nearest neighbors; therefore, the unclassified sample point is classified as orange.

[0098] The classification performance of the KNN model is closely related to the distribution of sample points and the selection of the number of neighboring points. Key hyperparameters for model training include the number of neighbors (K), the distance metric, and the distance weights. The number of neighbors (K) determines the evaluation range when the model determines the classification result. A smaller K value results in a smaller evaluation range, making the model more sensitive to local features and producing more refined classification results. However, this can also lead to local outliers and noise contamination, causing a decrease in model accuracy or overfitting. A higher K value makes the model focus more on the overall sample distribution, leading to decreased sensitivity to local outliers and noise, or neglecting some local features, potentially resulting in underfitting.

[0099] In some embodiments, S120 may specifically include:

[0100] S120-1: Train the initial KNN model using lightning sample data to determine the local analysis index POD and global analysis index FAR corresponding to different weight forms under Euclidean distance, the local analysis index POD and global analysis index FAR corresponding to different weight forms under street distance, and the local analysis index POD and global analysis index FAR corresponding to different weight forms under cosine distance.

[0101] S120-2: Based on the calculated local analysis index POD and global analysis index FAR, determine the optimal combination parameters; among which, the optimal combination parameters include the target distance measurement method and the target weight form;

[0102] S120-3: Optimize the initial KNN model using the optimal combination of parameters to obtain the desired KNN model.

[0103] In this embodiment of the invention, FAR is a global analysis index used to describe the relationship between frequency components and their corresponding amplitudes in a signal or data. POD is used to extract key features or patterns from high-dimensional data and characterize local features.

[0104] Euclidean distance reflects the n-dimensional spatial distance between data points, possessing a comprehensive characteristic form. Street distance, on the other hand, emphasizes the distance between each feature variable, highlighting the impact of local features on the result. Cosine distance focuses more on the directional similarity between two feature vectors, measuring the degree of difference in orientation between them. Distance weights measure the weight of nearest neighbor points in determining the category of the target sample point. When distance weights exist, known sample points that are closer to the target sample point have a greater weight in determining its category. Common distance weights include equidistance weights (no weight), inverse distance weights, and inverse squared distance weights.

[0105] In one example, for a point a in n-dimensional space ( , , , ..., ) and b ( , , , ..., The distance calculation formulas are as follows:

[0106] Euclidean distance: ;

[0107] Street distance: ;

[0108] Cosine distance: .

[0109] In some embodiments, the target distance metric and target weight form included in the optimal combination parameters can be one of the following combinations: Euclidean distance and inverse squared distance weight, or block distance and inverse squared distance weight, or cosine distance and inverse distance weight.

[0110] In some embodiments, the initial KNN model is optimized using the optimal combination of parameters to obtain the desired KNN model. Specifically, this can be achieved by: optimizing the initial KNN model using the optimal combination of parameters to determine the local analysis index POD and the global analysis index FAR corresponding to different K values, thereby obtaining a target K value range; wherein the local analysis index POD and / or the global analysis index FAR corresponding to the target K value range are better than the local analysis index POD and the global analysis index FAR corresponding to the range outside the target K value range; and determining the optimal K value from the target K value range to obtain the desired KNN model under the optimal K value.

[0111] In this embodiment of the invention, the initial KNN model is used to further model and optimize the hyperparameter of the number of K neighbor points for each distance metric and weighting method. The training prediction results of the optimized model and the optimization results of the K value are shown in Table 1 below.

[0112] Table 1: Training Results of K-value Optimization Model under Different Combinations of Distance Metrics and Distance Weights

[0113]

[0114] Based on the content of Table 1, the following information can be extracted:

[0115] For any distance metric, the smaller the distance weight of distant sample points, the more sample points are needed to achieve the overall optimal accuracy of the model, i.e., the larger the required K value. In models using Euclidean distance and street distance metrics, models using equal distance weights and inverse distance weights have similar optimal neighbor counts. Furthermore, the inverse distance model shows a significant improvement in POD compared to the equal distance model, while its FAR improvement is not significant. This indicates that under these two distance metrics, inverse distance weights have a clear advantage in modeling compared to equal distance weights. However, for the inverse distance squared weight coefficient, its optimal K value is much higher than other weighting schemes under these two distance metrics. Therefore, the resulting optimal model POD and FAR are difficult to directly use for horizontal comparison of model performance, necessitating the addition of a hyperparameter model training scheme.

[0116] For the cosine distance scheme model, the optimal K values ​​of the three schemes differ significantly, making it difficult to extract effective information. Therefore, it is necessary to supplement the training results of the Euclidean distance and street distance models under the inverse distance weight scheme model with a larger K value (K=5000) and the inverse distance squared weight scheme model with a smaller K value (K=10). Additionally, the training results of the three weight models of the cosine distance metric scheme under smaller K values ​​(K=10), larger K values ​​(K=5000), and larger K values ​​(K=10000) should also be supplemented. The results are shown in Table 2 below.

[0117] Table 2: Evaluation Table of KNN Modeling Supplementary Training Results

[0118]

[0119] Based on Table 2, under the inverse distance weighting scheme, the Euclidean distance and street distance models using a neighbor count of K=5000 show both POD and FAR as 0. This means the model does not predict lightning occurrence. This indicates that an excessively large number of neighbors causes the model to ignore local features, resulting in the neglect of lightning occurrence characteristics. The same applies to the cosine distance scheme model, where POD and FAR are both 0.

[0120] Combining Tables 1 and 2, it can be seen that under small K values, the POD of all models is significantly improved. Comparing the three weighting schemes—equal distance, inverse distance, and inverse-squared distance—the inverse-squared distance weighting scheme achieves a POD exceeding 70% under Euclidean distance and street distance metrics, making it the highest predicted POD. Furthermore, the FAR for both schemes is 30.85%. Compared to other models, these two models have a clear advantage. Meanwhile, the cosine distance KNN model with inverse distance weighting achieves a POD prediction of 69.21% with a small K value and an FAR of 30.98%, classifying it as a suboptimal model.

[0121] In some embodiments, determining the optimal K value from the target K value range to obtain the expected KNN model under the optimal K value may include: selecting multiple K values ​​from the target K value range, obtaining the local analysis index POD and the global analysis index FAR corresponding to each K value, and obtaining an initial index curve; wherein the initial index curve includes the POD index curve and the FAR curve; combining the first weight coefficient corresponding to the local analysis index POD and the second weight coefficient corresponding to the global analysis index FAR, performing weighted fusion on the POD index curve and the FAR curve (i.e., the local analysis index POD and the global analysis index FAR can be numericalized and then weighted fusion can be performed) to obtain a comprehensive index curve; and determining the K value corresponding to the largest comprehensive index in the comprehensive index curve as the optimal K value.

[0122] In some embodiments, the first weighting coefficient is greater than the second weighting coefficient.

[0123] In this embodiment of the invention, based on the three types of hyperparameter models described above, the optimal number of neighboring points K is sought to maximize the model's prediction rate. For example, when K is small, modeling and training are performed at ten points: K = 2, 5, 8, 10, 12, 15, 18, 20, 22, and 25, and the prediction results are calculated. The final result is as follows... Figure 3 As shown, the training results of the cosine distance / equidistant distance model fluctuate significantly with the number of neighboring points. Furthermore, the overall Probability of Detection (POD) is significantly lower than the previous two models. The POD and FAR of the two models using inverse squared distance weights show similar magnitudes and variations. Within the K value range of 8–18, the prediction probability remains consistently above 69%, while the FAR gradually decreases with increasing K value, falling within the range of 30%–31%.

[0124] In summary, using the KNN model for lightning proximity warning based on atmospheric data reanalysis, employing Euclidean distance or street distance as the distance metric, and using the inverse squared distance weighting scheme, with a hyperparameter K ranging from 8 to 18 neighboring points, achieves a relatively optimal model warning effect. Its prediction probability reaches approximately 69%, and the false alarm rate remains around 30%. Because of the focus on local features where lightning exists, the first weight coefficient corresponding to the local analysis indicator POD is greater than the second weight coefficient corresponding to the global analysis indicator FAR. These two weight coefficients can be determined through prior experimentation.

[0125] S130: The false classification of lightning strikes is used as the cost of misclassification. The expected KNN model is optimized and adjusted to obtain the target KNN model. The lightning activity is then predicted using the target KNN model to obtain the corresponding prediction results.

[0126] In some embodiments, the false lightning strike misclassification is used as a misclassification cost to adjust the expected KNN model to obtain the target KNN model. Specifically, this can be done by: dividing the lightning sample data into a training set and a validation set, and generating multiple misclassification costs associated with positive sample points; classifying the training set using the expected KNN model, and adjusting the expected KNN model based on the misclassification cost generated each time; validating the expected KNN model after each misclassification adjustment using the validation set, and determining the adjusted expected KNN model with the highest classification accuracy as the target KNN model.

[0127] Misclassification cost is a parameter set by a machine learning classification model to account for the different losses that misclassification results may cause. Adjusting the misclassification cost parameter can affect the model's training process and lead to bias in the model's classification results. Since the false alarm rate in the actual lightning prediction results was higher than expected, it is necessary to increase the misclassification cost for false lightning strikes to adjust the bias in the model's classification results in order to reduce the false alarm rate.

[0128] In one example, the cost w for false lightning strike misclassification was increased to 3, 5, and 7 respectively, and lightning predictions were performed for four lightning density levels at different time points. The model prediction results are as follows: Figures 4-7 As shown in the figure, lightning density is divided into four levels: sparse (lightning occurs at fewer than 10 locations), low frequency (lightning occurs at 10-30 locations), medium frequency (lightning occurs at 30-60 locations), and dense (lightning occurs at more than 60 locations).

[0129] Figure 4 The prediction results of different misclassification cost models under sparse conditions; Figure 5 The prediction results of different misclassification cost models under low-frequency conditions; Figure 6 These are the prediction results of different misclassification cost models under the mid-frequency case; Figure 7 The results show the predictions of different misclassification cost models under dense conditions. Table 3 below shows the evaluation of the prediction results of different misclassification cost models at local time points.

[0130] Table 3: Evaluation Table of Local Time Prediction Results for Different Misclassification Cost Models

[0131]

[0132] Depend on Figures 4 to 7The model prediction results and the data in Table 3 show that, on the one hand, as the misclassification cost increases, the model's prediction accuracy (FAR) at the same time point decreases, while the overall characteristics of the prediction area remain unchanged, but the prediction results become more refined. This indicates that the model's prediction performance has been significantly improved and the model has been optimized. On the other hand, although the model's prediction of POD at local time points reaches 100%, the overall FAR is still relatively high, indicating that the model's fitting ability is still insufficient. Furthermore, continuously increasing the misclassification cost for false lightning strikes leads to a significant decrease in the model's overall prediction accuracy, which may cause the model to fail in lightning prediction under certain characteristic conditions. Therefore, in practical applications, those skilled in the art need to set the model's misclassification cost according to the specific circumstances.

[0133] By continuously adjusting the misclassification cost, the model can focus more on learning about lightning events and reduce its sensitivity to noisy data. After each adjustment of the error classification cost, the model performance can be evaluated using a validation set, which serves as the basis for multiple model adjustments. This ensures the model's generalization ability on lightning data, reduces the risk of overfitting, improves the model's performance on new data, and enhances the model's adaptability to different lightning scenarios.

[0134] In one alternative embodiment, considering the imbalance between positive and negative sample points in the lightning sample data, a portion of the negative sample points can be randomly or strategically selected for deletion to reduce the number of negative sample points and alleviate the class imbalance problem. However, direct random undersampling may lose important information from the negative sample points, affecting the model's generalization ability. Therefore, undersampling can be combined with SMOTE (Synthetic Minority Oversampling Technique). By analyzing the positive sample points and synthesizing new positive sample points based on their similarity, the number of positive sample points can be increased. This allows the model to learn the features of the positive sample points more comprehensively, improving the model's performance on imbalanced datasets.

[0135] For example, negative sample points in the lightning sample data are undersampled using a random undersampling method, randomly selecting a subset of negative sample points for deletion. More advanced undersampling strategies can also be employed, such as cluster-based undersampling, which first clusters the negative sample points and then selects a certain number of samples from each cluster to preserve the diversity of the majority class. The positive sample points in the undersampled dataset are then processed using SMOTE. The specific steps are as follows:

[0136] Calculate the k nearest neighbors: For each positive sample point, use a distance metric to find its k nearest neighbor positive sample points in the feature space. The distance metric used here can be Euclidean distance, block distance, or cosine distance as described in the previous embodiments. Randomly select a neighbor among each positive sample point and its k nearest neighbors, and then generate new minority class samples according to the following formula:

[0137]

[0138] in, Represents the original positive sample points; This represents its selected nearest neighbor sample; Represents a random number between [0, 1]; This represents newly generated positive sample points.

[0139] Repeat the process of generating new samples until the number of positive sample points reaches the expected balance. Then merge the undersampled negative sample points with the positive sample points processed by SMOTE to form a balanced dataset, thus adjusting the cost of misclassification and obtaining the target KNN model.

[0140] Reference Figure 8 The diagram illustrates a structural block diagram of a lightning activity prediction device provided in an embodiment of the present invention, which may specifically include:

[0141] The data acquisition unit 801 is used to acquire lightning sample data and an initial KNN model;

[0142] The model training unit 802 is used to train the initial KNN model based on the lightning sample data by combining distance metric and weight form, to obtain the optimal combination parameters when the local analysis index POD and the global analysis index FAR are at their best, and to generate the expected KNN model based on the optimal combination parameters.

[0143] The optimization and adjustment unit 803 is used to take the false lightning strike misclassification as the misclassification cost, and optimize and adjust the expected KNN model based on the lightning sample data to obtain the target KNN model;

[0144] The lightning prediction unit 804 is used to predict lightning activity using the target KNN model and obtain prediction results.

[0145] In one alternative embodiment, the model training unit 802 includes:

[0146] The combined parameter determination unit is used to train the initial KNN model based on the lightning sample data and determine the combined parameters under different distance measurement methods and different weight forms; each set of combined parameters corresponds to a set of local analysis index POD and global analysis index FAR;

[0147] The optimal combination parameter filtering unit is used to filter the optimal combination parameters from multiple sets of combined parameters based on the local analysis index POD and the global analysis index FAR of each group.

[0148] The initial KNN model optimization unit is used to optimize the initial KNN model according to the optimal combination parameters to obtain the desired KNN model.

[0149] In one optional embodiment, each set of combined parameters includes a distance metric and a weighting form; the different distance metrics include Euclidean distance, block distance, and cosine distance; the combined parameter determination unit includes:

[0150] The index calculation unit is used to train the initial KNN model based on the lightning sample data, and determine the first local analysis index POD and the first global analysis index FAR corresponding to different weight forms under the Euclidean distance, the second local analysis index POD and the second global analysis index FAR corresponding to different weight forms under the street distance, and the third local analysis index POD and the third global analysis index FAR corresponding to different weight forms under the cosine distance.

[0151] The first type of combined parameter determination unit is used to determine the first type of combined parameters of the Euclidean distance under different weight forms based on the first local analysis index POD and the first global analysis index FAR.

[0152] The second type of combined parameter determination unit is used to determine the second type of combined parameters of the block distance under different weight forms based on the second local analysis index POD and the second global analysis index FAR.

[0153] The third type of combined parameter determination unit is used to determine the third type of combined parameters of the cosine distance under different weight forms based on the third local analysis index POD and the third global analysis index FAR.

[0154] The different weighting forms include equal distance weighting, inverse distance weighting, and inverse distance squared weighting.

[0155] In one optional embodiment, the optimal combination parameter filtering unit is specifically used for:

[0156] Based on the local analysis index POD and the global analysis index FAR described in each group, the optimal combination parameters when the local analysis index POD and the global analysis index FAR are optimal are selected from the first type of combination parameters, the second type of combination parameters, and the third type of combination parameters; the optimal combination parameters include the target distance measurement method and the target weight form.

[0157] In one alternative embodiment, the initial KNN model optimization unit includes:

[0158] The K-value index determination unit is used to optimize the initial KNN model based on the optimal combination parameters and determine the optimized local analysis index POD and the optimized global analysis index FAR corresponding to different K values.

[0159] The target K value interval determination unit is used to determine multiple target K values ​​from the different K values ​​based on the optimized local analysis index POD and the optimized global analysis index FAR of each group, and to determine the target K value interval based on the multiple target K values;

[0160] The optimal K-value filtering unit is used to filter out the optimal K-value from the target K-value range and determine the expected KNN model under the optimal K-value.

[0161] In one alternative embodiment, the optimal K-value filtering unit includes:

[0162] The curve generation unit is used to generate a POD index curve based on the optimized local analysis index POD corresponding to each of the target K values, and to generate a FAR curve based on the optimized global analysis index FAR corresponding to each of the target K values.

[0163] The weighted fusion unit is used to perform weighted fusion of the POD index curve and the FAR curve based on weight coefficients to obtain a comprehensive index curve.

[0164] The optimal K value determination unit is used to determine the K value corresponding to the maximum comprehensive index in the comprehensive index curve as the optimal K value.

[0165] In one optional embodiment, the lightning sample data includes positive sample points where lightning activity occurred and negative sample points where no lightning activity occurred; the optimization adjustment unit 803 includes:

[0166] The misclassification cost generation unit is used to divide the lightning sample data into a training set and a validation set, and generate multiple misclassification costs associated with the positive sample points.

[0167] A classification training unit is used to perform classification training on the training set using the expected KNN model, and to adjust the expected KNN model according to the misclassification cost generated in each classification training.

[0168] The model validation unit is used to validate the expected KNN model after each adjustment using the validation set, and to determine the adjusted expected KNN model with the highest classification accuracy as the target KNN model.

[0169] As the device embodiment is basically similar to the method embodiment, it is described in a relatively simple way. For relevant details, please refer to the description of the method embodiment above.

[0170] It should be noted that, in order to enable those skilled in the art to better distinguish data of the same type but with different actual meanings, some technical features in the embodiments of the present invention are distinguished by the terms "first", "second", and "third". The terms "first", "second", and "third" are used only for data differentiation and have no other special meaning. It is understood that the present invention does not impose any limitations on this.

[0171] This invention also provides an electronic device, which includes a processor and a memory:

[0172] The memory is used to store program code and transfer the program code to the processor;

[0173] The processor is used to execute the lightning activity prediction method of any embodiment of the present invention according to the instructions in the program code.

[0174] In some embodiments, please refer to Figure 9 , Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.

[0175] An electronic device 900 provided in this embodiment of the invention includes a processor 910 and a memory 920. The memory 920 stores a computer program. When executed by the processor, the computer program implements the aforementioned lightning activity prediction method.

[0176] Specifically, processor 910 may include, for example, a general-purpose microprocessor, an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit, ASIC), etc. Processor 910 may also include onboard memory for caching purposes. Processor 910 may be a single processing unit or multiple processing units for performing different actions of the method flow according to embodiments of this application.

[0177] The memory 920 may be any medium capable of containing, storing, transmitting, propagating, or transmitting instructions. For example, the memory 920 may include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, instruments, or propagation media. Specific examples of the memory 920 include: magnetic storage devices such as magnetic tape or hard disk drives (HDDs); optical storage devices such as compact disc read-only memory (CD-ROMs); and may also be random access memory (RAM) or flash memory; and / or wired / wireless communication links.

[0178] This invention also provides a computer-readable storage medium for storing program code for executing the lightning activity prediction method of any embodiment of this invention.

[0179] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0180] In the embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between devices or units through some interfaces, and may be electrical, mechanical, or other forms.

[0181] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0182] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0183] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0184] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for predicting lightning activity, characterized in that, include: Obtain lightning sample data and an initial KNN model; The initial KNN model is trained using a combination of distance metric and weighting based on the lightning sample data to obtain the optimal combination parameters when the local analysis index POD and the global analysis index FAR are at their best. The desired KNN model is then generated based on the optimal combination parameters. Using the false lightning strike misclassification as the cost of misclassification, the expected KNN model is optimized and adjusted based on the lightning sample data to obtain the target KNN model; The target KNN model was used to predict lightning activity, and the prediction results were obtained.

2. The lightning activity prediction method according to claim 1, characterized in that, The step of training the initial KNN model based on the lightning sample data, combining distance metric and weighting methods, to obtain the optimal combination parameters when the local analysis metric POD and the global analysis metric FAR are at their best, and generating the desired KNN model based on the optimal combination parameters, includes: The initial KNN model is trained based on the lightning sample data to determine the combination parameters under different distance measurement methods and different weight forms; each set of combination parameters corresponds to a set of local analysis index POD and global analysis index FAR; Based on the local analysis index POD and the global analysis index FAR described in each group, the optimal combination parameters are selected from the multiple groups of combined parameters; The initial KNN model is optimized based on the optimal combination parameters to obtain the desired KNN model.

3. The lightning activity prediction method according to claim 2, characterized in that, Each set of combined parameters includes a distance metric and a weighting form; the different distance metrics include Euclidean distance, street distance, and cosine distance; the step of training the initial KNN model based on the lightning sample data to determine the combined parameters under different combinations of distance metrics and weighting forms includes: The initial KNN model is trained based on the lightning sample data to determine the first local analysis index POD and the first global analysis index FAR corresponding to different weight forms under the Euclidean distance, the second local analysis index POD and the second global analysis index FAR corresponding to different weight forms under the street distance, and the third local analysis index POD and the third global analysis index FAR corresponding to different weight forms under the cosine distance. Based on the first local analysis index POD and the first global analysis index FAR, the first type of combined parameters of the Euclidean distance under different weight forms are determined; Based on the second local analysis index POD and the second global analysis index FAR, determine the second type of combined parameters of the block distance under different weight forms; Based on the third local analysis index POD and the third global analysis index FAR, determine the third type of combined parameters of the cosine distance under different weighting forms; The different weighting forms include equal distance weighting, inverse distance weighting, and inverse distance squared weighting.

4. The lightning activity prediction method according to claim 3, characterized in that, The step of selecting the optimal combination parameters from multiple sets of combined parameters based on the local analysis index POD and the global analysis index FAR of each group includes: Based on the local analysis index POD and the global analysis index FAR described in each group, the optimal combination parameters when the local analysis index POD and the global analysis index FAR are optimal are selected from the first type of combination parameters, the second type of combination parameters, and the third type of combination parameters; the optimal combination parameters include the target distance measurement method and the target weight form.

5. The lightning activity prediction method according to any one of claims 2 to 4, characterized in that, The step of optimizing the initial KNN model based on the optimal combination parameters to obtain the desired KNN model includes: The initial KNN model is optimized based on the optimal combination parameters to determine the optimized local analysis index POD and the optimized global analysis index FAR corresponding to different K values; Based on the local optimization index POD and the global optimization index FAR described in each group, multiple target K values ​​are determined from the different K values, and the target K value range is determined based on the multiple target K values; The optimal K value is selected from the target K value range, and the expected KNN model under the optimal K value is determined.

6. The lightning activity prediction method according to claim 5, characterized in that, The step of selecting the optimal K value from the target K value range includes: Based on the optimized local analysis index POD corresponding to each of the target K values, a POD index curve is generated, and based on the optimized global analysis index FAR corresponding to each of the target K values, a FAR curve is generated. The POD index curve and the FAR curve are weighted and fused based on weight coefficients to obtain a comprehensive index curve; The K value corresponding to the maximum value of the comprehensive index in the comprehensive index curve is determined as the optimal K value.

7. The lightning activity prediction method according to claim 1, characterized in that, The lightning sample data includes positive sample points where lightning activity occurred and negative sample points where no lightning activity occurred; the step of using false lightning strike misclassification as a misclassification cost, and optimizing and adjusting the expected KNN model based on the lightning sample data to obtain the target KNN model includes: The lightning sample data is divided into a training set and a validation set, and multiple misclassification costs associated with the positive sample points are generated. The expected KNN model is used to perform classification training on the training set, and the expected KNN model is adjusted according to the misclassification cost generated in each classification training. The validation set is used to validate the expected KNN model after each adjustment, and the adjusted expected KNN model with the highest classification accuracy is determined as the target KNN model.

8. A lightning activity prediction device, characterized in that, include: The data acquisition unit is used to acquire lightning sample data and the initial KNN model; The model training unit is used to train the initial KNN model based on the lightning sample data by combining distance metric and weight form, to obtain the optimal combination parameters when the local analysis index POD and the global analysis index FAR are optimal, and to generate the expected KNN model based on the optimal combination parameters. An optimization and adjustment unit is used to take the false lightning strike misclassification as the misclassification cost, and optimize and adjust the expected KNN model based on the lightning sample data to obtain the target KNN model; The lightning prediction unit is used to predict lightning activity using the target KNN model and obtain prediction results.

9. An electronic device, characterized in that, The device includes a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the lightning activity prediction method according to any one of claims 1-7 according to the instructions in the program code.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store program code for executing the lightning activity prediction method according to any one of claims 1-7.