A method for predicting safety accidents of beach tourists based on the large language model GPT-4

By adopting large language model GPT-4 and multiple machine learning models in the predictive prediction of beach tourists, it solves the problem of comprehensive risk assessment of beach tourists in existing technologies, and realizes the efficient prediction and flexibility of beach tourists' safety accidents and flexibility User interaction.

CN118261272BActive Publication Date: 2025-01-28HOHAI UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410521707.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-28
Publication Date
2025-01-28
Estimated Expiration
2044-04-28

AI Technical Summary

Technical Problem

The existing technology is difficult to effectively evaluate and predict the comprehensive risks of beach tourists, and it is impossible to provide flexible and efficient prediction results for different user groups.

Method used

Adopt the predictive prediction method of beach tourists based on the GPT-4 GPT-4, through the relevant inspection method and random forest algorithm analysis factors, combined with supporting vector machine SVM and BP neural network model to predict the beach tourists' security accidents, and output the model output to output the model output To GPT for user interaction.

Benefits of technology

The comprehensive assessment and prediction of the safety accidents of beach tourists can be achieved, and it can provide flexible and efficient prediction results according to the input of different user groups. It has the advantages of considering comprehensive factors and friendly interface interaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118261272B_ABST
    Figure CN118261272B_ABST
Patent Text Reader

Abstract

The present invention relates to a beach visitor safety accident prediction method based on a large language model GPT-4. The beach visitor safety accident database is used to select characteristic factors related to beach visitor safety, and the support vector machine (SVM) and BP (Back-propagation) neural network are trained and the model performance is evaluated by using Bayesian optimization; after creating a personal GPT in GPT-4, the trained model is output as a pkl file and uploaded to the GPT database to generate a GPT for users to directly input relevant factors to predict the beach risk level. The present invention relies on a large language model. Users only need to input characteristic factor information such as effective wave height, temperature, wave direction, wave period, etc. to the personal GPT created by this method, and the beach risk level fed back by the GPT can be obtained and appropriate suggestions can be given. It has the characteristics of flexible input information and good interactivity with users.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method for predicting safety accidents of beach tourists based on a large language model GPT-4, and belongs to the fields of coastal disaster prevention and reduction and machine learning. Background Art

[0002] As a popular tourist and leisure destination, beaches play a key role in the coastal tourism industry. The complex hydrodynamic environment and conditions of Chinese beaches pose potential threats to the safety of tourists. The most common is the invisible killer rip current near the beach, which poses a great threat to the life safety of tourists. In addition, for beaches with steep beach surfaces, it is difficult for waves to break when they propagate from deep water areas to the coastline, resulting in large waves and breaking near the coastline, which may cause harm to tourists. In recent years, reports on beach tourist accidents in my country have been common, indicating that there are still huge hidden dangers in the maintenance of beach safety in my country. A large number of beach tourist safety accidents indicate that the personal safety of tourists on the beach is seriously threatened, and it also affects the healthy development of my country's coastal tourism industry.

[0003] At present, most of the research on beach tourist safety issues is aimed at a single problem or a single element, such as drowning, marine life bites, etc., lacking an evaluation method for comprehensive factors, making it difficult to evaluate and analyze the overall risk. The prior art closest to this application is the invention with publication number CN111680022A, which provides a "Beach Tourist Safety Accident Database Establishment and Prediction Method", which systematically collects and organizes beach tourist safety accident information, presents the characteristics of safety accidents, explores the influencing factors of safety accidents, and proposes a solution for applying the database; although it is the first time to propose the collection of beach tourism safety accident data, the fitting relationship based on the prediction model it constructs is still relatively simple, and it is impossible to comprehensively predict the risks of beach tourists based on the characteristics of various factors, and it is also impossible to provide flexible and efficient prediction results for different user groups.

[0004] Therefore, in view of the above situation, it is necessary to design a new prediction model that can run the model according to the environmental factors input by different user groups to conduct a comprehensive assessment of the risks of beach tourists and provide flexible and efficient prediction results. Summary of the invention

[0005] The present invention provides a method for predicting safety accidents for beach tourists based on the large language model GPT-4. Different models are trained externally for different beaches. It has the advantages of being able to consider comprehensive factors, being friendly with interface interaction, and being more intelligent under the GPT own knowledge base.

[0006] The technical solution adopted by the present invention to solve its technical problem is:

[0007] A method for predicting safety accidents of beach tourists based on a large language model GPT-4 is proposed. The beach tourist safety prediction model is used to predict safety accidents of beach tourists. The construction process specifically includes the following steps:

[0008] Step S1: Select a beach to be predicted, collect relevant information about beach tourist safety accidents from its tourist safety accident database, and collect non-accident information of the beach to be predicted from other channels; combine various factors collected from the tourist safety accident database with non-accident information collected from other channels as a data set;

[0009] Step S2: Based on the probability of beach tourist safety accidents and various factors causing accidents in the tourist safety accident database in step S1, the correlation test method and the random forest algorithm are used to analyze the relationship between various factors causing accidents and beach tourist safety, and the analysis results are screened out as characteristic factors for beach tourist safety prediction model training;

[0010] Among them, the correlation test method can analyze the correlation between various factors and the occurrence of accidents, and the random forest algorithm evaluates the importance of various factors to the occurrence of accidents;

[0011] Step S3: Divide the data set collected in step S1 into a training set and a test set;

[0012] The training set was trained using support vector machine (SVM) and BP neural network. Bayesian optimization was used to search for the optimal hyperparameters during the training process, thereby obtaining beach tourist safety prediction models trained by support vector machine (SVM) and BP neural network respectively.

[0013] Among them, the support vector machine SVM model is suitable for professionals. The data input into the beach visitor safety prediction model needs to be standardized. In the nonlinear classification problem involved in beach visitor safety prediction, the feature data is mapped to a higher-dimensional space so that the risk level of beach visitors can be classified using a linear classifier.

