Estimation of coconut maturity based on fuzzy neural network and sperm whale optimization

Coconut water is the clear liquid found inside coconuts, famous for rehydrating after exercise or while suffering from a minor sickness. The essential issue tackled in this paper is how to estimate the appropriate stage of maturity of coconut water, which is a time-consuming task in the beverage industry since, as the coconut age increases, the coconut water flavor varies. Accordingly, to handle this issue, an adaptive model based on Fuzzy Neural Network and Sperm Whale Optimization, dubbed FNN–SWO, is developed to assess coconut water maturity. The Sperm Whale Optimization (SWO) algorithm is a meta-heuristic optimization algorithm. It is embedded in this model along with neural networks and fuzzy techniques (FNN system), which can be employed as an essential building block in the beverage industry. The proposed FNN–SWO model is trained and tested utilizing fuzzy rules with an adaptive network. In contrast, the SWO algorithm is adopted to determine the optimal weights for the fuzzy rules. Three subsets of data divided according to three levels of coconut water maturity-tender, mature, and very mature, are used to validate the combined FNN–SWO model. Depending on these three subsets of data, a comparison of the proposed FNN–SWO model has been conducted against a set of the most common conventional techniques. These techniques include Support Vector Machine, Naïve Bayes, FNN, Artificial Neural Network, as well as their embedding with other meta-heuristic optimization algorithms. For various key performance indicators, such as recall, F1-score, specificity, and accuracy, the proposed FNN–SWO model provides the best prediction outcomes compared to the current time-consuming techniques. The dominance of the proposed FNN–SWO model is evident from the final findings compared to its time-consuming peers for estimating coconut water maturity on time. As a result, the proposed FNN–SWO model is an effective heuristic for locating optimal solutions to classification problems. It can thereby be reassuringly applicable to other similar prediction problems. Additionally, it would benefit the scientific community interested in evaluating coconut water.

The inverse of the partial derivative is used to convert the difference between the desired and predicted outputs into a change in the manipulated variable, which can be applied to the plant model The best fitness f ðx tþ1 b Þ The best fitness value at completion of the present iteration t?1 k Output space k 4 Scaling factor that determines the spread of the clusters k 3 i The centroid of cluster j The precedents' membership (j) values for each rule (i) k 3 j Rule's firing strength Manipulated variable in order to make the predicted output of the FFN as close as possible to the desired output u fb ðvÞ Fuzzified values of the outputs w i ðv þ 1Þ The updated weight w j The weights of the consequence links.
The best whalés position x tþ1 b The best position at the end of the current iteration t?1 x c Space's central reflection The acquired reflection position x w The worst whale's position y The output value for a given input vector ''x'' y Predicted output value y d Desired output value g Constant learning rate l ij Membership function (j) for each input variable (i) r ij v þ 1 ð Þ The standard deviation of cluster j u i The normalized degree of individual rule firing

