A benthic animal hyperspectral data classification method based on random forest algorithm
By constructing RF, PCA-RF, and RFE-RF models based on the random forest algorithm, and utilizing hyperspectral data for feature selection and dimensionality reduction, the accuracy and efficiency issues of benthic animal classification and identification in underwater environments were solved, enabling rapid and accurate classification of common benthic animals in marine ranches.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INST OF OCEANOLOGY - CHINESE ACAD OF SCI
- Filing Date
- 2022-08-30
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies have low accuracy in classifying and identifying benthic animals in marine ranches in underwater environments. Sample pretreatment is complex and time-consuming, and DNA technology is cumbersome to operate, making it difficult to achieve rapid batch identification.
Random forest algorithm was used to construct RF, PCA-RF and RFE-RF models. Hyperspectral data was used for feature selection and dimensionality reduction. Combined with underwater environment, various common benthic animals in marine ranches were classified and identified.
It enables rapid and accurate classification of common benthic animals in marine ranches, improves identification efficiency and accuracy, simplifies sample preparation procedures, and adapts to complex underwater environments.
Smart Images

Figure CN115294404B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of spectral classification and recognition, specifically a method for classifying benthic animal hyperspectral data based on the random forest algorithm. Background Technology
[0002] In recent years, nearshore ecosystems have been impacted by multiple factors, including global change and human activities, leading to habitat degradation, resource depletion, and reduced biodiversity. Marine ranching is a crucial means of habitat restoration and resource enhancement, and a key driver for the transformation and upgrading of the fisheries industry. Currently, many marine ranching companies are utilizing underwater camera systems to collect and utilize video data. The sheer volume of real-time information makes it difficult to extract biological community data manually. Image analysis techniques and machine learning are therefore particularly important in marine ranching biological resource monitoring and research. Applying artificial intelligence, machine vision, and other sensor technologies in aquaculture allows for real-time monitoring of the ecological environment. Combining these with algorithms such as deep learning and random forests enables machine vision-based identification and classification, facilitating the unified analysis of marine organisms, and allowing for in-depth data mining during the aquaculture process, thus improving work efficiency and decision-making reliability. The technology for acquiring images using traditional red-green-blue (RGB) cameras for underwater target detection is becoming increasingly mature. Traditional image processing methods and deep learning-based target detection algorithms, such as region-based Faster R-CNN and You Only Look Once (YOLO), are widely used in underwater target detection. In ideal underwater imaging environments, detection speed and results are superior to traditional methods, and the accuracy of various algorithms can reach a high level. However, traditional RGB image detection techniques have a series of problems. When the underwater imaging environment is poor and marine animals have protective coloration mechanisms, it is difficult to effectively detect and identify experimental targets from complex backgrounds.
[0003] Hyperspectral imaging technology can provide higher spectral resolution than RGB images, covering a wide range of wavelengths from ultraviolet, visible, and near-infrared to mid-infrared, offering rich spectral information. Hyperspectral data is typically acquired from hundreds of adjacent narrow spectral bands, addressing problems encountered by traditional RGB image detection techniques and providing better target and similar target recognition capabilities. Classic hyperspectral target detection algorithms include the anomaly detector RXD algorithm developed by Reed and Xiaoli, the kernel RXD (KRXD) algorithm, the orthogonal subspace projection (OSP) algorithm, and the constrained energy minimization (CEM) algorithm. Currently, there is limited research in the literature on hyperspectral underwater target detection and classification.
[0004] Random Forest (RF) algorithms have been successfully applied to a range of high-dimensional data classification studies, including hyperspectral data analysis. RF is a bagging (i.e., bootstrap aggregation) ensemble process in which classification trees are grown from random samples obtained from the training data. RF uses bagging and random variable selection to construct decision trees in the ensemble. As an ensemble classifier, the RF algorithm has several advantages: (1) it incorporates the interactions between features; (2) it is computationally more efficient than bagging or bootstrap; (3) it is less prone to overfitting; and (4) it provides variable strength estimates and internal error estimates. Summary of the Invention
[0005] In view of the above, the purpose of this invention is to provide a classification method for common benthic animals in marine ranches based on the random forest algorithm using hyperspectral data. This method solves the problems of low accuracy in sensory analysis, complex and time-consuming sample pretreatment, large solvent consumption, limited application scope of classification techniques, and cumbersome operation of DNA technology, making it difficult to adapt to rapid batch identification and detection. This invention utilizes underwater hyperspectral data and three RF algorithms to build a model for classifying and identifying various common benthic animals in marine ranches in an underwater environment. It evaluates the effectiveness of RF, PCA-RF, and RFE-RF algorithms in underwater hyperspectral data classification analysis and selects the band subset that may produce the best classification accuracy. The classification performance of the PCA-RF and RFE-RF algorithms is compared, and the band combinations selected by different feature selection algorithms are tested to improve the final classification accuracy.
[0006] The technical solution adopted by the present invention to achieve the above objectives is as follows:
[0007] A method for classifying benthic animal hyperspectral data based on the random forest algorithm includes the following steps:
[0008] We obtained target samples of common benthic animals from different types of marine ranches, collected their hyperspectral data, and preprocessed them.
[0009] RF model, PCA-RF model and RFE-RF model were constructed respectively, and the three models were trained using preprocessed hyperspectral data;
[0010] Three pre-trained models were used to classify benthic animal hyperspectral data.
[0011] Building an RF model includes the following steps:
[0012] 1.1) The preprocessed hyperspectral data is divided into training set and test set. Samples are drawn from the training set using random sampling with replacement as training data for decision trees. The samples are then input into the RF model to generate a random forest model composed of multiple decision trees.
[0013] 1.2) Adjust the depth and number of decision trees. Repeat step 1.1). Take the average of the OOB error estimates of all decision trees in the random forest generated after each adjustment as the generalization error estimate of the random forest. By adjusting the model parameters of the random forest model, when the generalization error estimate of the random forest fluctuates within a fixed range, select the decision tree depth and number of decision trees corresponding to the highest accuracy of the model output as the optimal decision tree depth and optimal number of decision trees to obtain the initial random forest model.
[0014] 1.3) Use the test set to verify the recognition accuracy of the initial random forest model.
[0015] Training a Radio Frequency (RF) model includes the following steps:
[0016] 2.1) Based on the importance of the variables output by the initial random forest model, sort the spectral features in the hyperspectral data from largest to smallest, and let i = l;
[0017] 2.2) Take the first i spectral features in the sorting as the spectral data in the training set of the initial random forest model, repeat steps 1.1)-1.3), retrain the RF model, determine the optimal decision tree depth and the optimal number of decision trees, establish the RF model corresponding to the first i spectral features, and test the recognition accuracy of the RF model corresponding to the first i spectral features, i = i + l;
[0018] 2.3) Determine if i ≤ n, where n is the total number of spectral features in the hyperspectral data. If yes, return to step 2.2). Otherwise, select the RF model with the highest average recognition accuracy among all spectral feature models established in step 2.2) as the final random forest model.
[0019] Building and training a PCA-RF model includes the following steps:
[0020] 3.1) Calculate the correlation coefficient matrix, eigenvalues, and eigenvectors in the hyperspectral data, sort the eigenvalues, retain the top k largest eigenvectors, transform the hyperspectral data into a new space constructed by the k eigenvectors to complete dimensionality reduction, and obtain the dimensionality-reduced hyperspectral data as the input data of the model;
[0021] 3.2) Perform steps 1.1) to 2.3) to obtain the PCA-RF model.
[0022] The steps to build and train an RFE-RF model are as follows:
[0023] 4.1) The entire band of the hyperspectral data is screened using the RFE method to obtain the optimal band subset. The entire band is then dimensionality reduced, and the optimal band subset and its corresponding spectral features are used as the input data for the model.
[0024] 4.2) Execute steps 1.1)-2.3) to obtain the RFE-RF model.
[0025] A classification system for benthic animal hyperspectral data based on the random forest algorithm, comprising:
[0026] The data acquisition and preprocessing module is used to acquire target samples of common benthic animals in different types of marine ranches, collect their hyperspectral data, and perform preprocessing.
[0027] The model building and training module is used to build RF models, PCA-RF models and RFE-RF models respectively, and train the three models using preprocessed hyperspectral data;
[0028] The data output module is used to classify benthic animal hyperspectral data using three pre-trained models.
[0029] A benthic animal hyperspectral data classification system based on a random forest algorithm includes a memory and a processor; the memory is used to store a computer program; the processor is used to implement the benthic animal hyperspectral data classification method based on a random forest algorithm when the computer program is executed.
[0030] A computer-readable storage medium storing a computer program that, when executed by a processor, implements a method for classifying benthic animal hyperspectral data based on a random forest algorithm.
[0031] The present invention has the following beneficial effects and advantages:
[0032] 1. The sample preparation process for benthic animals is simple, and common economic animals in marine ranches can be used. No sample pretreatment is required, and the hyperspectral reflectance signal intensity is good.
[0033] 2. It has good scalability. By increasing the types of benthic animal samples used to construct random forest models with three different feature selection methods, it is possible to quickly identify various underwater organisms.
[0034] 3. Compared with other classification methods, such as principal component analysis (PCA) and support vector machine (SVM), the random forest model can effectively extract weak signals with high variable importance and significant contribution to classification from the characteristic spectra of reflectance spectra, thereby improving classification performance.
[0035] 4. Based on existing models, rapid identification and classification of underwater benthic animal samples can be completed in just a few minutes, and the model's prediction accuracy is high, with accurate and reliable detection results. Attached Figure Description
[0036] Figure 1 These are normalized hyperspectral reflectance images of five underwater benthic animal samples from the examples;
[0037] Figure 2 This is a graph showing the relationship between 360 spectral feature wavelengths extracted from the variable importance list (from high to low) and the variable importance in the example.
[0038] Figure 3 This is a graph showing the relationship between the OOB error estimation and the number of decision trees for the five benthic animal samples in the example;
[0039] Figure 4 This is a diagram showing the confusion matrix identification results of benthic animal samples in the examples;
[0040] Figure 5 This is a PCA scatter plot showing the distribution of five benthic animals;
[0041] Figure 6 This is a graph showing the trend of classification accuracy as the number of features changes, generated by filtering band subsets from the reflectance spectra of five benthic animals using the RFE method. Detailed Implementation
[0042] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments.
[0043] A classification method for hyperspectral data of common benthic animals in marine ranches based on the random forest algorithm, specifically including the following steps:
[0044] (1) Sample selection: Select different types of benthic animal target samples as experimental subjects;
[0045] (2) Obtaining hyperspectral data: Optimize experimental parameters and collect hyperspectral data of benthic animal samples;
[0046] (3) Establish RF, PCA-RF, and RFE-RF models: Use a portion of the hyperspectral data of the benthic animal samples in step (2) as the training set to establish a random forest model, and use the remaining portion as the prediction set to test the classification effect of the model;
[0047] (4) Prepare benthic animal samples and collect their hyperspectral data using the methods in steps (1) and (2). Input the spectral data of the sample to be tested into the three different random forest models established in step (3) for identification and obtain classification results.
[0048] Step (3) improves the accuracy of the random forest model by optimizing the depth of the decision trees, the number of trees, the number of spectral feature variables, the number of principal components, and the band subset selected by RFE. Step (3) specifically includes the following steps:
[0049] (301) Randomly select 70% of all hyperspectral data as the training set and fix it. Use random sampling with replacement to extract samples from the training set and input them as training data for decision trees into the RF model of the sklearn module in Python. Finally, the generated multiple decision trees are combined into a random forest model. The spectral data of each sample includes n spectral features, and each spectral feature is the spectral intensity corresponding to the spectral wavelength.
[0050] (302) Adjust the depth and number of decision trees, repeat step (301), and take the average of the OOB error estimates of all decision trees in the random forest generated after each adjustment. This gives the generalization error estimate of the random forest. The generalization error estimate, i.e., the OOB error estimate of the random forest, will gradually decrease as the number of decision trees increases, eventually fluctuating within a certain range (e.g., ...). Figure 3 This allows you to select and output the important parameter "n_estimators" (the number of decision trees) after the curve has stabilized. Inputting this parameter into a Random Forest (RF) program yields better classification results. By combining this with a grid search function to adjust the parameters, the optimal values for decision tree depth and number are determined. The Random Forest model corresponding to these optimal values becomes the initial Random Forest model.
[0051] (303) Use the remaining 30% of the spectral data as a test set to test the accuracy of the initial random forest model;
[0052] (304) Sort the spectral features from largest to smallest according to the importance of the variables output by the initial random forest model, and let i = l;
[0053] (305) Take the first i spectral features in the sorting as the spectral data in the training set sample of step (301), retrain the RF model according to steps (301)-(303), determine the optimal decision tree depth and number of decision trees, establish an RF model corresponding to the number of the first i spectral features, test the accuracy of the RF model corresponding to the number of the first i spectral features, and obtain the average recognition accuracy for different kinds of benthic animal samples, i = i + l;
[0054] (306) Determine if i ≤ n. If so, repeat step (305). Otherwise, compare the average recognition accuracy of the RF models corresponding to all spectral features established in step (305). The RF model with the highest accuracy is the desired random forest model.
[0055] (307) Train the principal components with high contribution in the random forest (PCA-RF) based on principal component analysis to obtain the principal components with the best contribution, input them into the RF model, and obtain the accuracy of PCA-RF.
[0056] (308) In the Random Forest (RFE-RF) based on the recursive feature elimination method, the entire band is screened through RFE to obtain the best band subset. The entire band is then dimensionality reduced, and the best band subset and the number of features are input into the model to obtain the best classification accuracy of RFE-RF. The RFE (Recursive Feature Elimination) algorithm model has the function of evaluating and outputting the number of the best band subset. By running it, the accuracy curve as the number of band subsets (that is, the number of feature bands screened by RFE-RF) increases can be obtained, and the highest accuracy corresponding to the number of the best band subset can be obtained. This can be used to determine the number of the best band subset and which feature bands it is.
[0057] Furthermore, step (1) can prepare benthic animal samples by placing each selected benthic animal sample in an artificial underwater experimental environment to ensure that the sample is in a completely underwater environment, simulating the scene of it being in the sea, and then using a hyperspectral imaging experimental device to acquire data.
[0058] Example:
[0059] This embodiment relates to a hyperspectral data classification method for common benthic animals in marine ranches based on the random forest algorithm, specifically including the following steps:
[0060] 1. Sample preparation
[0061] The five common benthic animals used in this embodiment (Scallop, Scallop, Rhinoceros natans, Abalone, and Sea cucumber) were all caught at sea during scientific research missions.
[0062] 2. Experiments and Data Processing
[0063] 2.1 Optimize experimental parameters and collect hyperspectral reflectance spectral data of benthic animal samples. For example... Figure 1 As shown, all five samples have clear spectral signals. The sea cucumber has weak light reflection due to its color, resulting in a lower normalized spectral signal intensity, but this does not affect RF identification and classification.
[0064] Optimized experimental parameters include image acquisition position angle, power, and resolution. The light source imaging range is 0.2-5m; scanning method: motorized push-broom type (static high-resolution scanning), compatible with cruise scanning (dynamic fast scanning); illumination method: self-contained illumination source; electrical parameters: hyperspectral analyzer main unit: power ~20W; 2 halogen lamps: 80-260VAC, power ~150W / each; performance indicators: spectral range: 400-1000nm; spectral multi-channel: 1440, 720, 360, 176; pixel count: 1920×1456 (spatial dimension × spectral dimension); spectral resolution: 2.8nm; scanning range: lateral opening angle approximately 30°; data fusion function: with built-in attitude sensor, reserved GPS and USBL data interfaces; size and weight: 2000m class (including mounting bracket): 800×400×280mm; ~10 / 5kg (air / water). 250 spectra were extracted from each benthic animal sample.
[0065] 2.2 Establishing the RF model
[0066] (1) Randomly select 70% of all spectral data of benthic animal samples as training set and fix it. Use random sampling with replacement to extract samples from the training set and input them as training data of decision tree into the RF model of the sklearn module in Python. Finally, the generated multiple decision trees are combined into a random forest model. The spectral data of each sample includes n spectral features. Each spectral feature is the spectral intensity corresponding to the spectral wavelength. In this embodiment, the number of spectral features of the reflectance spectrum data of each sample is 360, that is, n = 360.
[0067] (2) Adjust the depth and number of decision trees, repeat step (1), and take the random forest generated after each adjustment.
[0068] The average of all decision tree O0B error estimates yields the generalization error estimate of the random forest. The optimal values are determined by adjusting the parameters using grid search: 400 decision trees and 8 decision tree depths. The random forest model corresponding to the optimal values is the initial random forest model.
[0069] (3) Using 30% of the reflectance spectrum data as a test set to test the classification accuracy of the random forest model, the identification accuracy of 5 underwater benthic animal samples was obtained. The RF classification result was 90.13%, the OOB error was 0.0046 when n_estimators was 400, the kappa coefficient was 0.8767, and the model stability was excellent.
[0070] 2.3 Optimize the RF model
[0071] (1) The reflectance spectral feature variables are screened, and the reflectance spectral features are sorted from largest to smallest according to the importance of the variables output by the random forest model. Figure 2 ).from Figure 2 It can be concluded that the wavelengths corresponding to the important features among the 360 bands have high variable importance. At the same time, outputting these bands through the RF program can improve the accuracy of the model.
[0072] (2) Let i = l.
[0073] (3) Take the first i reflectance spectral features in the importance ranking of variables as the data in the training set sample of step (1) in 2.2, retrain the RF model according to steps (1)-(3) in 2.2, determine the optimal decision tree depth and number of decision trees, establish the RF model corresponding to the number of the first i spectral features, test the accuracy of the RF model corresponding to the number of the first i spectral features, and obtain the average recognition accuracy of the 5 benthic animal samples, i = i + l.
[0074] (4) Determine if i ≥ n. If not, repeat step (3) in 2.3. Otherwise, compare the average recognition accuracy of the RF model corresponding to all reflectance spectral features established in step (3) of 2.3. As the number of extracted spectral feature variables increases, the recognition accuracy of the sample also increases. After a certain number of features are extracted, the accuracy will not continue to improve. Therefore, the number of features that have just reached the highest accuracy, the number of trees, and the depth can be selected as parameters to input into the RF model to improve the classification accuracy of the RF model. This achieves the goal of classifying and identifying common benthic animals in marine ranches using hyperspectral imaging technology combined with the RF model.
[0075] Figure 1 Normalized reflectance spectra of five benthic animal samples, obtained by... Figure 3 The OOB error estimation plot can deduce the optimal n_estimators, i.e., the number of decision trees. By optimizing the RF parameters, the classification accuracy of the RF can be obtained, and simultaneously... Figure 4 The benthic animal sample classification and identification confusion matrix allows for a direct view of the identification accuracy for each sample.
[0076] 2.4 Random Forest Based on Principal Component Analysis (PCA-RF)
[0077] First, all reflectance spectral data of five benthic animal samples are read in, and the correlation coefficient matrix, eigenvalues, and eigenvectors are calculated. Then, the eigenvalues are sorted, and the k largest eigenvectors are retained (the cumulative contribution rate of the top k eigenvectors reaches more than 99%). The spectral data are then transformed into a new space constructed by the k eigenvectors to complete dimensionality reduction. Figure 5The PCA scatter plots of five benthic animal samples are shown. Dimensionality reduction and classification of the reflectance spectra were performed using PCA to extract the optimal number of principal components. The optimal number of principal components corresponding to the best contribution was then input into the PCA-RF model to obtain the classification accuracy of the random forest (PCA-RF) based on principal component analysis. The PCA-RF classification accuracy was 95.20%, the explained variance was 0.9992, and the kappa coefficient was 0.8433, demonstrating excellent model stability.
[0078] 2.5 Random Forest Based on Recursive Feature Elimination (RFE-RF)
[0079] Figure 6 The image used for Recursive Feature Elimination (RFE) filtering shows the change in classification accuracy as the number of reflectance spectral features varies. Benthic animal classification was performed using the RF algorithm and all bands, with optimized n_estimators and max_depth values also applied to RFE. The best overall classification results were obtained by classifying five samples using the RFE algorithm. A total of 83 bands were selected for RFE. Overall, RFE significantly reduced data dimensionality. Compared to using RF and all bands, RFE-RF provided better classification results (classification accuracy of 98.74%, kappa coefficient of 0.8766).
[0080] Table 1 shows the final classification results of the three random forest algorithms.
[0081]
[0082] Output the classification results of the data as a confusion matrix. Figure 4 The image shows the identification results of five samples. The third sample (Rhododendron simsii) had the lowest identification accuracy at 64%; the first and fourth samples (Scallop argus) had the highest accuracy at 100%; the second and fifth samples (Scallop esculenta) had accuracy of 91% and 96% respectively, indicating high overall classification accuracy. Because the reflectance spectral characteristics of Scallop argus and Scallop esculenta differ significantly from the other four samples, these two samples were easier to identify, resulting in the highest classification accuracy. The reflectance spectral curves and characteristics of Rhododendron simsii extracted in the experiment were similar to those of other samples in certain spectral bands; 20 out of the 75 Rhododendron simsii samples in the test set were misidentified, resulting in the lowest identification accuracy. The identification results show that Rhododendron simsii was identified as Abalone rubra var. rubra var. rubra 36% of the time.
Claims
1. A method for classifying benthic animal hyperspectral data based on a random forest algorithm, characterized in that, Includes the following steps: We obtained target samples of common benthic animals from different types of marine ranches, collected their hyperspectral data, and preprocessed them. RF model, PCA-RF model and RFE-RF model were constructed respectively, and the three models were trained using preprocessed hyperspectral data; Three pre-trained models were used to classify benthic animal hyperspectral data. Building an RF model includes the following steps: 1.1) The preprocessed hyperspectral data is divided into training set and test set. Samples are drawn from the training set using random sampling with replacement as training data for decision trees. The samples are then input into the RF model to generate a random forest model composed of multiple decision trees. 1.2) Adjust the depth and number of decision trees. Repeat step 1.1). Take the average of the OOB error estimates of all decision trees in the random forest generated after each adjustment as the generalization error estimate of the random forest. By adjusting the model parameters of the random forest model, when the generalization error estimate of the random forest fluctuates within a fixed range, select the decision tree depth and number of decision trees corresponding to the highest accuracy of the model output as the optimal decision tree depth and optimal number of decision trees to obtain the initial random forest model. 1.3) Use the test set to verify the recognition accuracy of the initial random forest model; Training a Radio Frequency (RF) model includes the following steps: 2.1) Based on the importance of the variables output by the initial random forest model, sort the spectral features in the hyperspectral data from largest to smallest, and let i = l; 2.2) Take the first i spectral features in the sorting as the spectral data in the training set of the initial random forest model, repeat steps 1.1)-1.3), retrain the RF model, determine the optimal decision tree depth and the optimal number of decision trees, establish the RF model corresponding to the first i spectral features, and test the recognition accuracy of the RF model corresponding to the first i spectral features, i = i+l; 2.3) Determine if i ≤ n, where n is the total number of spectral features in the hyperspectral data. If yes, return to step 2.2). Otherwise, select the RF model with the highest average recognition accuracy among all spectral feature models established in step 2.2) as the final random forest model. Building and training a PCA-RF model includes the following steps: 3.1) Calculate the correlation coefficient matrix, eigenvalues, and eigenvectors in the hyperspectral data, sort the eigenvalues, retain the top k largest eigenvectors, and transform the hyperspectral data into a new space constructed by the k eigenvectors to complete dimensionality reduction, thus obtaining the dimensionality-reduced hyperspectral data, which serves as the input data for the model. 3.2) Execute steps 1.1) to 2.3) to obtain the PCA-RF model; Building and training an RFE-RF model includes the following steps: 4.1) The entire band of hyperspectral data is screened using the RFE method to obtain the optimal band subset. The entire band is then dimensionality reduced, and the optimal band subset and its corresponding spectral features are used as the input data for the model. 4.2) Execute steps 1.1) to 2.3) to obtain the RFE-RF model.
2. A classification system for benthic animal hyperspectral data based on a random forest algorithm, characterized in that it comprises: The data acquisition and preprocessing module is used to acquire target samples of common benthic animals in different types of marine ranches, collect their hyperspectral data, and perform preprocessing. The model building and training module is used to build RF models, PCA-RF models and RFE-RF models respectively, and train the three models using preprocessed hyperspectral data; The construction of the RF model is configured to perform: 1.1) The preprocessed hyperspectral data is divided into training set and test set. Samples are drawn from the training set using random sampling with replacement as training data for decision trees. The samples are then input into the RF model to generate a random forest model composed of multiple decision trees. 1.2) Adjust the depth and number of decision trees. Repeat step 1.1). Take the average of the OOB error estimates of all decision trees in the random forest generated after each adjustment as the generalization error estimate of the random forest. By adjusting the model parameters of the random forest model, when the generalization error estimate of the random forest fluctuates within a fixed range, select the decision tree depth and number of decision trees corresponding to the highest accuracy of the model output as the optimal decision tree depth and optimal number of decision trees to obtain the initial random forest model. 1.3) Use the test set to verify the recognition accuracy of the initial random forest model; Training the RF model is configured to perform: 2.1) Based on the importance of the variables output by the initial random forest model, sort the spectral features in the hyperspectral data from largest to smallest, and let i = l; 2.2) Take the first i spectral features in the sorting as the spectral data in the training set of the initial random forest model, repeat steps 1.1)-1.3), retrain the RF model, determine the optimal decision tree depth and the optimal number of decision trees, establish the RF model corresponding to the first i spectral features, and test the recognition accuracy of the RF model corresponding to the first i spectral features, i = i+l; 2.3) Determine if i ≤ n, where n is the total number of spectral features in the hyperspectral data. If yes, return to step 2.2). Otherwise, select the RF model with the highest average recognition accuracy among all spectral feature models established in step 2.2) as the final random forest model. The PCA-RF model is configured to be built and trained as follows: 3.1) Calculate the correlation coefficient matrix, eigenvalues, and eigenvectors in the hyperspectral data, sort the eigenvalues, retain the top k largest eigenvectors, and transform the hyperspectral data into a new space constructed by the k eigenvectors to complete dimensionality reduction, thus obtaining the dimensionality-reduced hyperspectral data, which serves as the input data for the model. 3.2) Execute steps 1.1) to 2.3) to obtain the PCA-RF model; The construction and training of the RFE-RF model is configured to perform: 4.1) The entire band of hyperspectral data is screened using the RFE method to obtain the optimal band subset. The entire band is then dimensionality reduced, and the optimal band subset and its corresponding spectral features are used as the input data for the model. 4.2) Execute steps 1.1) to 2.3) to obtain the RFE-RF model; The data output module is used to classify benthic animal hyperspectral data using three pre-trained models.
3. A classification system for benthic animal hyperspectral data based on the random forest algorithm, characterized in that, It includes a memory and a processor; the memory is used to store a computer program; the processor is used to implement, when executing the computer program, a method for classifying benthic animal hyperspectral data based on a random forest algorithm as described in claim 1.
4. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the benthic animal hyperspectral data classification method based on the random forest algorithm as described in claim 1.
Citation Information
Patent Citations
Fish product rapid identification method based on laser-induced breakdown spectroscopy technology
CN111735806A