[0014] The BP neural network model is suitable for tourists. The data input into the beach tourist safety prediction model does not need to be preprocessed. A hidden layer of neurons and a neural network with 4 neurons are selected. The characteristic data is used as input in the input layer. After being processed by the RELU activation function in the hidden layer neurons, it is transmitted to the output layer for output. In the output layer, the error between the network prediction value and the actual value is calculated and then fed back to the hidden layer neurons. After repeated iterations, the best risk prediction is output;

[0015] Step S4: using the test set data to evaluate the performance of the beach visitor safety prediction model, and calculating the accuracy and related key indicators of the beach visitor safety prediction model based on the data in the confusion matrix, wherein the related key indicators include precision, recall rate and F1 score;

[0016] Step S5: After the beach visitor safety prediction model tested in step S4 is output as a pkl file, it is uploaded to the personal GPT database. After the beach visitor safety prediction model is generated in GPT, professionals or tourists can input relevant characteristic factor information in GPT to predict the risk level of tourists, thus completing the construction of the beach visitor safety prediction model;

[0017] As a further preferred embodiment of the present invention, in step S1, the information related to beach tourist safety accidents collected from the tourist safety accident database of the selected beach to be predicted includes basic information of tourists, including the age, gender, activities being performed by tourists when the accident occurred, the number of beach tourists on that day, and meteorological conditions, hydrodynamic conditions, and topographic conditions when the accident occurred.

[0018] Among them, meteorological conditions include temperature, wind speed, wind direction, sunshine duration and rainfall;

[0019] Hydrodynamic conditions include significant wave height, wave direction, wave period, tidal level, and tidal range;

[0020] Topographic conditions include beach curvature, beach profile slope, and sediment particle size;

[0021] As a further preferred embodiment of the present invention, in step S1, the specific method for obtaining the data set is to obtain data within n days before and after each accident from the official database, randomly select characteristic factor information of several time nodes as information of no accident, merge it with the characteristic factors when the beach tourist accident occurred and the corresponding number of accident information, and convert the accident status into two categories of risk levels, namely safety and danger, according to the number of accidents; select all factors except the time node and the number of accidents as the data set for training the beach tourist safety prediction model;

[0022] As a further preferred embodiment of the present invention, in step S2, the correlation test method analyzes the correlation of several factors to the occurrence of safety accidents for beach tourists, determines the probability of accidental occurrence of the correlation or difference of each factor, and combines the random forest algorithm to obtain the importance of each factor to the safety of beach tourists, obtains the characteristic factors with greater influence on the risk level, and screens out the characteristic factors for training the beach tourist safety prediction model;

[0023] Among them, the selected characteristic factors include temperature, wind speed, wind direction, significant wave height, wave direction, wave period, peak sunshine duration, tide level, tidal range and precipitation;

[0024] As a further preferred embodiment of the present invention, in step S3, when training the support vector machine SVM model, the input data is standardized, and the processing formula is:

[0025]

[0026] In formula (1), X is the original data; X min is the minimum value of the feature in the data set; X max is the maximum value of the feature in the data set; min is the lower limit of the zoom range, the default is 0; max is the upper limit of the zoom range, the default is 1; X scaled is the scaled data;

[0027] After standardization, each feature data is distributed between 0 and 1;

[0028] As a further preferred embodiment of the present invention, after the data input into the support vector machine SVM model is standardized, Bayesian optimization is used to search for hyperparameters, and the kernel function is selected from the radial basis function RBF and the Sigmoid kernel function;

[0029] Among them, the expression of radial basis function RBF is:

[0030] K(x,x′)=exp(-γ‖xx′‖ 2 ) (2)

[0031] In formula (2), x and x' are two sample points; γ is an important parameter of the RBF function, and the search range is set to [0.001, 0.005];

[0032] The expression of the Sigmoid kernel function is:

[0033] K(x,x′)=tanh(αx·x′+c) (3)

[0034] In formula (3), x and x' are two sample points; α is a scaling function, which is generally set to 1; c is a bias term, which uses the default value, and the search range is set to [600, 800];

[0035] As a further preferred embodiment of the present invention, in step S3, Bayesian optimization is used to search for hyperparameters of the BP neural network, and the selection range of the hyperparameters is:

[0036] For hidden layer neurons, select one hidden layer and the number of neurons in the search range is [1,10];

[0037] For the RELU activation function, choose between the rectified linear unit and the hyperbolic tangent function;

[0038] For the optimization algorithm, choose between stochastic gradient descent and adaptive learning rate optimization methods;

[0039] For the regularization term α, the search range is [1e-5, 1e-1];

[0040] As a further preference of the present invention, in step S3, when Bayesian optimization is used for hyperparameter search, a 5-fold cross validation is simultaneously used in the process, i.e., the training set is randomly divided into 5 subsets of equal size, one subset is randomly selected as a sub-validation set, and the remaining 4 subsets are all sub-training sets. After a sub-model is trained from the sub-training set, the performance is evaluated on the sub-validation set. The process is performed 5 times and the average index is calculated as the performance of the model under the hyperparameters.

[0041] As a further preferred embodiment of the present invention, in step S4, the beach visitor safety prediction model is evaluated using a test set, and the performance of the beach visitor safety prediction model is measured by calculating precision, recall rate, F1 score, and accuracy;

[0042] The calculation formula of accuracy is:

[0043]

[0044] In formula (4), True Positive is the number of correctly predicted positive classes, and False Positive is the number of negative classes that are incorrectly predicted as positive classes;

[0045] The calculation formula for recall is:

[0046]

[0047] In formula (5), True Positive is the number of correctly predicted positive classes, and False Negative is the number of positive classes that are incorrectly predicted as negative classes;

[0048] The calculation formula of F1 score is:

[0049]