Introduction
Coconut is a wonderfully versatile raw material. Coconut can be classified as a fruit (nut or seed), but it is also a type of berry. Coconut is a raw material used in sweet and salty cooking. The natural habitats of coconut include islands, coastal areas, and humid tropical regions with relatively large rainfall. Coconut palms are cultivated in more than ninety countries and zones worldwide, with a total production of more than 59 million tons in 2021 [1][2][3].
Coconut is a very beneficial fruit that is used in a wide range of products. Most production of coconut is in tropical areas of Asia (Indonesia, the Philippines, and India), accounting for more than 72% of the overall production. Mexico is ranked eighth in coconut production of 0.25M Tons in 2023 [4], with a production area of 190,000 ha [5]. Currently, global coconut products account for a share of more than US$20.24 billion in 2022. There is anticipated to be an increase in the compound annual growth rate (CAGR) of 8.4 percent between 2023 and 2030 [6]. Tropical coconuts are not native to Egypt due to the limited rainfall there. There are, however, some giant coconut palms on Kitchener's Island in Aswan, where the British planted exotic and non-native flora [7,8]. Further investigations of coconut cultivation in Egypt are needed. Coconut water is the liquid found in the center of a young, green coconut. It helps nourish the fruit. As the coconut matures, which takes around 10-12 months, some liquid remains while the rest ripens into the solid white flesh known as coconut meat. [9].
The coconut kernel has an edible skin, and coconut water is delicious and used to rehydrate the human body after exercise due to its high content of sugar and minerals. Additionally, the coconut husk has strong fibers. The coconut (Cocos nucifera L.) fruit can be processed for use in a variety of beverages and foods, such as coconut milk, which is derived from the solid endosperm, coconut water, which is from the aqueous part of the coconut endosperm, and the ''meat'' of the coconut which is from trimmed young coconuts [10]. The liquid endosperm (coconut water) in the coconut kernel cavity of coconut fruit is a highly valued beverage used as a natural source of carbohydrates and suitable for rehydration after physical activity [11].
Coconut water is a fragile liquid found in the center of a young, green coconut and rapidly deteriorates [12,13]; consequently, assessing its quality during storage and processing remains a challenge [14]. According to the coconut maturity, the coconut water volume and nutrients vary. Each beverage is produced considering the specific characteristics of coconut water. There are determinant factors for coconut water selection. For example, minerals and sugars are varied and affected by the development stage of coconuts, soil characteristics, and farming practices [15]. The water of very mature coconuts has higher concentrations of magnesium and potassium than the water of very tender coconuts, but the calcium concentration dramatically decreases with age [16]. The coconut water volume also varies with coconut age; for example, the volume increases at ages of 7 to 9 months old and then declines before being converted to jelly [16]. Depending on the maturity stage of the coconut, the uses of coconut water can vary as follows: (1) Young coconut water, known for its high electrolyte content, is a popular drink for athletes and people who are dehydrated. It possesses anti-inflammatory and anti-bacterial properties. According to [17], young coconut water can have a strong anti-inflammatory effect. In contrast, mature coconut water may have a more moderate anti-inflammatory effect. It can be applied topically to alleviate skin irritations, (2) Mature coconut water is less sweet than young coconut water but is still rich in nutrients. According to [18,19], the maturity stage influences sugar levels. As maturity increased, the sucrose content increased, while fructose and glucose levels decreased. It is a popular ingredient in smoothies, juices, and other beverages. It is also known to have antioxidant properties, making it a popular drink for people looking to improve their skin health and (3) Overripe coconut water is found in coconuts that have started to spoil. Although overripe coconut water is unsuitable for drinking, it can be used in cooking. It is often used as a natural flavoring in curries, stews, and other dishes. It can also be used as a natural tenderizer for meat. Separating the coconut water extracted from very mature fruits from that of very young fruits is essential. This process is useful for utilizing all the water extracted from the fruits, whether for nutrition or later sale to pharmaceutical companies. Therefore, it is necessary to grade and classify types of coconut water according to their intended use. Coconut fruit classification is insignificant because the extraction process is needed for all coconut fruits and be punched as one batch.
There are many challenges to sorting coconut water. [20] characterized the volatile compounds/profiles of five different tender varieties of coconut water for further discrimination using the headspace solid-phase microextraction technique. The dissolved oxygen concentration of natural coconut water varies according to the coconut maturity stage; at the 7-month growth stage, the dissolved oxygen content of coconut water increases from 6 to 9 mg l À1 after 3 h of extraction and remains constant for 4 h. After 10 h, the content declines to zero. In contrast, the coconut water of 9-month-old coconuts has a maximum dissolved oxygen concentration of 6 mg l À1 , which in different experiments decreased to zero after 7 h [20] and stayed constant for 4 h before dropping to zero after 10 h.
In the past ten years, artificial intelligence has been increasingly applied to solve multiple problems associated with coconut cultivation. Notable developments in expert systems and machine learning [21] have prompted new discoveries and led to solutions for many problems in coconut cultivation and production [22]. ANN [23] relies on intelligent mathematical models and parameterless features, and these networks are biological nervous systeminspired. In the past thirty years, the ANN has been widely implemented in regression, forecasting, classification, and pattern recognition problems [24,25]. The proficiency of an ANN is deeply affected by the number and effectiveness of the corresponding learning stages [26]. Multilayer perceptron (MLP) neural networks are the most commonly used and implemented ANNs [27]. The appropriate supervised training methods can be classified into two main categories: stochastic processes and gradient-based methods [28]. The back-propagation algorithm and its variants are examples of gradient-based methods, and researchers commonly use them. However, gradient-based methods are associated with three main problems: slow convergence, initial parameter dependency, and local minima [29,30].
Swarm Intelligence (SI)-based algorithms have been utilized in many applications due to their robustness to initial requirements, global search efficiency, and accuracy. The main objective of SI algorithms is to improve the performance of computations that can assist in solving complex optimization problems with other techniques, such as FNN. SWO, one of the most powerful SI algorithms, has not been fully investigated for selecting optimal weights for fuzzy bases [31,32].
[33] exploited the Harris Hawks optimizer with a recurrent gated unit to discover various infections in coconut trees. The empirical investigation was conducted on the suggested model, and the results demonstrated the adequate performance of the presented model over recent approaches. [34] reported sixteen texture and color attributes for 1265 damaged images of coconut pests by extracting the texture and color attributes of the damaged images in the grey and color domain after damage segmentation utilizing a thresholding approach. They implemented the gray level run length matrix and the gray level co-occurrence matrix to discover the texture attributes of the damages, and they reported two ANN models to categorize the extracted data attributes of the damages into five various classes. The experimental results showed that ANN and SVM outperformed the others in all performance measures, and their proposed model can be used as a baseline model for additional studies to determine coconut pest damage using deep learning methods. [35] utilized seven CNN structures (VGG19, VGG16, MobileNet, Xception, InceptionResNetV2, InceptionV3, and ResNet50) to identify two main maturity stages of the coconut (mature and tender). Recognizing the maturity level of the coconut plants is difficult because of the external lighting with challenging background conditions. Their empirical outcomes showed that the ResNet50 method effectively identified two main stages of coconut maturity with an accuracy of 98.32%. [36] utilized YOLOv5 approach to identify the on-tree mature coconut fruits With an accuracy of 88.4%. [37] introduced a dataset containing the general differences of the coconuts in terms of their maturity statuses through their acoustic characteristics. Their dataset can also help develop an intelligent classification system of coconut through deep learning and machine learning models.
In the literature, very few works consider using SI algorithms in this direction since many improved SI algorithms have been developed [38,39].