[0050] In formula (6), Precision is the accuracy and Recall is the recall rate;

[0051] The accuracy calculation formula is:

[0052]

[0053] In formula (7), True Positive is the number of correctly predicted positive classes, True Negative is the number of correctly predicted negative classes, False Positive is the number of incorrectly predicted negative classes, and False Negative is the number of incorrectly predicted positive classes.

[0054] As a further preference of the present invention, the specific steps of step S5 are:

[0055] Step S51, select Create Personal GPT in GPT-4, and perform initial settings for the personal GPT on the settings page. The initial settings require predicting the risk level of the beach based on the environmental parameters provided by the user and giving corresponding suggestions;

[0056] Step S52, output the support vector machine SVM model and BP neural network model after the test in step S4 as pkl files respectively, upload them to the personal GPT database, and request to apply the support vector machine SVM model and BP neural network model to the created personal GPT in the interactive dialog box with the GPT generation assistant GPT Builder.

[0057] Through the above technical solution, compared with the prior art, the present invention has the following beneficial effects:

[0058] 1. The beach tourist safety accident prediction method based on the large language model GPT-4 provided by the present invention adopts the most advanced Vincent multimodal large language model GPT-4, which can be used by developers to create personal GPT to solve practical problems;

[0059] 2. The beach tourist safety accident prediction method based on the large language model GPT-4 provided by the present invention systematically collects and organizes the beach tourist safety accident information, explores the influencing factors of safety accidents, and uses the GPT-4 framework to externally train the beach tourist safety accident prediction model and then output it to the initially created personal GPT, so that the beach risk prediction model has the advantages of being able to consider comprehensive factors, being friendly to the interface interaction, and being more intelligent under the GPT's own knowledge base;

[0060] 3. The beach tourist safety accident prediction method based on the large language model GPT-4 provided by the present invention fully considers the actual user groups, constructs a support vector machine SVM model and a BP neural network model that balances prediction performance and complexity, and matches the models for training and testing to achieve optimal performance, providing users with different prediction results as a reference, and better predicting the safety of beach tourists. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0062] Figure 1 It is a flowchart of the steps of the beach tourist safety accident prediction method based on the large language model GPT-4 provided by the present invention;

[0063] Figure 2 It is a schematic diagram of a beach tourist safety prediction model based on a large language model GPT-4 provided by the present invention;

[0064] Figure 3It is a correlation analysis between various factors and safety accidents of beach tourists in the preferred embodiment provided by the present invention;

[0065] Figure 4 is a graph of importance of each characteristic factor and risk level of beach tourists obtained by using a random forest algorithm in a preferred embodiment provided by the present invention;

[0066] Figure 5 5a shows the ROC diagram of the support vector machine SVM model and the BP neural network model prediction test set provided by the present invention, 5a shows the support vector machine SVM model, and 5b shows the BP neural network model prediction;

[0067] Figure 6 It is a confusion matrix diagram of the support vector machine SVM model and the BP neural network model prediction test set provided by the present invention, 6a embodies the support vector machine SVM model, and 6b embodies the BP neural network model prediction;

[0068] Figure 7 It is the support vector machine SVM model and BP neural network model provided by the present invention, 7a embodies the support vector machine SVM model, 7b embodies the BP neural network model prediction;

[0069] Figure 8 It is the confusion matrix diagram of the prediction of all data sets by the SVM training model and the BP neural network training model in GPT. 8a shows the support vector machine SVM model, and 8b shows the BP neural network model prediction;

[0070] Fig. 9 The model trained with SVM and the model trained with BP neural network in GPT predict the accuracy, recall rate, and F1 score of the entire data set. 9a shows the support vector machine SVM model, and 9b shows the BP neural network model prediction;

[0071] Fig.10 This is an example diagram of beach tourist safety accident prediction based on the large language model GPT-4 provided by the present invention. DETAILED DESCRIPTION

[0072] The present invention will now be described in further detail with reference to the accompanying drawings.

[0073] As described in the background technology, most of the current research on beach tourists' safety issues focuses on a single issue or a single element, and lacks an evaluation method for comprehensive factors, so it is difficult to evaluate and analyze the overall risk. Therefore, this application attempts to overcome the lack of existing evaluation methods for comprehensive factors. The first thing to consider is that a large language model must be determined. Only through a relatively advanced large language model can an evaluation method that takes into account the impact of comprehensive environmental factors on beach tourists' safety be proposed.

[0074] The large language model used in this application is GPT-4, which is the most powerful Vincent multimodal large language model in the world today, and can be used by developers to create personal GPTs to solve practical problems. Using the framework of GPT-4, the beach tourist safety accident prediction model is externally trained and output to the initially created personal GPT, so that the beach risk prediction model has the characteristics of being able to consider comprehensive factors, being friendly to the interface interaction, and being more intelligent under the GPT's own knowledge base.

[0075] This application uses a beach visitor safety prediction model to predict beach visitor safety accidents. Figure 1 Given its entire construction process, matching, in a preferred embodiment, such as Figure 2 Shown is a schematic diagram of the beach visitor safety prediction model established by the present invention, which is trained by using a support vector machine (SVM) and a BP neural network externally using beach visitor safety accident data.

[0076] The construction process specifically includes the following steps:

[0077] Step S1: Select the beach to be predicted, and collect relevant information about beach tourist safety accidents from its tourist safety accident database; the beach to be predicted is selected here because different beaches reflect different beach safety risk characteristics, so in order to ensure the accuracy of the model, different models need to be trained for different beaches; at the same time, non-accident information of the beach to be predicted is collected from other channels.