Motivations
This investigation aims to develop a precise detector to sort and classify coconut water from coconuts in three different development stages: tender, mature, and very mature, with green, greenish-brown or yellowish-brown, and completely brown colors, respectively. The SWO algorithm is developed to choose the optimal weights for the fuzzy rules to obtain the coconut water maturity prediction, and a prototype sorter is implemented based on the information on the actual times and dissolved oxygen level acquired from an optimized ANN to evaluate the anticipated values of coconut water maturity with an acceptable error margin.

Contributions
The fundamental contributions of this paper can be summarized in the following: • A new model, called FNN-SWO, for predicting coconut water maturity is established based on clustering the input data and data fuzzification to estimate the appropriate stage of maturity of coconut water. • The proposed FNN-SWO model is trained and tested utilizing fuzzy rules with an adaptive network. In contrast, the SWO algorithm is adopted to determine the optimal weights for the fuzzy rules. • Compare the proposed model with the state-of-the-art models and evaluate their performance.

Structure
This paper is structured as follows. Section 2 presents the theories and methods used, that is, the components of the FNN system and the SWO algorithm. The proposed FNN-SWO assessment model is discussed in Sect. 3. Section 4 presents the experimental results and performance analysis. Lastly, concluding remarks are given in Sect. 5.

Fundamental preliminaries
This section concisely describes the methods and materials used in this paper: the components of the FNN system and the SWO algorithm.

ANNs
Neural networks [21,26,40] are modeled after the human brain and imitate the way biological neurons communicate with each other. Node (neuron) layers, including input, hidden, and output layers, make up neural networks. The nodes are components used in information processing. The number of nodes in the input and output layers relates to the dataset's input and output variables. At the same time, the experiment must determine the appropriate number of nodes in the hidden layer. Each node (neuron) links to others in a specific pattern through a connection link. That link is associated with a corresponding weight, which contains details about the input signal and provides helpful information about input to address the problems. Each node can access various inputs but only one output. It takes in the inputs from nearby neurons, elaborates them, and then sends the output to adjacent neurons, giving the inputs the proper weight using the connective values [41].
Neural networks are effective tools that classify and cluster data at a high rate. The ability of neural networks to learn from examples (training data, input, and output samples) is their primary property for improving their accuracy over time. For setting, the required I/O relationship that depicts the behavior of the designed system with an acceptable level of error for the application, neural networks compute outputs from input data, compare the measured and calculated outcomes, and then adjust their internal structure and the weights of the connections between artificial neurons to reduce the discrepancy between the measured and calculated values. It's essential to watch out throughout training to prevent over-fitting. Over-training causes the network to get so used to the example training patterns that it cannot generalize to new data.