[0078] The information on beach tourist safety accidents collected from the tourist safety accident database of the selected beach to be predicted includes basic information of tourists, including tourist age, gender, activities being performed by tourists when the accident occurred, number of beach tourists on that day, and meteorological conditions, hydrodynamic conditions, topographic conditions, etc. when the accident occurred. Meteorological conditions include temperature, wind speed, wind direction, sunshine duration, and rainfall; hydrodynamic conditions include effective wave height, wave direction, wave period, tide level, and tidal range; topographic conditions include beach curvature, beach profile slope, and sediment particle size. The information on beach tourist safety accidents is systematically collected and sorted, and more complete information including accident type, cause, time, and location is obtained, which can provide more effective safety management strategies for the subsequent establishment of a database and accurately assess the safety risk level of the beach.

[0079] The various factors collected from the tourist safety accident database are combined with non-accident information collected from other channels as a data set. The method of collecting the database here is to obtain data from the official database within n days before and after each accident, randomly select the characteristic factor information of several time nodes as the information of no accidents, and merge it with the characteristic factors when the beach tourist accident occurred and the corresponding number of accident information, and convert the accident status into two categories of risk levels according to the number of accidents, namely safety and danger; all factors except time nodes and number of accidents are selected as the data set for training the beach tourist safety prediction model.

[0080] In the preferred embodiment, Dadonghai Beach in Sanya, Hainan is selected as an example to illustrate the advantages of the subsequent steps.

[0081] Step S2: Based on the probability of beach tourist safety accidents and various factors causing accidents in the tourist safety accident database in step S1, the correlation test method and random forest algorithm are used to analyze the relationship between various factors causing accidents and beach tourist safety, and the analysis results are used to filter out characteristic factors for beach tourist safety prediction model training.

[0082] The correlation test method analyzes the correlation of multiple factors to the occurrence of accidents for beach tourists and selects characteristic factors to train the model. It judges the correlation of various factors to the risk of beach tourists by calculating the Spearman correlation coefficient, calculating the significance coefficient, drawing a line graph or a scatter plot, etc. The Spearman correlation coefficient is used to evaluate the monotonic correlation between two variables and does not require the variables to follow a normal distribution or a linear relationship. The significance coefficient usually refers to the P value in a statistical test, which is used to judge the significance of the results, that is, the probability that the observed correlation or difference is not accidental.

[0083] The random forest algorithm is used to obtain the importance of each feature element to the safety of beach tourists, so as to obtain the feature factors that have a greater impact on the risk level. The so-called random forest is an integrated learning method that improves the performance and accuracy of the model by combining multiple decision trees. The random forest algorithm can calculate the feature importance of the model by observing the degree to which the splitting of each feature data in multiple decision trees improves the performance.

[0084] The random forest algorithm has a similar function to the correlation test above, and is used to screen out factors used to train the model. The particularity of the random forest algorithm is that it can evaluate the importance of features while building a model. Random forest evaluates the importance of each feature by observing its role in the splitting of the tree. This method not only takes into account the interaction between features, but also handles nonlinear relationships. The Spearman correlation coefficient and significance coefficient usually only evaluate the linear or monotonic relationship between a single feature and the target variable, and may ignore the complex interactions between features. The difficulty is that random forests require enough trees and depth to accurately evaluate the importance of features, and the computational cost is relatively high.

[0085] For Dadonghai Beach in Sanya, Hainan, quantitative analysis is performed on each factor in the database and the probability of safety accidents for beach tourists. The probability of an accident is set as 1, and the probability of no accident is set as 0. This application uses correlation test and random forest algorithm, which can intelligently select and confirm characteristic factors according to the actual situation of Dadonghai Beach in Sanya, Hainan, and provide preliminary guarantee for the accuracy of the subsequent generation model.

[0086] In the example given in this application, Figure 3 The Spearman correlation coefficient of each factor is expressed, and a significance test is performed. It can be seen that the temperature in meteorological conditions, the effective wave height, wave direction, and wave period in hydrodynamic conditions are statistically significantly correlated with the probability of accident. The temperature has the strongest correlation with the probability of accident, and is negatively correlated with the probability of accident. The effective wave height, wave direction, and wave period have weak correlations with the probability of accident, respectively. The effective wave height and wave period are positively correlated with the probability of accident, and the wave direction is negatively correlated with the probability of accident. Therefore, the characteristic factors selected in this application include temperature, effective wave height, wave direction, and wave period. The Spearman correlation coefficients between the remaining influencing factors and the probability of accident did not pass the significance test and are statistically insignificant.

[0087] Figure 4 It indicates the importance of each feature data calculated by the random forest algorithm and the risk of beach tourists. It can be seen that temperature and wave direction have an important impact on the risk of beach tourists. Figure 3 The results of the significance test are similar, so the characteristic factors selected in this application include temperature and wave direction. However, tide level and wind speed are considered to be insignificant in the significance test, but the degree of risk impact on beach tourists cannot be ignored.

[0088] Therefore, through the implementation of step S2, the correlation test method is combined with the random forest algorithm to screen out characteristic factors for training the beach tourist safety prediction model, including temperature, wind speed, wind direction, effective wave height, wave direction, wave period, peak sunshine duration, tide level, tidal range and precipitation.

[0089] Step S3: Divide the data set collected in step S1 into a training set and a test set; for Dadonghai Beach in Sanya, Hainan, obtain data within 2 days before and after each accident from the National Meteorological Science Data Center, China Marine Hydrological Data Management Database, etc., randomly select the characteristic factor information of the three time nodes of 12:00, 15:00, and 18:00 as the information of no accident, and merge it with the characteristic factors when the beach tourist accident occurred and the corresponding number of accident information, and convert the number of accidents into two categories of risk levels: when the number of casualties is 0, it is marked as "safe", and when the number of casualties is greater than 0, it is marked as "dangerous". All features except date and number of accidents are selected for model training. The data set is divided into a training set and a test set, of which 80% of the data is used for training and 20% of the data is used for testing.

[0090] This step, as one of the more prominent invention points of the present application, is to use support vector machine (SVM) and BP (Back-propagation) neural network to train the training set. During the training process, Bayesian optimization is used to search for the optimal hyperparameters, thereby obtaining beach tourist safety prediction models trained by support vector machine SVM and BP neural network respectively.

[0091] The reason for using two models for training is that this application fully considers the classification of user groups. The user groups we target include professional staff (the support vector machine SVM model is suitable for professionals, and the input data can be saved in an Excel table and uploaded to GPT for batch prediction), and tourists playing on the beach (the BP neural network model is suitable for tourists, and a small amount of information is directly input for a small amount of prediction). At the same time, the support vector machine SVM (Support Vector Machines) can work by finding a hyperplane that maximizes the positive and negative sample intervals, which helps to improve the generalization ability of the model; and effectively handle nonlinear problems through kernel techniques, mapping data in low-dimensional space to high-dimensional space, which is very effective for solving small or medium-sized binary classification problems. The BP (Back Propagation) neural network is mainly composed of an input layer, a hidden layer, and an output layer. The number of hidden layers and the number of nodes in each layer can be adjusted to learn complex nonlinear relationships. The two algorithms have good results in predicting the risk level of beach tourists based on the various characteristic factors of accidents involving beach tourists. Therefore, support vector machines and BP neural networks are selected as two different classifiers, and data sets are used for training and verification.

[0092] Next, two models were trained externally using beach tourist safety accident data. The first was the support vector machine (SVM) model. Since SVM often uses kernel functions (such as radial basis function - RBF) to process nonlinearly separable data. These kernel functions calculate the similarity between data points. The scale difference of features will greatly affect the calculation results of the kernel function. In order to ensure that all features contribute to the model in a balanced manner, improve the generalization ability of the model, and accelerate the convergence speed of model training, the feature data (such as temperature, wave period, effective wave height, etc.) are standardized before training the support vector machine (SVM) model so that each feature data is distributed between 0 and 1.

[0093] The standardization formula is:

[0094]

[0095] In formula (1), X is the original data; X min is the minimum value of the feature in the data set; X max is the maximum value of the feature in the data set; min is the lower limit of the zoom range, the default is 0; max is the upper limit of the zoom range, the default is 1; X scaled is the scaled data.

[0096] After standardizing the data input into the support vector machine (SVM) model, Bayesian optimization is used to search for hyperparameters to achieve the best performance of the support vector machine (SVM) model. The kernel function is selected from the radial basis function (RBF) and the sigmoid kernel function;

[0097] Among them, the expression of radial basis function RBF is:

[0098] K(x,x′)=exp(-γ‖xx′‖ 2 ) (2)

[0099] In formula (2), x and x' are two sample points; γ is an important parameter of the RBF function, and the search range is set to [0.001, 0.005], which controls the width of the function. A value that is too small will easily lead to under-fitting of the model, while a value that is too large will lead to over-fitting.

[0100] The expression of the Sigmoid kernel function is:

[0101] K(x,x′)=tanh(αx·x′+c) (3)

[0102] In formula (3), x and x' are two sample points; α is a scaling function, which is generally set to 1; c is a bias term that controls the penalty of the model for misclassification. The default value is used and the search range is set to [600, 800]. A larger c value may lead to overfitting, while a smaller C value may lead to underfitting.

[0103] From the above, we can see that in the support vector machine (SVM) model, when using Bayesian optimization, the parameter combination must be set in advance. For example, the basis function is selected from RBF and sigmoid. Bayesian optimization will select one of the basis functions in each iteration to match the other parameters to train the model and evaluate the effect. The optimal parameter combination will be selected after a certain number of iterations.

[0104] Next, we use Bayesian optimization to search for hyperparameters of the BP neural network. We select a neural network with one hidden layer and four neurons. Its feature data is used as input in the input layer, and is processed by the RELU activation function in the hidden layer and then transmitted to the output layer for output. In the output layer, the error between the network prediction value and the actual value is calculated and then fed back to the hidden layer. After repeated iterations, the optimal risk prediction is output. The selection range of the BP neural network hyperparameters is:

[0105] For the hidden layer neurons, the main function of the hidden layer is to extract features from the input data and pass these features to the output layer. Select a hidden layer and search for the number of neurons in the range [1,10]. Too high a number of neurons may lead to overfitting, while too few may lead to underfitting.

[0106] The RELU activation function determines the output form of each neuron in the neural network, introduces nonlinear factors, and enables the neural network to learn and simulate complex nonlinear relationships. Select from the rectified linear unit (relu) and the hyperbolic tangent function (tanh);

[0107] For the optimization algorithm, choose between stochastic gradient descent (sgd) and adaptive learning rate optimization method (adam);

[0108] For the regularization term α, it is used to specify the strength of the L2 regularization term, which helps prevent the network from overfitting, but a larger value may lead to underfitting. The search range is [1e-5, 1e-1].

[0109] The Bayesian hyperparameter tuning process also uses 5-fold cross validation, that is, the training set is randomly divided into 5 subsets of equal size, one subset is randomly selected as the sub-validation set, and the remaining 4 are all sub-training sets. After the sub-model is trained from the sub-training set, the performance is evaluated on the sub-validation set. This process is repeated 5 times and the average index is calculated as the performance of the model under the hyperparameters. This process can be repeated in the Bayesian optimization process to finally obtain the optimal model hyperparameters. A risk assessment model for beach tourists trained with two different algorithms can be established. The experiment verified that the cross-validation accuracy of the optimal model of the support vector machine SVM and the BP neural network was 69.57% and 73.04% respectively.

[0110] Step S4: Use the test set data to evaluate the performance of the beach visitor safety prediction model, and calculate the accuracy of the beach visitor safety prediction model and related key indicators based on the data in the confusion matrix.