Fuzzy systems
There are several reasons to deal with fuzzy events, which are hard to classify. First, fuzzy logic can represent human knowledge more naturally and appropriately. Second, it is widely recognized that many real-world situations are intrinsically fuzzy. Third, fuzzy quantity is simple and easy to use [42,43]. Fuzzy systems are provided to study fuzzy events and interpret the subjective human knowledge of the actual processes. The main specialized paper, which proposed the foundations and mathematics of the fuzzy set theory, was published by [44]. This theory suggested using the continuous interval [0, 1] instead of the discrete set [0, 1] for the membership function (values of true and false). There are three stages in the technique of fuzzy inference: • Fuzzification: a function sets the numeric inputs' values based on the degree to which related fuzzy sets agree. • Processing: rules are processed by the fuzzy system in line with the inputs' firing strengths. • De-fuzzification: the consequent fuzzy values are returned to scalar values.

FNN system
In neural networks [45], the principle of fuzzy systems is used to enable a system to handle real-life situations in a manner more like humans, which helps in accelerating network processes or improving parameters. In FNN, there is a combination of the neural network's capacity to provide the learning's computational features, generalize to untrained samples, and its simplicity in implementation for any complex problem, as well as the fuzzy systems' capacity to clarify the ambiguous data that is so common in real-world situations. Different FNN systems include combinations between neural networks and fuzzy systems according to the stage at which the neural networks are used. FNN systems can be either concurrent, cooperative, or hybrid [46]. Concurrent FNN systems are competing systems that take the output from each other, and a neural network can work on one task without affecting other parameters [47]. These systems are not FNN systems in the strict sense because the fuzzy system and the neural network interact continually. Cooperative (or parallel) FNN systems are preprocessors for fuzzy systems in which the parameters are set using neural networks in an initial phase using training data. Once the fuzzy rules have been produced, the neural networks are taken out, and the fuzzy system is left to operate independently [48]. Hybrid (or integrated) FNN systems combine fuzzy logic and neural networks in a strict sense to determine the parameters iteratively. Hybrid FNN systems are the most suitable for solving diagnostic problems [49].
The advantage of FNN systems is that they can learn through patterns and are simple in interpreting their operations [50]. Recently, the applications of FNN systems have expanded to cover all branches of knowledge, including data classification, data analysis, error detection, and decision-making support.
The five-layer network is recommended for usage in the FNN system of this study. The suggested FNN system is depicted in Fig. 1. An input space x 2 R n is mapped to an output space K 2 R using this FNN system. The FNN uses the following inference rule, namely, rule R j .
A specific procedure must be used to update the parameters, which is summarized as a five-layer network [51], as shown in Fig. 1. Firstly, the input layer that initializes the training stage set \x; k [ by determining the minimum and maximum values signs. Then the second layer is called the membership function layer and is defined as: Where the membership k 2 ij consists of the present j th neuron with the i th input from the former layer as the subscript and the layer number as the superscript. x i denotes the value of i th input. c ij and r ij stand for the center and width of a Gaussian distribution for a set that is assigned to l ij , respectively.
The third layer is dubbed the rule layer. In this layer, the precedents' membership values for each rule are multiplied by each other to acquire the rule's firing strength, which is used to determine the volume of each neuron's output as follows: Subsequently, the resulting layer is the fourth layer. Its outputs are fuzzified values of the outputs from the rule layer. This layer is determined as follows: Where u i means the normalized degree of individual rules' firing.
The connection weights can be determined as follows: Where g 2 ½0; 1 is a given rate of constant learning for the neural network, weights are changed in proportion to the negative of the error derivative with respect to each weight. The fuzzy set values can be calculated, as: An adaptive approach is provided to train the FNN system. During the training procedure, it will look for the value of u(v) until the most negligible value for jy d ðv þ 1Þ À yðv þ 1Þj is obtained. The value ofŷðv þ 1; tÞ will get closer to y d ðv þ 1Þ as the desired value of the manipulated variable is reached. Hence: In FNN training, the value of e u ðvÞ is employed, and the plant model makes sure thatŷðv þ 1Þ closely approximates y d ðv þ 1Þ. There are two ways to assess the learning algorithm mentioned above. At first, the forward way in which the current degree of rules' firing is computed, and the FNN's output is projected. The second way is either optimizing the weight in the resultant layer or concurrently modifying the membership functions and weights.

SWO algorithm
An effective nature-inspired optimization algorithm termed SWO algorithm [52] is introduced to imitate the sperm whale's natural behaviors to live. Breathing and feeding for sperm whales consider two inverse cyclical processes; as they provide on squids but should descend to the depths of the water at about 2000-3000 m to catch squids where they live; while they need to surface to breathe, they can halt breathing for about 90 min [53].
Each solution in the SWO algorithm indicates a sperm whale. Firstly, a sperm whale's initial population is formed, assessed, and arranged. After that, to maintain the global optimum and avoid falling into local optima, this sperm whale's initial population is separated into n distinct Temporal Sub-Groups (TSGs), each of which has m members. For each new Master Sub-Group (MSG), one member is arbitrarily chosen from each Temporal Sub-Group (TSG) [53], as illustrated in Fig. 2.
As mentioned before, in the breathing-feeding cycle, sperm whales pass through two contrasting locations. Hence, there are two solutions for each sperm whale are Fig. 1 Structure of the suggested FNN system taken into consideration, one for its certain location and the other for its opposite location, and the two solutions' objective functions are evaluated. Additionally, only the worst solution is reflected because the best solution's opposite impression does not help determine the optimal solution. SWO transfers the worst solution to an arbitrary point on the line connecting the worst and the best solutions for ensuring that the search space's central reflection x c transmits the point within the wanted solution area. As a result, x c and the acquired reflection position x r can be formulated mathematically as follows: Where x w is the worst whale's position, x b is the best whale's position. c denotes the center factor, which might be any number, c i is the beginning center factor, and r is the shrinking coefficient, which has a value smaller than 1. Equation 11 is applied only in the case of x r is beyond the search space for lessening the value of c. When dealing with global optimization problems that are bound-constrained, the parameter's range c can be chosen so that x r does not go outside the bounds of the search space. Assume C be a vector with a 1 Â n dimension. In this case: Where rand is an arbitrary number chosen from a uniform distribution within the [0, 1] range, in this instance, it is not necessary to confirm whether or not x r is beyond the search, which speeds up the process of finding a solution.
As there would be no need to specify r and c, this also reduces the number of parameters. From each MSG, a selection of q whales with more satisfactory objective functions are chosen as the Good Gang group. Then, a local search is conducted on this Good Gang group's members by altering the solutions within a specified radius; if the altered solutions are improved, they will replace the originals in the Good Gang group. The best solution from the Good Gang group then crosses over with the remaining solutions in the MSG, and between two created children, one (randomly) replaces the mother solution; this procedure is repeated a specific number of times. At last, all of the subgroups' solutions are set next to each other in the sperm whales group and arranged them. These steps are repeated until the optimum solution is obtained. The pseudo-code defining the SWO algorithm is offered in Appendix A after presenting the stages of the SWO algorithm outlined above.

A proposed model based on FNN and SWO (FNN-SWO) for coconut water maturity assessment
This paper suggests an effective modeling process, dubbed FNN-SWO, for forecasting coconut water maturity. The proposed modeling process consists of the following stages: clustering the data, fuzzy analysis including SWO, machine learning, FNN-SWO training, and FNN-SWO Neural Computing and Applications (2023) 35:19541-19564 19547 testing. An overview of the suggested model is presented in the following Subsections, which provide a detailed explanation of each modeling stage and an illustration of the dataset utilized in the case study.
Two key components make up the prediction of coconut water maturity. The first component is the dataset's realtime values, which are utilized to analyze the prediction model. Specifically, the actual times and dissolved oxygen contents are used to compute the predicted values of coconut water maturity based on the appropriate model parameters. All phases of coconut maturation are represented in the model by the values in the dataset, which are derived from the real-time monitoring sensors. The second component is the mechanism that integrates the data and actual timings to calculate the anticipated value of coconut water maturity based on the analyses with a reasonable margin of error.

Data clustering stage
In this stage, all values input into the training dataset are clustered into an n vector space based on the following parameters chosen for clustering: • Effective domain: assign the areas of cluster center for all dimensions of the training dataset. • Parameters used: the first parameter determines the neighborhood of a cluster center. • Acceptance probability: this parameter specifies the threshold above which data points are regarded as cluster centers. • Refusal probability: this parameter sets the threshold below which data points are not considered cluster centers.
The inner vector V of cluster centers is generated during the clustering process. The positions of the cluster centers are included in all rows of vector V. The feedback from vector V contains the values of v, which assign the effective domain of each clustering center for all the dimensions of data, as shown in Algorithm in Appendix B.

Fuzzification stage
A fuzzy block [54] is an extracted group of rules depending on the number of clusters. The rules are grouped in the IF-THEN structure as input-output relationships. This paper proposes a fuzzy and fast machine-learning method based on reinforcement learning. The suggested fuzzy blocks are dependent on two factors.
• The input factor: the parameters of each fuzzy block are updated using a fitness function and the network output. • The critical metric factor: evaluates the signal based on the actual signal. The neural network determines the critical metric. The critical weights are updated using the SWO algorithm, which is explained in Sect. 2.4. Furthermore, the Lyapunov stability function [55] is employed to select the status of the learning rates and guarantee the stability of the proposed model.

Prediction stage
The rules of the membership function are calculated for all values of the input training dataset. The membership rules function is determined using the parameter centroids ðc ij and domain area B ij Þ. The fuzzification stage transforms the input values into membership values and then computes the output using the relevant rules. The outcome of the forecasting region is calculated for making a proper decision. Figure. 3 shows the five-layer FNN recommended in the proposed FNN-SWO model. A first-order fuzzy logic model transforms the fuzzy rules into the desired outputs. The FNN consists of five layers. The first layer is associated with the membership function of the actual value. The second layer represents the degree of membership, which is constructed from the function (ranging from the minimum to the maximum) of the incoming real value. The third layer represents the optimal weight w i ratio of the membership's degree of the ith rule. The fourth layer is the defuzzification layer. The fifth layer calculates the total output as the summation of all real values incoming from the fourth layer.
All parameters in the prediction stage of coconut water maturity are optimized using the SWO algorithm. The proposed model uses fuzzy rules as inputs to the ANN and chooses the optimal weight using the SWO algorithm to obtain the coconut water maturity prediction.
Finally, after describing the stages of the suggested FNN-SWO model in the preceding Subsections for evaluating the maturity of coconut water, Fig. 4 provides the flowchart of the stages in structure determination, training, and testing for the suggested FNN-SWO model.
• The first stage involves determining the data parameters and initially clustering the values. • The second stage is the clustering operation.
• The third stage includes training the clustered data in the model considering the allowable Mean Squared Error (MSE).
• The fourth stage involves testing the model and calculating the average absolute difference between x and Y Mean Absolute Error (MAE), as follows: 4 Results and discussions

Dataset description
Two hundred fruits of coconut from the 7-month development stage and older were gathered after inflorescence emerged from two Pacific coast fields. Coconut water was emptied from a 15-mm hole with a drill. All coconuts were categorized into three classes: tender, mature, and very mature, with green, greenish-brown, or yellowish-brown and completely brown colors, respectively. Dissolved oxygen concentration measurements were made for each class of coconut maturity. The continuous measurements of the oxygen concentration were recorded with a data logger each second in the air and the coconut water to identify the transient response of oxygen in the coconut water from coconuts of each stage. Dissolve oxygen measurements for coconut water can be obtained through three different techniques. First, the transducer is introduced to the coconut water for one minute. Then, the transducer is removed from the coconut water (in the air) for three intervals of 5, 7, and 10 s in different techniques. Three other peak measurements were obtained from each period of transducer contact with the air. The dissolved oxygen measurements' reference points were specified as condition states. The dissolved oxygen concentrations in the air after 5, 7, and 10 s according to the measurement technique, were used to establish the maximum dissolved oxygen (DOmax). The measurements were taken 5, 10, and 60 s after transducer insertion in coconut water and were subsequently denoted as DO5, DO10, and DO60, respectively. The automatic sorter constructed by Hahn [56] was applied in the newly developed model to obtain an exact sorting process, as shown in Fig. 5. Hahn [56] described the main components of the sorter and the operation of the sorter in detail. A dissolved oxygen sensor with a resolution of 0.1 mg of O 2 j À1 (HI 76410/4, Hanna Instruments, USA) was connected to an analyzer panel (HI 8410, Hanna Instruments, USA). The analyzer panel provides an output current of 4-20 mA based on the amount of dissolved oxygen measured by a microcontroller (Fig. 5b).
The curtain valve, as shown in Fig. 5, has a diameter of 150 mm, and the coconut water discharge rate is 75 ml/s. The dissolved oxygen sensor starts to take measurements after 4 s. The microcontroller receives the measurement data for the incoming coconut water class and sends a  35:19541-19564 19549 signal to one of the four solenoid valves, as shown in Fig. 5. Figure 6 shows the dissolved oxygen values for three different samples of the tender class of coconut water.

Working environment
The suggested FNN-SWO method was compared against five state-of-the-art techniques, including SVM-GA, ANN, FNN, ANN-GA, and NB, executed in this paper. To implement all experiments in this paper, Python was utilized on a computing environment with a Dual Intel Ò Xeon Ò Gold 5115 2.4 GHz CPU and 128 GB of RAM on the operating system Microsoft Windows Server 2019. In the proposed approach, the optimality of the results was validated by using the hold-out strategy, where the training and test sets are realized by randomly dividing each dataset into two parts, where the training phase is done on 80% of the dataset while the remaining 20% is for testing purposes. The configuration parameters of the proposed methodology are set considering the original variants and the data presented in their first publications [57,58].

Comparative analysis
This paper's coconut water dataset comprises real-time data collected over 3 months. The FNN parameters were optimized based on the learning factor and learning coefficient. An experimental method to determine the parameters was developed. A structure of 1 to 8 neurons in the hidden layer, a learning factor from 0.01 to 1, and a learning factor step of 0.01 were selected. Different  training and validation steps were performed for each factor, covering the entire range. Then, the number of weights and iterations needed for network training, the prediction error (MAE), and the correlation between the real and predicted values and time data were analyzed for each sample.

Experimental results with partial derivatives (Gradients) and with SWO Optimizer
To show the effectiveness of the proposed framework, an experiment is conducted With partial derivatives (Gradients) and with SWO Optimizer. The obtained results for accuracy, recall, precision, and F1-score are presented in Table 1, in which boldface numbers indicate the best results. It can be noted from Table 1 that the use of SWO leads to a massive improvement in all of the performance metrics by substantial percentages. Table 2 shows the accuracy, precision, recall, and F-Score of the three training subsets of the collected coconut water data and the performance of the proposed FNN-SWO against different algorithms from the literature, including SVM-GA, ANN, FNN, ANN-GA, NB, FNN-PSO, FNN-DE, ANN-SWO, and FNN-SWO, in which boldface numbers indicate the best results. The proposed method and its competitors were performed under the same experimental settings. It is evident from Table 2 that the proposed FNN-SWO method obtained the best performance regarding accuracy, recall, and F-score for 50, 100, and 500 subsets in the training phase. ANN-SWO reached the best performance regarding precision for 50, 100, and 500 subsets in the training phase. It should be noted that for the 50 subsets, the proposed FNN-SWO ranked first for all performance measures except precision. ANN-SWO achieved first place in precision and second in accuracy, recall, and F-score. Finally, NB achieved the worst accuracy, recall, and F-score Neural Computing and Applications (2023) 35:19541-19564 19553 results. For 100 subsets, the proposed FNN-SWO ranked first for all performance measures except precision. ANN-SWO reached first place in precision. FNN achieved second place in accuracy, precision, recall, and F-score. Finally, NB achieved the worst accuracy, precision, and recall results.

Training results
Regarding 500 subsets, the proposed FNN-SWO ranked first for all performance measures except precision. ANN-SWO achieved first place in precision and second place in accuracy. ANN-GA achieved second place in terms of recall and F-score. Finally, NB achieved the worst accuracy, precision, recall, and F-score results. Therefore, the proposed FNN-SWO method could be considered a well-   . 11 Accuracy, precision, recall and F-score values for all competitors with respect to 500 subset in the training phase regarded and proficient heuristic for discovering optimal or near-optimal solutions to classification problems.
Meanwhile, Fig. 9 shows the values of each of the four metrics utilized in that competition. Based on the values recorded (as depicted in Fig. 9), the proposed FNN-SWO approach exceeded others for all performance metrics except precision for the 50 subsets in the training phase. Figure 10 shows the values of each of the four metrics utilized in that competition for 100 subsets in the training phase. Based on the values recorded, the proposed FNN-SWO performed the best for all performance measures except precision. Based on the values recorded in Fig. 11,  Neural Computing and Applications (2023) 35:19541-19564 19557 the proposed FNN-SWO achieved the best for all performance measures except precision for 500 subsets in the training phase. Regarding Figs. 9, 10, and 11, ANN-SWO ranked first in precision for 50, 100, and 500 subsets in the training phase. Table 3 shows the accuracy, precision, recall, and F-Score for three subset data periods of the collected coconut water data, in which boldface numbers indicate the best results. For 50 subsets, the proposed FNN-SWO ranked first in accuracy and precision. ANN-GA ranked first in terms of sensitivity. FNN ranked first in terms of Specificity.

Testing results
Regarding 75 subsets, the proposed FNN-SWO achieved the best for all performance measures except sensitivity. FNN performed the best for sensitivity. Finally, the proposed FNN-SWO ranked first for all performance measures in 120 subsets.
Meanwhile, Fig. 12 shows the accuracy, sensitivity, Specificity, and precision values for the proposed method and their counterparts with respect to 50 subsets in the testing phase. Based on the recorded values, the proposed FNN-SWO achieved the best accuracy and precision. ANN-GA achieved the best in terms of sensitivity. FNN ranked first in terms of Specificity. Figure 13 shows the performance measures obtained by the proposed method and their counterparts for 75 subsets in the testing phase.   35:19541-19564 19559 Based on the values registered, the proposed FNN-SWO achieved the best for all performance measures except sensitivity. FNN performed the best for sensitivity. Figure 14 shows the evaluation metrics obtained by the proposed method and their competitors concerning 120 subsets in the testing phase. The proposed FNN-SWO achieved the best for all performance measures based on the values registered. The actual and predicted values data for three subset data periods of the collected coconut water data in the testing phase are compared and presented in Figures. 15, 16, and 17. Figure 15 shows the tender class, Fig. 16 represents the mature class, and Fig. 15 reveals the very mature class. The predicted data are consistent with the actual data shown in these figures, which also reveals that the proposed FNN-SWO method could be considered a well-regarded and proficient heuristic for discovering optimal or near-optimal solutions to classification problems.

MAE and MSE values
The prediction model is run with the training and testing subsets, and the worst, average, and best MAE and MSE values are computed for each subset of data, as shown in  Fig. 19, the proposed FNN-SWO obtained the least MAE and MSE values in the testing phase for the coconut dataset.

Managerial implication of the proposed model
The proposed FNN-SWO method employs the SWO algorithm to select the optimum weights for the fuzzy rules. Our proposed FNN-SWO can achieve high accuracy in terms of training and testing compared to other models.
It plays an essential role as a tool for predicting the maturity level of coconut water. This tool can be combined with coconut water extraction machines in manufacturing to separate coconut water into three maturity levels (i.e., tender, mature, and very mature).

Conclusion and future work
The main problem addressed in this study is how to accurately evaluate the maturity level of coconut water, a time-consuming task in the beverage industry. Therefore, to solve this problem, an integrated model called FNN-SWO has been proposed to evaluate the maturity of coconut water. The SWO method has been incorporated into this approach along with FNN techniques, which can be utilized as an essential building block in the beverage industry. The proposed FNN-SWO model is trained and tested using fuzzy rules with an adaptive network, whereas the SWO algorithm is utilized to select the optimum weights for the fuzzy rules. Multiple evaluation measures (precision, recall, F1-score, specificity, sensitivity, and accuracy) were adopted to estimate its performance. Based on the findings, The noticeable outcomes were: (i) the FNN-SWO model had the best prediction results for recall, F1-score, specificity, and accuracy and was ranked second in terms of precision and sensitivity; and (ii) The SWO algorithm had a significant impact on improving the prediction of the maturity of coconut water. These results revealed that integrating both methods has an inherent advantage over other methods for distinguishing between different maturity classes of coconut water. Compared with other methods, the FNN-SWO model outcomes performed best. Overall, these findings could pave the way for the future design and development of robust prediction algorithms for specific datasets. Furthermore, the results recorded from the dataset would greatly benefit the scientific community interested in coconut water assessment.
To expedite this process, surrogate-assisted models could be investigated in the future. Furthermore, other SI and meta-heuristic algorithms could be tested, such as the ant colony and sparrow search. Also, adopting other datasets in the proposed approach could be considered. Data availability The datasets generated during and/or analysed during the current study are available from the corresponding author on reasonable request.

Declarations
Conflict of interest The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons. org/licenses/by/4.0/.