[0111] In testing and evaluating a beach visitor safety prediction model, this application Figure 5 Given the support vector machine SVM ( Figure 5 5a) and BP neural network ( Figure 5 5b) in Figure 1 shows the ROC curve when predicting the test set. This is a graphical method for evaluating the performance of a binary classification model. The True Positive Rate (TPR) and False Positive Rate (FPR) of the model are plotted on a graph to show the model's ability to distinguish between two categories (such as positive and negative). The True Positive Rate represents the ability to correctly predict the positive class, while the False Positive Rate represents the ability to incorrectly identify the positive class. The model performance is measured by calculating the area above the dotted line of the ROC curve. The larger the area, the better the performance. It can be seen that the support vector machine model has a good prediction effect on the test set, which is 0.82, but the BP neural network model has a poor prediction performance on the test set, which is 0.56. Although the BP neural network model is slightly lacking in verification of the test set, the 73.04% accuracy obtained by cross-validation can also guarantee the prediction ability of the BP neural network.

[0112] Figure 6 is the support vector machine SVM model ( Figure 6 6a) and BP neural network model ( Figure 6 6b) in the figure, the confusion matrix diagram provides an intuitive way to view the prediction performance of the model on each category. The color depth in the figure indicates the number of predictions, and the model's ability to distinguish between different categories can be seen. The horizontal axis of the confusion matrix represents the predicted category of the model, and the vertical axis represents the actual category. Ideally, the values ​​on the diagonal of the confusion matrix (indicating the number of correct predictions) will be much larger than the values ​​on the off-diagonal (indicating the number of incorrect predictions). It can be seen that the support vector machine SVM model correctly predicts more samples of "safe" risk, and correctly predicts 11 "safe" level samples, while the BP neural network model correctly predicts more samples of "dangerous" level, correctly predicting 8 "dangerous" level samples, and only 3 samples of "dangerous" level are predicted as "safe".

[0113] In the example, the relevant key indicators selected in this application include precision, recall and F1 score. The selection criteria are to reflect the scenarios in which the model is suitable for application and provide a basis for the selection of different scenarios for model application. Precision focuses on the proportion of correctly predicted positive examples to all predicted positive examples, and is suitable for scenarios where the cost of evaluating false positive examples is high. Recall measures the proportion of correctly predicted positive examples to all actual positive examples, and is more important than situations where the cost of evaluating missed positive examples is high. The F1 score is the harmonic average of precision and recall, which is used to find a balance between the two, and is particularly suitable for scenarios where both are equally important.

[0114] The confusion matrix mentioned above, together with precision, recall, and F1 score, can quantify the pros and cons of the two models in predicting the "safe" and "risk" categories. Precision, recall, and F1 score are calculated based on the data in the confusion matrix, providing a quantitative measure of model performance. The confusion matrix provides the basic data for these calculations and more detailed misclassification. Although precision, recall, and F1 score reflect different aspects of model performance, the confusion matrix can show more comprehensive information, including the number of true positives and false positives for each category. Therefore, when used together with these metrics, the confusion matrix can provide a deeper and more comprehensive understanding of model performance.

[0115] The calculation formula of accuracy is:

[0116]

[0117] In formula (4), True Positive is the number of correctly predicted positive classes, and False Positive is the number of negative classes that are incorrectly predicted as positive classes;

[0118] The calculation formula for recall is:

[0119]

[0120] In formula (5), True Positive is the number of correctly predicted positive classes, and False Negative is the number of positive classes that are incorrectly predicted as negative classes;

[0121] The calculation formula of F1 score is:

[0122]

[0123] In formula (6), Precision is the accuracy and Recall is the recall rate;

[0124] The accuracy calculation formula is:

[0125]

[0126] In formula (7), True Positive is the number of correctly predicted positive classes, True Negative is the number of correctly predicted negative classes, False Positive is the number of incorrectly predicted negative classes, and False Negative is the number of incorrectly predicted positive classes.

[0127] The positive samples mentioned above refer to samples of the category that are of interest in a specific task. For example, when focusing on samples with a risk level of "safe", samples of this category are positive samples, and other samples are negative samples.

[0128] Figure 7 The following table shows the accuracy, recall rate, F1 score of the test set predicted by the support vector machine (SVM) model and the BP neural network model, as well as the macro average and weighted average of the above parameters after averaging and weighted averaging. Figure 7 7a, with Figure 5 and Figure 6 The results are similar to those of the previous two models. The SVM model has a higher accuracy rate for the test set prediction and has a higher performance in predicting "danger", while the BP neural network model is slightly lacking in predicting the "danger" level. According to the recall index, the SVM model can reduce the underreporting of the "safety" indicator, but the underreporting of the "danger" indicator is more. For the BP model, there are fewer underreportings of "danger", so from a practical point of view, the BP model is more conservative in prediction and can predict more risks as "danger", while the SVM model has a better effect on the test set prediction. According to the F1 score, the overall performance of the SVM model in predicting the test set is better than that of the BP neural network, especially in predicting the "safety" level.

[0129] observe Figure 7 7b, macro-average and weighted average are to average or weighted average the precision, recall, and F1 score indicators of the BP neural network model and the support vector machine SVM model respectively. The weight of the weighted average is determined by the actual number of labels of "safe" and "dangerous" in the total number of samples. For example, the macro-average of the accuracy of the support vector machine SVM model is to calculate the arithmetic average of the accuracy of "safe" and "dangerous" of the support vector machine SVM model, and the weighted average is to multiply the accuracy of "safe" and "dangerous" by the weight and add them together. The macro-average and weighted average of the BP neural network model are around 0.7, and the support vector machine SVM model is around 0.8, which further proves the superiority of the support vector machine SVM model in the validation set verification.

[0130] Step S5: Select Create Personal GPT in GPT-4, and make initial settings for the personal GPT on the settings page. The initial settings require predicting the risk level of the beach based on the environmental parameters provided by the user (such as temperature, wave period, effective wave height, etc.), and giving corresponding suggestions; output the support vector machine SVM model and BP neural network model tested in step S4 as pkl files, upload them to the personal GPT database, and request to apply the support vector machine SVM model and BP neural network model to the created personal GPT in the interactive dialog box with the GPT generation assistant GPT Builder.

[0131] The machine learning prediction model uploaded to GPT cannot be too complex. The reason is that the environment in which GPT runs the model is relatively limited. Some machine learning libraries (such as torch, mlxtend and other neural networks and model integration libraries) cannot be used, and the computing power is limited, which makes complex models automatically report errors after running for a certain period of time. Therefore, support vector machines (SVMs) and BP neural networks that balance prediction performance and complexity are selected for prediction, providing users with different prediction results as a reference, so as to better predict the safety of beach tourists.

[0132] For the example of Dadonghai Beach in Sanya, Hainan, Figure 8 The model trained by the support vector machine SVM in GPT ( Figure 8 8a) and the BP neural network training model ( Figure 8 8b) Confusion matrix diagram for predicting beach risk level; after exporting the externally trained model into a pkl file, the pkl is transferred to the database of the initially created personal GPT, and then in the GPT creation assistant GPT Builder, GPT is required to use the SVM model and the BP neural network model for the risk level prediction of beach tourists, and then all the data of all Dadonghai beach tourists are batch imported into GPT to obtain the prediction results. It can be seen that the support vector machine SVM model and the BP neural network model correctly predict the number of "safe" indicators, with 56 and 59 correctly predicted "safe" samples respectively, and the number of correctly predicted samples for the "dangerous" level is not much different between the two models.

[0133] Fig. 9 The accuracy, recall, and F1 score of the models trained with support vector machines (SVM) and BP neural networks in GPT for predicting beach risk levels. Fig. 9 In 9a, the support vector machine (SVM) model has an accuracy of about 75% for the entire data set, and has the same performance in accurately predicting the "safe" and "risk" levels. However, according to the recall, the SVM model is more likely to miss the "dangerous" level. Fig. 9In 9b, the prediction characteristics of the BP neural network model for risk level are similar to those of the support vector machine SVM model, but overall, the prediction of the "safe" level is better than that of the support vector machine SVM model, and the prediction of the "dangerous" level is not much different. The macro average and weighted average indicators reflect that the overall effect of GPT prediction using the two models is similar, around 80%.

[0134] The performance of the support vector machine (SVM) model and the BP neural network model have different characteristics. The support vector machine (SVM) model has strong generalization and can maintain stable prediction performance for untouched data. Although the BP neural network has outstanding prediction effects in some data, it is slightly lacking in prediction stability. However, in actual operation, such as Fig.10 As shown, users can directly input relevant information in the interactive interface. GPT will ask users about the model used for prediction. After users select the relevant model, GPT can use the relevant information to input into the model for verification and return the risk level. Users can also further interact with GPT to meet relevant needs.

[0135] In summary, the beach tourist safety accident prediction method based on the large language model GPT-4 provided by this application is based on a large language model compared to the previous beach warning system. The user only needs to input characteristic factor information such as effective wave height, temperature, wave direction, wave period, etc. into the personal GPT created by this method, and the GPT can feedback the beach risk level and give appropriate suggestions. It has the characteristics of flexible input information and good interactivity with users.

[0136] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in common dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless defined as herein.

[0137] The meaning of "and / or" described in this application means that the situations where each exists alone or both exist at the same time are included.

[0138] The term “connection” as used in this application may mean a direct connection between components or an indirect connection between components via other components.

[0139] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.

Claims

1. A method for predicting safety accidents of beach tourists based on the large language model GPT-4, characterized by: The beach visitor safety prediction model is used to predict beach visitor safety accidents. The construction process includes the following steps: Step S1: Select a beach to be predicted, collect relevant information about beach tourist safety accidents from its tourist safety accident database, and collect non-accident information of the beach to be predicted from other channels; combine various factors collected from the tourist safety accident database with non-accident information collected from other channels as a data set; Step S2: Based on the probability of beach tourist safety accidents and various factors causing accidents in the tourist safety accident database in step S1, the correlation test method and the random forest algorithm are used to analyze the relationship between various factors causing accidents and beach tourist safety, and the analysis results are screened out as characteristic factors for beach tourist safety prediction model training; The correlation test method analyzes the correlation of several factors on the occurrence of beach tourist safety accidents, determines the probability of accidental occurrence of the correlation or difference of each factor, and combines the random forest algorithm to obtain the importance of each factor to the safety of beach tourists, obtains the characteristic factors that have a great impact on the risk level, and screens out the characteristic factors for training the beach tourist safety prediction model; Among them, the selected characteristic factors include temperature, wind speed, wind direction, significant wave height, wave direction, wave period, peak sunshine duration, tide level, tidal range and precipitation; Step S3: Divide the data set collected in step S1 into a training set and a test set; The training set was trained using support vector machine (SVM) and BP neural network. Bayesian optimization was used to search for the optimal hyperparameters during the training process, thereby obtaining beach tourist safety prediction models trained by support vector machine (SVM) and BP neural network respectively. Among them, the support vector machine SVM model is suitable for professionals. The data input into the beach visitor safety prediction model needs to be standardized. In the nonlinear classification problem involved in beach visitor safety prediction, the feature data is mapped to a higher-dimensional space so that the risk level of beach visitors can be classified using a linear classifier. The BP neural network model is suitable for tourists. The data input into the beach tourist safety prediction model does not need to be preprocessed. A hidden layer of neurons and a neural network with 4 neurons are selected. The characteristic data is used as input in the input layer. After being processed by the RELU activation function in the hidden layer neurons, it is transmitted to the output layer for output. In the output layer, the error between the network prediction value and the actual value is calculated and then fed back to the hidden layer neurons. After repeated iterations, the best risk prediction is output; Step S4: using the test set data to evaluate the performance of the beach visitor safety prediction model, and calculating the accuracy and related key indicators of the beach visitor safety prediction model based on the data in the confusion matrix, wherein the related key indicators include precision, recall rate and F1 score; The beach visitor safety prediction model was evaluated using the test set, and the performance of the beach visitor safety prediction model was measured by calculating precision, recall, F1 score, and accuracy. The calculation formula of accuracy is: In formula (4), True Positive is the number of correctly predicted positive classes, and False Positive is the number of negative classes that are incorrectly predicted as positive classes; The calculation formula for recall is: In formula (5), True Positive is the number of correctly predicted positive classes, and False Negative is the number of positive classes that are incorrectly predicted as negative classes; The calculation formula of F1 score is: In formula (6), Precision is the accuracy and Recall is the recall rate; The accuracy calculation formula is: In formula (7), True Positive is the number of correctly predicted positive classes, True Negative is the number of correctly predicted negative classes, False Positive is the number of incorrectly predicted negative classes, and False Negative is the number of incorrectly predicted positive classes. Step S5: After the beach visitor safety prediction model tested in step S4 is output as a pkl file, it is uploaded to the personal GPT database. After the beach visitor safety prediction model is generated in GPT, professionals or tourists can input relevant characteristic factor information in GPT to predict the risk level of tourists, thereby completing the construction of the beach visitor safety prediction model.

2. The method for predicting safety accidents of beach tourists based on the large language model GPT-4 according to claim 1 is characterized in that: In step S1, the information related to beach tourist safety accidents collected from the tourist safety accident database of the selected beach to be predicted includes basic information of tourists, including the age, gender, activities that tourists were doing when the accident occurred, the number of beach tourists on that day, and meteorological conditions, hydrodynamic conditions, and topographic conditions when the accident occurred. Among them, meteorological conditions include temperature, wind speed, wind direction, sunshine duration and rainfall; Hydrodynamic conditions include significant wave height, wave direction, wave period, tidal level, and tidal range; Topographic conditions include beach curvature, beach profile slope, and sediment particle size.

3. The method for predicting safety accidents of beach tourists based on the large language model GPT-4 according to claim 1 is characterized in that: In step S1, the specific method for obtaining the data set is to obtain data within n days before and after the date of each accident from the official database, randomly select characteristic factor information of several time nodes as information on no accidents, merge it with the characteristic factors when the beach tourist accident occurred and the corresponding number of accident information, and convert the accident status into two categories of risk levels based on the number of accidents, namely safe and dangerous; all factors except time nodes and number of accidents are selected as the data set for training the beach tourist safety prediction model.

4. The method for predicting safety accidents of beach tourists based on the large language model GPT-4 according to claim 1 is characterized in that: In step S3, when training the support vector machine (SVM) model, the input data is standardized, and the processing formula is: In formula (1), X is the original data; X min is the minimum value of the feature in the data set; X max is the maximum value of the feature in the data set; min is the lower limit of the zoom range, the default is 0; max is the upper limit of the zoom range, the default is 1; X scaled is the scaled data; After standardization, each feature data is distributed between 0 and 1.

5. The method for predicting safety accidents of beach tourists based on the large language model GPT-4 according to claim 4 is characterized in that: After the data input into the support vector machine (SVM) model is standardized, Bayesian optimization is used to search for hyperparameters, and the kernel function is selected from the radial basis function (RBF) and the sigmoid kernel function. Among them, the expression of radial basis function RBF is: K(x,x′)=exp(-γ||x-x′|| 2 ) (2) In formula (2), x and x′ are two sample points; γ is an important parameter of the RBF function, and the search range is set to [0.001, 0.005]; The expression of the Sigmoid kernel function is: K(x,x′)=tanh(αx·x′+c) (3) In formula (3), x and x′ are two sample points; α is the scaling function, which is set to 1; c is the bias term, which uses the default value, and the search range is set to [600, 800].

6. The method for predicting safety accidents of beach tourists based on the large language model GPT-4 according to claim 1 is characterized in that: In step S3, Bayesian optimization is used to search for hyperparameters of the BP neural network, and the selection range of the hyperparameters is: For hidden layer neurons, select one hidden layer and the number of neurons in the search range is [1,10]; For the RELU activation function, choose between the rectified linear unit and the hyperbolic tangent function; For the optimization algorithm, choose between stochastic gradient descent and adaptive learning rate optimization methods; For the regularization term α, the search range is [1e-5, 1e-1].

7. The method for predicting safety accidents of beach tourists based on the large language model GPT-4 according to claim 1 is characterized in that: In step S3, when Bayesian optimization is used for hyperparameter search, the process also uses 5-fold cross-validation, that is, the training set is randomly divided into 5 subsets of equal size, one subset is randomly selected as the sub-validation set, and the remaining 4 are all sub-training sets. After the sub-model is trained with the sub-training set, the performance is evaluated on the sub-validation set. This process is performed 5 times and the average index is calculated as the performance of the model under the hyperparameters.

8. The method for predicting safety accidents of beach tourists based on the large language model GPT-4 according to claim 1 is characterized in that: The specific steps of step S5 are: Step S51, select Create Personal GPT in GPT-4, and perform initial settings for the personal GPT on the settings page. The initial settings require predicting the risk level of the beach based on the environmental parameters provided by the user and giving corresponding suggestions; Step S52, output the support vector machine SVM model and BP neural network model after the test in step S4 as pkl files respectively, upload them to the personal GPT database, and request to apply the support vector machine SVM model and BP neural network model to the created personal GPT in the interactive dialog box with the GPT generation assistant GPT Builder.

Citation Information

Patent Citations

  • Beach tourist safety accident database establishment and prediction method

    CN111680022A

  • Rail train accident prediction method based on RF-BP-RF model

    CN116542521A

  • Multi-task processing method and device based on hybrid model

    CN116882514A