# Predictive Model of Humidity in Greenhouses through Fuzzy Inference Systems Applying Optimization Methods

Authors: Sebastian-Camilo Vanegas-Ayala; Julio Barón-Velandia; Daniel-David Leal-Lara
Journal: Advances in Fuzzy Systems
 (2023)

---

## Abstract

Establishing the indoor and outdoor humidity values in a greenhouse allows us to describe the crop yield during its entire developmental cycle. This study seeks to develop a predictive model of indoor relative humidity values in a greenhouse with high accuracy and interpretability through the use of optimized fuzzy inference systems, in order to offer greenhouse users a clear and simple description of their behaviour. The three-phase methodology applied made use of descriptive statistics techniques, correlation analysis, and prototyping paradigm for the iterative and incremental development of the predictive model, validated through error measurement. The research resulted in six models which define the behaviour of humidity as a result of temperature, CO2, and soil moisture, with percentages of effectiveness above 90%. The implementation of a Mamdani-type fuzzy inference system, optimized by a hybrid method combining genetic and interior point algorithms, allowed to predict the relative humidity in greenhouses with high interpretability and precision, with an effectiveness percentage of 90.97% and MSE (mean square error) of 8.2e − 3.


---

## Body

## 1. Introduction

Greenhouse farming uses facilities and technologies that meet the growth and development requirements with the aim of establishing or improving environmental meteorological factors to provide a suitable growing environment. This allows to reduce dependence on the natural environment, protect plantations from bad weather, diseases, and pests, and increase production and yield and requires less land area for agricultural activity [1–6].Similarly, it has been evidenced that the production of crops is affected by the climate generated by the greenhouse, influenced by external climatic conditions such as wind speed, solar radiation, outdoor temperature, and humidity, the structure of the greenhouse, the type and state of the crop, and activation control signals, such as ventilation, heating, and CO2 injection, which influence photosynthesis and evaporative cooling to enrich humidity and decrease air temperature [1–3].The greenhouse climate then becomes a time-varying, nonlinear, and distributed parameter system, with multiple interactions between system inputs and outputs. It presents a dynamic behavior that involves the combination of physical processes such as energy transfer (radiation and heat) and mass transfer (water vapor fluxes and CO2 concentration) that take place inside and outside the greenhouse [5–11].Some proposals have modeled the greenhouse environment through the use of differential equations for air temperature, humidity, and CO2 concentrations, deriving the appropriate mass and energy balances, for indoor temperature and indoor humidity [1, 3, 8, 12–15]. However, these models are difficult to describe mathematically, especially when the structure of the system and the relationship between variables are not well known or too complex. To solve these limitations, artificial intelligence (AI) techniques are implemented—such as artificial neural networks (ANNs), fuzzy logic (FL), and genetic algorithms (GAs), which allow developing various control and modeling techniques [6, 14].The main environmental factors affecting crops are humidity, temperature, and shade conditions. Proper management of these conditions increases the degree of vitality and yield of plants [13, 16]. Control and modeling of humidity for greenhouse climate management plays a key role here, as it improves the biological processes of plants in relation to transpiration and photosynthesis, which translate into a positive effect on crop growth and production [3, 6, 9].The use of fuzzy inference systems constitutes a framework for modeling complex nonlinear relationships that provides advantages such as the reasoning mechanism in understandable human terms, the ability to take linguistic information from human experts and combine it with numerical data, simultaneous manipulation of numerical and linguistic information, the ability to approximate complex nonlinear functions with simple models, and representation in linear time-invariant local models [1, 4, 6–8, 10, 17, 18].Similarly, fuzzy logic has been combined with control for the development of fuzzy controllers to manage greenhouse environments demonstrating that these systems perform with high accuracy in practical applications by maintaining variables at desired conditions and being resilient to disturbances [19, 20].The processes and interactions of the greenhouse environment make this type of system a potent, efficient, and successful tool to precisely control the management of greenhouse systems in combination with GAs and ANNs [6, 15, 21]. In addition, the implementation of fuzzy clustering techniques allows automatic generation of fuzzy models. K-means, C-means, and subtractive fuzzy clustering are some useful techniques to describe complex dynamical systems and provide an automatic way to generate robust fuzzy systems [17].On the other hand, many fuzzy modeling approaches concentrate on the accuracy of the model, that is, fitting data as accurately as possible, for which they implement both heuristic and exact AI-based optimization mechanisms, achieving significant improvement in the performance of the models [9, 22–27]. However, similarly they pay little attention to model simplicity and interpretability, which is considered the main objective of fuzzy inference systems [6]. Therefore, it is necessary to find solutions that maintain both the system accuracy and its interpretability, guaranteeing a better performance as well as greater understanding of the modeled system [28].This research seeks to develop a predictive model of indoor relative humidity values in a greenhouse with high accuracy and interpretability through the use of fuzzy inference systems, optimized by heuristic and accurate methods, in order to offer greenhouse users a clear and simple description of their behaviour.A moisture prediction model with high interpretability is presented based on a complete analysis of the variables that interact in a greenhouse environment, guaranteeing high accuracy values with the optimization of each model, a strategy that is not currently exploited [28]. The content was divided into the following sections: materials and methods, results, discussion, and conclusions.


## 2. Materials and Methods

The methodological technique applied for obtaining the model conforms to three phases, as indicated in Figure1. It starts with the analysis of data obtained from a greenhouse environment, continues with the construction of the setup through the iterative and incremental elaboration of software prototypes, and relies on model validation involving measurement of the degree of accuracy and interpretability to select the predictive model.Figure 1
The methodological technique applied (adapted from [13, 15, 22, 29, 30]).


### 2.1. Data Analysis

A statistical analysis was performed based on data obtained from the greenhouse environment of a bean crop in the city of Bogotá, Colombia [31]. Humidity and relative temperature, soil moisture, light intensity, CO2 concentration, luminosity, and activation of ventilation system, irrigation system, and heating system were measured. The crop’s behaviour was thus defined, and possible dependencies between the variables were found using RStudio and Orange statistical software.Due to the data used, the model is restricted to values obtained under climatological conditions in the city of Bogotá D.C. and limited to the sensors used with values of(i)
Internal relative humidity: 0 to 100%.(ii)
Internal temperature: −40 to 80°C.(iii)
Soil humidity: 1 to 1023 V transformed to 0 to 100%.(iv)
Light intensity: (λ0.5) 350 to 375 nm.(v)
CO2 concentration: 300 to 10000 ppm.(vi)
Luminosity: 188 to 88000 Lux.


### 2.2. Characterization of Variables

Exploratory statistics allow one to obtain the mean of each variable, its standard deviation, the coefficient of skewness, kurtosis, and the quantiles 0, 0.25, 0.5, 0.75, and 1. This provides a detailed characterization of the variables that form the fuzzy sets.


### 2.3. Correlation Analysis of Variables

A multivariate statistical analysis was performed for each of the variables, using two Pearson and Spearman correlation coefficients, compared to the selection of attributes using the RReliefF method [32]. The dependencies between variables and their relationship with the indoor relative humidity were identified.


### 2.4. Model Building

A prototype-based incremental iterative development cycle was applied, determining and verifying each of the parameters that conform to the proposed fuzzy inference systems together with a hybrid optimization mechanism, guaranteeing a high degree of accuracy in each of the proposals configured using Matlab.


### 2.5. Determination of Input Variables

The input variables are variables that make up the input of each fuzzy inference system and that present a significant effect on the prediction of the indoor relative humidity in the correlation analysis.


## 2.1. Data Analysis

A statistical analysis was performed based on data obtained from the greenhouse environment of a bean crop in the city of Bogotá, Colombia [31]. Humidity and relative temperature, soil moisture, light intensity, CO2 concentration, luminosity, and activation of ventilation system, irrigation system, and heating system were measured. The crop’s behaviour was thus defined, and possible dependencies between the variables were found using RStudio and Orange statistical software.Due to the data used, the model is restricted to values obtained under climatological conditions in the city of Bogotá D.C. and limited to the sensors used with values of(i)
Internal relative humidity: 0 to 100%.(ii)
Internal temperature: −40 to 80°C.(iii)
Soil humidity: 1 to 1023 V transformed to 0 to 100%.(iv)
Light intensity: (λ0.5) 350 to 375 nm.(v)
CO2 concentration: 300 to 10000 ppm.(vi)
Luminosity: 188 to 88000 Lux.


## 2.2. Characterization of Variables

Exploratory statistics allow one to obtain the mean of each variable, its standard deviation, the coefficient of skewness, kurtosis, and the quantiles 0, 0.25, 0.5, 0.75, and 1. This provides a detailed characterization of the variables that form the fuzzy sets.


## 2.3. Correlation Analysis of Variables

A multivariate statistical analysis was performed for each of the variables, using two Pearson and Spearman correlation coefficients, compared to the selection of attributes using the RReliefF method [32]. The dependencies between variables and their relationship with the indoor relative humidity were identified.


## 2.4. Model Building

A prototype-based incremental iterative development cycle was applied, determining and verifying each of the parameters that conform to the proposed fuzzy inference systems together with a hybrid optimization mechanism, guaranteeing a high degree of accuracy in each of the proposals configured using Matlab.


## 2.5. Determination of Input Variables

The input variables are variables that make up the input of each fuzzy inference system and that present a significant effect on the prediction of the indoor relative humidity in the correlation analysis.


## 3. Prototyping from Different Perspectives

Six prototypes based on the Mamdani, Takagi–Sugeno (TS), and ANFIS fuzzy inference systems represented asfX⟶ were developed. For each of the configurations, a variation was implemented using C-means fuzzy clustering algorithms. 70% of the data from the dataset were used for training, defined as XT⟶ and YT⟶, and the remaining 30% were used for its validation, XV⟶ and YV⟶.The Mamdani fuzzy inference system was defined by themamfis function in Matlab, as shown in the following equation:(1)fX⟶=mamfisAnd Method,Or Method,Defuzzification Method,Implication Method,Aggregation Method,fX⟶=mamfis'min','max','centroid','min','max'.It features the AND fuzzy operator method for the minimum fuzzy input values, the OR fuzzy operator method for the maximum fuzzy input values, the defuzzification method to calculate sharp output values using the centroid of the area under the output fuzzy set, the implication method to compute the consequent fuzzy set, the consequent membership function at the value of the antecedent result, and the aggregation method to combine rule consequents as the maximum of consequent fuzzy sets.On the other hand, the Sugeno fuzzy inference system is described by thesugfis function in Matlab, as shown in the following equation:(2)fX⟶=sugfisAnd Method,Or Method,Defuzzification Method,Implication Method,Aggregation Method,fX⟶=sugfis'prod','max','wtaver','prod','sum'.It implements the AND fuzzy operator method as the product of fuzzy input values, the OR fuzzy operator method as the maximum of fuzzy input values and the probabilistic OR of fuzzy input values for their variation by clusters, the defuzzification method to calculate sharp output values defined as the weighted mean of all rule outputs, the implication method to calculate the consequent fuzzy set, the scale of the consequent membership function by the value of the antecedent result, and finally the aggregation method for combining rule consequents implementing the sum of consequent fuzzy sets.The configuration of the ANFIS fuzzy inference system starts from the implemented configuration of the Sugeno fuzzy inference system and implements the functionsanfisOptions and anfis, as detailed in the following equation:(3)fΧ⟶=anfistrain Data,anfis OptionsInitial FIS,Epoch Number,Initial Step Size,Validation Data,fΧ⟶=anfisXT⟶YT⟶,anfis Optionssugfis,2000.1,XV⟶YV⟶.The maximum number of training epochs from the Sugeno model is defined at 200, the initial training step size at 0.1, and the optimization method by the hybrid method with Backpropagation for the input and least squares for the output.The fuzzy clustering for the three types of fuzzy inference systems is defined through the MatlabgenfisOptions and the genfis function, as indicated in the following equation:(4)fΧ⟶=genfisin,out,genfis Optionsclustering Type,Num Clusters,Exponent,Max NumIteration,Min Improvement,fΧ⟶=genfisXT⟶,YT⟶,genfis Options'FCM Clustering',5,2.0,100,1×10−5.A configuration with five clusters using the C-means method, a fuzzy partition matrix exponent of 2.0, a maximum number of iterations of 100, and a minimum improvement of the objective function of 1e-5 is implemented for the Mamdani and Sugeno fuzzy inference systems.


### 3.1. Implementing Optimization Mechanisms

A combination of heuristic and exact techniques is used to optimize all elaborated model proposals, fitting the values that determine the shape of inputs and outputs with a hybrid function that executes a minimization by interior point algorithm after being processed by a genetic algorithm.The interior point algorithm, represented ashΧ⟶, is defined with the optimoptions function in Matlab to create the function that continues the optimization after the genetic algorithm finishes, as shown in the following equation:(5)hΧ⟶=optim optionsSolver Name,Algorithm,MaxIter,Max Fun Evals,hΧ⟶=optim options'fmincon','interior−point',30,3000,with a maximum number of function evaluations of 3000 and a maximum number of iterations of 30 before the algorithm stops.On the other hand, the genetic algorithmgΧ⟶ is implemented using the same optimoptions function but includes in its parameters a hybrid function through HybridFcn to hΧ⟶, as indicated in the following equation:(6)gΧ⟶=optim optionsSolver Name,Population Size,Elite Count,Max Generations,Crossover Fraction,Hybrid Fcn,Max Time,gΧ⟶=optim options'ga',50.0,2,200,0.8,@fmincon,h,300.It determines a population size of 50 individuals, a maximum number of iterations of 200 before the algorithm stops, the number of individuals of the current generation that are guaranteed to survive until the next generation of 2, and the fraction of the population in the next generation (not including those who were guaranteed survival), which creates the crossover function at about 80% and determines the stop time of the algorithm after running for 300 seconds.Finally, the optimized fuzzy inference systemfoptΧ⟶ was defined at 7, implementing the Matlab functions tunefis Options and tunefis:(7)foptΧ⟶=tunefisf,get Tunable Settingsf,in,out,tunefis OptionsMethod,Optimization Type,Method Options,foptΧ⟶=tunefisf,fin;fout,XT⟶,YT⟶,tunefis Options'ga','tuning',g.The hybrid functiongΧ⟶ was defined as the optimization method starting with the genetic algorithm and following with the interior point algorithm, optimizing the existing input, output, and rule parameters without learning new rules and obtaining only the adjustable parameter configuration of the input and output of the fuzzy inference system by means of the getTunableSettings function in Matlab.


### 3.2. Model Validation

Each of the proposed fuzzy inference systems was evaluated in regard to accuracy and interpretability by selecting the predictive model.


### 3.3. Measuring the Degree of Accuracy

The six prototypes of fuzzy inference systems developed were run on 30 occasions, and the training and validation values of their maximum, minimum, mean square errorMSE, root mean square error RMSE, and mean absolute error MAE were defined as indicated in the following equation:(8)MSE=1n∑i=1nfoptxi−yi2,RMSE=MSE,MAE=1n∑i=1nfoptxi−yi.


### 3.4. Comparison of Degree of Accuracy and Interpretability

The proposals were compared taking into account the highest degree of accuracy and interpretability of each, selecting the model with the highest degree of interpretation and precision. At-test of two samples was performed to determine whether the data obtained by the prediction in relation to the actual data came from the same distribution with the same mean and variance.The level of interpretation is defined on a scale of 1 to 6, where 1 indicates the lowest level and 6 the highest. Similarly, the degree of accuracy is defined by assigning a value from 1 to 6 to the respective model, where 1 represents the lowest and 6 the highest value of accuracy. This process is performed for the lowestMSE value obtained from the 30 runs of the model and for the MSE value of all its runs, to finally get an average of both precision values.Finally, the interpretation level and precision degree values were added to define a selection ranking, where the model to choose corresponds to the one presenting the highest value.The percentage of effectiveness of the model is defined using the following equation.(9)Effectiveness=1001−RMSE.


### 3.5. Software Prototyping Paradigm

The prototyping-based paradigm offers the best methodology to evaluate the efficiency of proposed models and their adaptability in iterative and incremental software developments [30]. The process is characterized by five stages, described as follows:(1)
Communication: the overall objectives of the software solution are defined, identifying the specific parameters and configurations of each model(2)
Quick plan: quick planning of the iteration is done to make a prototype that meets the set needs(3)
Modeling and quick design: modeling is carried out in the form of quick design that shows the configuration of the model, as well as the configuration of the user interaction interfaces(4)
Construction of the prototype: the development of the software prototype of the model continues(5)
Deployment, delivery, and feedback: the implemented prototype is evaluated and validated, in order to identify functionality and performance improvements if required in future iterations


## 3.1. Implementing Optimization Mechanisms

A combination of heuristic and exact techniques is used to optimize all elaborated model proposals, fitting the values that determine the shape of inputs and outputs with a hybrid function that executes a minimization by interior point algorithm after being processed by a genetic algorithm.The interior point algorithm, represented ashΧ⟶, is defined with the optimoptions function in Matlab to create the function that continues the optimization after the genetic algorithm finishes, as shown in the following equation:(5)hΧ⟶=optim optionsSolver Name,Algorithm,MaxIter,Max Fun Evals,hΧ⟶=optim options'fmincon','interior−point',30,3000,with a maximum number of function evaluations of 3000 and a maximum number of iterations of 30 before the algorithm stops.On the other hand, the genetic algorithmgΧ⟶ is implemented using the same optimoptions function but includes in its parameters a hybrid function through HybridFcn to hΧ⟶, as indicated in the following equation:(6)gΧ⟶=optim optionsSolver Name,Population Size,Elite Count,Max Generations,Crossover Fraction,Hybrid Fcn,Max Time,gΧ⟶=optim options'ga',50.0,2,200,0.8,@fmincon,h,300.It determines a population size of 50 individuals, a maximum number of iterations of 200 before the algorithm stops, the number of individuals of the current generation that are guaranteed to survive until the next generation of 2, and the fraction of the population in the next generation (not including those who were guaranteed survival), which creates the crossover function at about 80% and determines the stop time of the algorithm after running for 300 seconds.Finally, the optimized fuzzy inference systemfoptΧ⟶ was defined at 7, implementing the Matlab functions tunefis Options and tunefis:(7)foptΧ⟶=tunefisf,get Tunable Settingsf,in,out,tunefis OptionsMethod,Optimization Type,Method Options,foptΧ⟶=tunefisf,fin;fout,XT⟶,YT⟶,tunefis Options'ga','tuning',g.The hybrid functiongΧ⟶ was defined as the optimization method starting with the genetic algorithm and following with the interior point algorithm, optimizing the existing input, output, and rule parameters without learning new rules and obtaining only the adjustable parameter configuration of the input and output of the fuzzy inference system by means of the getTunableSettings function in Matlab.


## 3.2. Model Validation

Each of the proposed fuzzy inference systems was evaluated in regard to accuracy and interpretability by selecting the predictive model.


## 3.3. Measuring the Degree of Accuracy

The six prototypes of fuzzy inference systems developed were run on 30 occasions, and the training and validation values of their maximum, minimum, mean square errorMSE, root mean square error RMSE, and mean absolute error MAE were defined as indicated in the following equation:(8)MSE=1n∑i=1nfoptxi−yi2,RMSE=MSE,MAE=1n∑i=1nfoptxi−yi.


## 3.4. Comparison of Degree of Accuracy and Interpretability

The proposals were compared taking into account the highest degree of accuracy and interpretability of each, selecting the model with the highest degree of interpretation and precision. At-test of two samples was performed to determine whether the data obtained by the prediction in relation to the actual data came from the same distribution with the same mean and variance.The level of interpretation is defined on a scale of 1 to 6, where 1 indicates the lowest level and 6 the highest. Similarly, the degree of accuracy is defined by assigning a value from 1 to 6 to the respective model, where 1 represents the lowest and 6 the highest value of accuracy. This process is performed for the lowestMSE value obtained from the 30 runs of the model and for the MSE value of all its runs, to finally get an average of both precision values.Finally, the interpretation level and precision degree values were added to define a selection ranking, where the model to choose corresponds to the one presenting the highest value.The percentage of effectiveness of the model is defined using the following equation.(9)Effectiveness=1001−RMSE.


## 3.5. Software Prototyping Paradigm

The prototyping-based paradigm offers the best methodology to evaluate the efficiency of proposed models and their adaptability in iterative and incremental software developments [30]. The process is characterized by five stages, described as follows:(1)
Communication: the overall objectives of the software solution are defined, identifying the specific parameters and configurations of each model(2)
Quick plan: quick planning of the iteration is done to make a prototype that meets the set needs(3)
Modeling and quick design: modeling is carried out in the form of quick design that shows the configuration of the model, as well as the configuration of the user interaction interfaces(4)
Construction of the prototype: the development of the software prototype of the model continues(5)
Deployment, delivery, and feedback: the implemented prototype is evaluated and validated, in order to identify functionality and performance improvements if required in future iterations


## 4. Results and Discussion

### 4.1. Information Analysis and Correlation

A statistical and correlation analysis of a total of 61,925 records is performed with the dataset using statistical software, following these preprocessing tasks: removal of seconds in record dates to facilitate unification of data, selection of the study variables, deletion of the records with missing information, and normalization in the interval of [0, 1].The statistical data for the variables are shown in Table1. Most cases show positive kurtosis, except for soil moisture and temperature. Additionally, a negative skew coefficient is presented for relative humidity and soil moisture, evidencing a concentration of the data on the left. In the other cases, it is presented as a skew positive, concentrated on the right, only close to zero in the case of temperature.Table 1
Exploratory analysis of the variables in the greenhouse.
VariableMeanStandard deviationSkewness coefficientKurtosis0%25%50%75%100%act_fan0.152539360.359545811.93283771.7359178000.000000000.000000000.00000001act_heating0.113831250.317608762.43180463.9138001700.000000000.000000000.00000001act_solenoid_valve0.033556720.180086625.180377524.8371128800.000000000.000000000.00000001co2_ppm0.099740950.087088063.554692419.5888784800.052392290.084000870.11214551ground_humidity_per0.627095500.21353123−0.6608821−0.3303842100.500000000.703703700.81481481hum0.873825990.15438635−1.33208901.5055450100.788023950.940119761.00000001light_Intensity0.240095550.187414051.15212730.0205486800.121537340.121537340.40614411Luminosity0.186167860.226914101.30119770.6247416100.021973730.051081370.32700541temp0.337173490.163747560.1102891−0.7681373800.181434600.375527430.45569621The correlation analysis using the Pearson correlation coefficient is shown in Table2, where the most direct correlation with indoor humidity is evident: temperature, followed by luminosity and subsequently the performance of ventilation and heating systems.Table 2
Pearson’s correlation matrix of the variables in the greenhouse.
Variableact_fanact_heatingact_solenoid_valveco2_ppmground_humidity_perhumlight_IntensityLuminositytempact_fan1.000−0.0750.013−0.179−0.124−0.2120.0920.1160.028act_heating−0.0751.000−0.0190.1840.067−0.143−0.114−0.155−0.074act_solenoid_valve0.013−0.0191.0000.3740.0370.0470.0310.0150.002co2_ppm−0.1790.1840.3741.0000.2590.1330.024−0.060−0.088ground_humidity_per−0.1240.0670.0370.2591.0000.1150.230−0.0290.244hum−0.212−0.1430.0470.1330.1151.000−0.060−0.245−0.596light_Intensity0.092−0.1140.0310.0240.230−0.0601.0000.8500.390Luminosity0.116−0.1550.015−0.060−0.029−0.2450.8501.0000.448temp0.028−0.0740.002−0.0880.244−0.5960.3900.4481.000The results of Spearman’s correlation coefficient are shown in Table3, which mostly indicate the same order of direct correlation between humidity and the environment variables resulting from Pearson’s coefficient.Table 3
Spearman correlation matrix of the variables in the greenhouse.
Variableact_fanact_heatingact_solenoid_valveco2_ppmground_humidity_perhumlight_IntensityLuminositytempact_fan1.000−0.0750.013−0.261−0.125−0.1900.0840.1400.038act_heating−0.0751.000−0.0190.2210.086−0.181−0.134−0.229−0.066act_solenoid_valve0.013−0.0191.0000.2440.0440.0400.0500.0340.005co2_ppm−0.2610.2210.2441.0000.2170.1640.147−0.043−0.101ground_humidity_per−0.1250.0860.0440.2171.000−0.0540.2460.0200.241hum−0.190−0.1810.0400.164−0.0541.000−0.106−0.216−0.584light_Intensity0.084−0.1340.0500.1470.246−0.1061.0000.8310.398Luminosity0.140−0.2290.034−0.0430.020−0.2160.8311.0000.441temp0.038−0.0660.005−0.1010.241−0.5840.3980.4411.000The RReliefF attribute selection method resulted in the following order for humidity as the target variable of the greenhouse environment:(1)
Temperature(2)
Luminosity(3)
Soil moisture(4)
Intensity of light(5)
Concentration of CO2(6)
Ventilation activation(7)
Activation of the irrigation system(8)
Activation of heating systemBased on previous analyses comparing correlation coefficients and attribute selection, it is determined that the variables that most affect indoor relative humidity values within greenhouses are(i)
Temperature, which in turn relates to the values of luminosity and intensity of light(ii)
Concentration of CO2, which in turn relates to the actuators(iii)
Soil moisture, which, in turn, relates to activation of the irrigation system


### 4.2. Construction of the Models

Six proposed models were constructed using the Mamdani, Takagi–Sugeno (TS), and ANFIS fuzzy inference systems, along with their variation using C-means fuzzy clustering. They were optimized by a hybrid algorithm that combined the genetic and interior point algorithms. The current data and two shifts in time for temperature, CO2, and soil moisture were used as input for the prediction of humidity. For each of the inputs, the following input fuzzy sets were proposed:(i)
temp: current temperature(ii)
temp-1: temperature with one shift in time(iii)
temp-2: temperature with two shifts in time(iv)
co2_ppm: current CO2 concentration(v)
co2_ppm-1: concentration of CO2 with one shift in time(vi)
co2_ppm-2: CO2 concentration with two shifts in time(vii)
ground_humidity_per: current soil moisture(viii)
ground_humidity_per-1: soil moisture with one shift in time(ix)
ground_humidity_per-2: soil moisture with two shifts in timeThe models without fuzzy clustering, all Gaussian, were comprised by three membership functions representing the values of the variable: low, medium, and high. On the other hand, the inputs of the models with clustering were composed of five membership functions of the same type.The output fuzzy set conforms to five membership functions representing the values of the variable: very low, low, medium, high, and very high. Sugeno and ANFIS models are linear, and Mamdani models are triangular. For models with Mamdani-type fuzzy clustering, the output is composed of Gaussian-type membership functions. The range of values for system inputs and outputs is defined as follows:(i)
Temperature between 0.2 and 0.8(ii)
CO2concentration between 0.0 and 0.4(iii)
Soil moisture between 0.3 and 0.8(iv)
Humidity between 0.4 and 1.0The exploratory analysis defined the rules implemented in the models without fuzzy clustering as follows:(i)
If the historical and current temperature is high, the CO2 with two shifts is medium and the previous and current is low; if historical and current soil moisture is low, then humidity is very low.(ii)
If the temperature with two shifts is medium and the previous and current is high, the historical CO2 concentration is low and the current is medium; the soil moisture with two shifts is low and the previous and current is medium) then humidity is low.(iii)
If the historical and current temperature is medium, the historical and current CO2 is medium; if the historical and current soil moisture is medium, then the humidity is medium.(iv)
If the temperature with two shifts is medium and the previous and current is low, the historical CO2 concentration is high and the current is medium; the soil moisture with two shifts is high and the previous and current is medium, then humidity is high.(v)
If the historical and current temperature is low, the CO2 with two shifts is medium and the previous and current high; the historical and current soil moisture is high, then humidity is very high.


## 4.1. Information Analysis and Correlation

A statistical and correlation analysis of a total of 61,925 records is performed with the dataset using statistical software, following these preprocessing tasks: removal of seconds in record dates to facilitate unification of data, selection of the study variables, deletion of the records with missing information, and normalization in the interval of [0, 1].The statistical data for the variables are shown in Table1. Most cases show positive kurtosis, except for soil moisture and temperature. Additionally, a negative skew coefficient is presented for relative humidity and soil moisture, evidencing a concentration of the data on the left. In the other cases, it is presented as a skew positive, concentrated on the right, only close to zero in the case of temperature.Table 1
Exploratory analysis of the variables in the greenhouse.
VariableMeanStandard deviationSkewness coefficientKurtosis0%25%50%75%100%act_fan0.152539360.359545811.93283771.7359178000.000000000.000000000.00000001act_heating0.113831250.317608762.43180463.9138001700.000000000.000000000.00000001act_solenoid_valve0.033556720.180086625.180377524.8371128800.000000000.000000000.00000001co2_ppm0.099740950.087088063.554692419.5888784800.052392290.084000870.11214551ground_humidity_per0.627095500.21353123−0.6608821−0.3303842100.500000000.703703700.81481481hum0.873825990.15438635−1.33208901.5055450100.788023950.940119761.00000001light_Intensity0.240095550.187414051.15212730.0205486800.121537340.121537340.40614411Luminosity0.186167860.226914101.30119770.6247416100.021973730.051081370.32700541temp0.337173490.163747560.1102891−0.7681373800.181434600.375527430.45569621The correlation analysis using the Pearson correlation coefficient is shown in Table2, where the most direct correlation with indoor humidity is evident: temperature, followed by luminosity and subsequently the performance of ventilation and heating systems.Table 2
Pearson’s correlation matrix of the variables in the greenhouse.
Variableact_fanact_heatingact_solenoid_valveco2_ppmground_humidity_perhumlight_IntensityLuminositytempact_fan1.000−0.0750.013−0.179−0.124−0.2120.0920.1160.028act_heating−0.0751.000−0.0190.1840.067−0.143−0.114−0.155−0.074act_solenoid_valve0.013−0.0191.0000.3740.0370.0470.0310.0150.002co2_ppm−0.1790.1840.3741.0000.2590.1330.024−0.060−0.088ground_humidity_per−0.1240.0670.0370.2591.0000.1150.230−0.0290.244hum−0.212−0.1430.0470.1330.1151.000−0.060−0.245−0.596light_Intensity0.092−0.1140.0310.0240.230−0.0601.0000.8500.390Luminosity0.116−0.1550.015−0.060−0.029−0.2450.8501.0000.448temp0.028−0.0740.002−0.0880.244−0.5960.3900.4481.000The results of Spearman’s correlation coefficient are shown in Table3, which mostly indicate the same order of direct correlation between humidity and the environment variables resulting from Pearson’s coefficient.Table 3
Spearman correlation matrix of the variables in the greenhouse.
Variableact_fanact_heatingact_solenoid_valveco2_ppmground_humidity_perhumlight_IntensityLuminositytempact_fan1.000−0.0750.013−0.261−0.125−0.1900.0840.1400.038act_heating−0.0751.000−0.0190.2210.086−0.181−0.134−0.229−0.066act_solenoid_valve0.013−0.0191.0000.2440.0440.0400.0500.0340.005co2_ppm−0.2610.2210.2441.0000.2170.1640.147−0.043−0.101ground_humidity_per−0.1250.0860.0440.2171.000−0.0540.2460.0200.241hum−0.190−0.1810.0400.164−0.0541.000−0.106−0.216−0.584light_Intensity0.084−0.1340.0500.1470.246−0.1061.0000.8310.398Luminosity0.140−0.2290.034−0.0430.020−0.2160.8311.0000.441temp0.038−0.0660.005−0.1010.241−0.5840.3980.4411.000The RReliefF attribute selection method resulted in the following order for humidity as the target variable of the greenhouse environment:(1)
Temperature(2)
Luminosity(3)
Soil moisture(4)
Intensity of light(5)
Concentration of CO2(6)
Ventilation activation(7)
Activation of the irrigation system(8)
Activation of heating systemBased on previous analyses comparing correlation coefficients and attribute selection, it is determined that the variables that most affect indoor relative humidity values within greenhouses are(i)
Temperature, which in turn relates to the values of luminosity and intensity of light(ii)
Concentration of CO2, which in turn relates to the actuators(iii)
Soil moisture, which, in turn, relates to activation of the irrigation system


## 4.2. Construction of the Models

Six proposed models were constructed using the Mamdani, Takagi–Sugeno (TS), and ANFIS fuzzy inference systems, along with their variation using C-means fuzzy clustering. They were optimized by a hybrid algorithm that combined the genetic and interior point algorithms. The current data and two shifts in time for temperature, CO2, and soil moisture were used as input for the prediction of humidity. For each of the inputs, the following input fuzzy sets were proposed:(i)
temp: current temperature(ii)
temp-1: temperature with one shift in time(iii)
temp-2: temperature with two shifts in time(iv)
co2_ppm: current CO2 concentration(v)
co2_ppm-1: concentration of CO2 with one shift in time(vi)
co2_ppm-2: CO2 concentration with two shifts in time(vii)
ground_humidity_per: current soil moisture(viii)
ground_humidity_per-1: soil moisture with one shift in time(ix)
ground_humidity_per-2: soil moisture with two shifts in timeThe models without fuzzy clustering, all Gaussian, were comprised by three membership functions representing the values of the variable: low, medium, and high. On the other hand, the inputs of the models with clustering were composed of five membership functions of the same type.The output fuzzy set conforms to five membership functions representing the values of the variable: very low, low, medium, high, and very high. Sugeno and ANFIS models are linear, and Mamdani models are triangular. For models with Mamdani-type fuzzy clustering, the output is composed of Gaussian-type membership functions. The range of values for system inputs and outputs is defined as follows:(i)
Temperature between 0.2 and 0.8(ii)
CO2concentration between 0.0 and 0.4(iii)
Soil moisture between 0.3 and 0.8(iv)
Humidity between 0.4 and 1.0The exploratory analysis defined the rules implemented in the models without fuzzy clustering as follows:(i)
If the historical and current temperature is high, the CO2 with two shifts is medium and the previous and current is low; if historical and current soil moisture is low, then humidity is very low.(ii)
If the temperature with two shifts is medium and the previous and current is high, the historical CO2 concentration is low and the current is medium; the soil moisture with two shifts is low and the previous and current is medium) then humidity is low.(iii)
If the historical and current temperature is medium, the historical and current CO2 is medium; if the historical and current soil moisture is medium, then the humidity is medium.(iv)
If the temperature with two shifts is medium and the previous and current is low, the historical CO2 concentration is high and the current is medium; the soil moisture with two shifts is high and the previous and current is medium, then humidity is high.(v)
If the historical and current temperature is low, the CO2 with two shifts is medium and the previous and current high; the historical and current soil moisture is high, then humidity is very high.


## 5. Measurement of the Error in Models

For the humidity predictive models, each of the six proposals was run 30 times. Table4 presents the maximum and minimum error values, MSE, RMSE, MAE, and arithmetic mean of the MSEs of the training and validation phases.Table 4
Error values for the runs of the predictive models.
Fuzzy inference systemTrainingValidationMSE¯MSERMSEMAEMINMAXMSERMSEMAEMINMAXSugeno clusterE11.100e − 21.049e − 11.000e − 304.317e − 11.360e − 21.165e − 11.600e − 303.341e − 11.230e − 2E21.270e − 21.129e − 11.000e − 304.584e − 18.100e − 39.020e − 21.300e − 302.950e − 11.040e − 2E31.040e − 21.020e − 19.000e − 404.145e − 12.350e − 21.533e − 12.100e − 303.753e − 11.695e − 2E41.590e − 21.263e − 11.100e − 304.239e − 14.300e − 36.530e − 29.000e − 41.000e − 41.677e − 11.010e − 2E51.300e − 21.139e − 11.000e − 304.561e − 11.430e − 21.194e − 11.700e − 34.000e − 42.995e − 11.365e − 2E61.480e − 21.215e − 11.100e − 304.416e − 11.060e − 21.028e − 11.400e − 302.765e − 11.270e − 2E71.110e − 21.055e − 11.000e − 303.886e − 13.190e − 21.785e − 12.500e − 304.569e − 12.150e − 2E81.070e − 21.036e − 19.000e − 404.124e − 11.090e − 21.044e − 11.400e − 303.214e − 11.080e − 2E91.530e − 21.236e − 11.100e − 304.316e − 14.000e − 36.360e − 29.000e − 402.038e − 19.650e − 3E101.970e − 21.402e − 11.300e − 304.503e − 14.500e − 36.700e − 29.000e − 401.711e − 11.210e − 2E119.700e − 39.850e − 29.000e − 404.315e − 11.260e − 21.122e − 11.600e − 303.662e − 11.115e − 2E121.520e − 21.235e − 11.100e − 304.362e − 16.300e − 37.910e − 21.100e − 302.229e − 11.075e − 2E131.320e − 21.148e − 11.000e − 303.739e − 15.000e − 37.050e − 21.000e − 301.926e − 19.100e − 3E141.160e − 21.077e − 11.000e − 304.429e − 11.830e − 21.352e − 11.900e − 303.317e − 11.495e − 2E151.400e − 21.183e − 11.100e − 304.276e − 15.300e − 37.310e − 21.000e − 31.000e − 41.981e − 19.650e − 3E161.070e − 21.036e − 19.000e − 404.124e − 11.090e − 21.044e − 11.400e − 303.214e − 11.080e − 2E171.530e − 21.236e − 11.100e − 304.316e − 14.000e − 36.360e − 29.000e − 402.038e − 19.650e − 3E181.970e − 21.403e − 11.300e − 304.501e − 14.500e − 36.700e − 29.000e − 401.711e − 11.210e − 2E191.630e − 21.275e − 11.200e − 304.397e − 13.000e − 35.460e − 28.000e − 402.087e − 19.650e − 3E202.190e − 21.478e − 11.300e − 31.000e − 44.582e − 15.200e − 37.230e − 21.000e − 31.000e − 41.834e − 11.355e − 2E211.360e − 21.168e − 11.100e − 304.878e − 11.210e − 21.101e − 11.500e − 31.000e − 43.100e − 11.285e − 2E221.550e − 21.244e − 11.100e − 304.048e − 13.400e − 35.870e − 28.000e − 401.786e − 19.450e − 3E231.070e − 21.036e − 19.000e − 404.124e − 11.090e − 21.044e − 11.400e − 303.214e − 11.080e − 2E241.530e − 21.236e − 11.100e − 304.339e − 14.000e − 36.360e − 29.000e − 402.036e − 19.650e − 3E252.170e − 21.474e − 11.300e − 305.521e − 15.400e − 37.350e − 21.000e − 31.000e − 42.030e − 11.355e − 2E261.590e − 21.263e − 11.100e − 304.141e − 14.400e − 36.610e − 29.000e − 41.000e − 41.844e − 11.015e − 2E271.320e − 21.147e − 11.000e − 304.252e − 11.080e − 21.039e − 11.400e − 302.698e − 11.200e − 2E281.770e − 21.331e − 11.200e − 304.012e − 13.700e − 36.060e − 28.000e − 401.871e − 11.070e − 2E293.120e − 21.768e − 11.600e − 31.000e − 47.802e − 11.450e − 21.204e − 11.700e − 31.000e − 43.917e − 12.285e − 2E301.290e − 21.136e − 11.000e − 304.138e − 12.280e − 21.511e − 12.100e − 303.323e − 11.785e − 2ANFIS clusterE16.100e − 37.790e − 27.000e − 406.470e − 11.050e − 21.027e − 11.400e − 304.111e − 18.300e − 3E25.600e − 37.460e − 27.000e − 404.342e − 11.680e − 21.298e − 11.800e − 304.751e − 11.120e − 2E36.100e − 37.790e − 27.000e − 404.315e − 11.870e − 21.368e − 11.900e − 304.372e − 11.240e − 2E46.100e − 37.790e − 27.000e − 403.998e − 11.100e − 21.049e − 11.500e − 304.178e − 18.550e − 3E55.900e − 37.660e − 27.000e − 404.452e − 11.100e − 21.049e − 11.500e − 303.883e − 18.450e − 3E64.600e − 36.790e − 26.000e − 404.256e − 17.900e − 38.900e − 21.200e − 302.911e − 16.250e − 3E75.800e − 37.600e − 27.000e − 404.272e − 17.800e − 38.830e − 21.200e − 303.416e − 16.800e − 3E85.600e − 37.500e − 27.000e − 404.336e − 11.160e − 21.078e − 11.500e − 31.000e − 47.310e − 18.600e − 3E96.300e − 37.970e − 27.000e − 403.821e − 11.260e − 21.124e − 11.600e − 31.000e − 42.833e − 19.450e − 3E107.000e − 38.380e − 28.000e − 404.151e − 11.200e − 21.095e − 11.500e − 304.375e − 19.500e − 3E115.200e − 37.220e − 27.000e − 404.385e − 14.540e − 22.130e − 13.000e − 308.493e − 12.530e − 2E125.700e − 37.520e − 27.000e − 404.056e − 11.410e − 21.189e − 11.700e − 302.603e − 19.900e − 3E136.000e − 37.760e − 27.000e − 404.095e − 16.500e − 38.090e − 21.100e − 303.411e − 16.250e − 3E145.700e − 37.560e − 27.000e − 404.278e − 11.340e − 21.156e − 11.600e − 304.251e − 19.550e − 3E155.900e − 37.700e − 27.000e − 404.005e − 11.420e − 21.193e − 11.700e − 303.434e − 11.005e − 2E165.600e − 37.500e − 27.000e − 404.336e − 11.160e − 21.078e − 11.500e − 31.000e − 47.310e − 18.600e − 3E176.300e − 37.970e − 27.000e − 403.821e − 11.260e − 21.124e − 11.600e − 31.000e − 42.833e − 19.450e − 3E189.000e − 39.490e − 29.000e − 403.945e − 11.580e − 21.257e − 11.700e − 31.000e − 47.014e − 11.240e − 2E197.200e − 38.490e − 28.000e − 405.573e − 11.520e − 21.233e − 11.700e − 303.020e − 11.120e − 2E201.130e − 21.064e − 11.000e − 306.001e − 12.200e − 21.482e − 12.100e − 308.480e − 11.665e − 2E216.600e − 38.120e − 27.000e − 404.247e − 11.250e − 21.119e − 11.600e − 303.823e − 19.550e − 3E224.800e − 36.900e − 26.000e − 404.267e − 11.010e − 21.005e − 11.400e − 305.780e − 17.450e − 3E235.600e − 37.500e − 27.000e − 404.336e − 11.160e − 21.078e − 11.500e − 31.000e − 47.310e − 18.600e − 3E246.300e − 37.970e − 27.000e − 403.821e − 11.260e − 21.124e − 11.600e − 31.000e − 42.833e − 19.450e − 3E256.700e − 38.160e − 27.000e − 404.835e − 11.310e − 21.144e − 11.600e − 304.612e − 19.900e − 3E265.200e − 37.220e − 27.000e − 404.213e − 14.300e − 36.570e − 29.000e − 403.418e − 14.750e − 3E276.400e − 38.000e − 27.000e − 404.291e − 19.400e − 39.670e − 21.300e − 304.154e − 17.900e − 3E286.000e − 37.720e − 27.000e − 404.082e − 11.120e − 21.060e − 11.500e − 304.952e − 18.600e − 3E296.700e − 38.200e − 27.000e − 404.291e − 18.400e − 39.150e − 21.300e − 303.695e − 17.550e − 3E305.800e − 37.610e − 27.000e − 404.731e − 14.900e − 36.980e − 21.000e − 303.455e − 15.350e − 3Mamdani clusterE11.390e − 21.180e − 11.100e − 303.823e − 18.800e − 39.370e − 21.300e − 32.000e − 42.321e − 11.135e − 2E21.440e − 21.201e − 11.100e − 304.019e − 17.300e − 38.570e − 21.200e − 302.874e − 11.085e − 2E31.250e − 21.116e − 11.000e − 304.105e − 18.500e − 39.220e − 21.300e − 34.000e − 42.874e − 11.050e − 2E41.210e − 21.102e − 11.000e − 304.316e − 15.800e − 37.610e − 21.100e − 32.000e − 42.218e − 18.950e − 3E51.300e − 21.139e − 11.000e − 31.000e − 44.158e − 15.700e − 37.550e − 21.000e − 302.263e − 19.350e − 3E61.580e − 21.256e − 11.100e − 303.907e − 17.400e − 38.620e − 21.200e − 36.000e − 42.934e − 11.160e − 2E71.230e − 21.107e − 11.000e − 304.668e − 16.300e − 37.950e − 21.100e − 302.711e − 19.300e − 3E81.260e − 21.123e − 11.000e − 304.215e − 16.100e − 37.800e − 21.100e − 302.048e − 19.350e − 3E91.210e − 21.100e − 11.000e − 304.349e − 17.500e − 38.630e − 21.200e − 302.355e − 19.800e − 3E101.210e − 21.100e − 11.000e − 304.328e − 17.600e − 38.700e − 21.200e − 302.874e − 19.850e − 3E111.670e − 21.293e − 11.200e − 303.843e − 16.600e − 38.150e − 21.100e − 31.000e − 42.299e − 11.165e − 2E121.190e − 21.089e − 11.000e − 304.239e − 15.000e − 37.090e − 21.000e − 302.756e − 18.450e − 3E131.190e − 21.092e − 11.000e − 304.119e − 18.200e − 39.060e − 21.300e − 302.551e − 11.005e − 2E141.210e − 21.099e − 11.000e − 304.222e − 17.100e − 38.400e − 21.200e − 302.716e − 19.600e − 3E151.180e − 21.087e − 11.000e − 304.321e − 17.700e − 38.760e − 21.200e − 302.423e − 19.750e − 3E161.470e − 21.213e − 11.100e − 304.006e − 15.700e − 37.540e − 21.000e − 31.000e − 42.299e − 11.020e − 2E171.310e − 21.146e − 11.000e − 304.185e − 15.900e − 37.650e − 21.100e − 302.180e − 19.500e − 3E181.200e − 21.096e − 11.000e − 304.345e − 17.400e − 38.590e − 21.200e − 31.000e − 42.389e − 19.700e − 3E191.230e − 21.108e − 11.000e − 304.190e − 17.400e − 38.600e − 21.200e − 302.812e − 19.850e − 3E201.170e − 21.081e − 11.000e − 304.263e − 18.300e − 39.090e − 21.300e − 302.874e − 11.000e − 2E211.220e − 21.105e − 11.000e − 304.260e − 17.000e − 38.370e − 21.200e − 302.556e − 19.600e − 3E221.300e − 21.140e − 11.000e − 304.176e − 15.800e − 37.650e − 21.100e − 302.263e − 19.400e − 3E231.240e − 21.115e − 11.000e − 304.181e − 17.200e − 38.500e − 21.200e − 302.767e − 19.800e − 3E241.300e − 21.139e − 11.000e − 304.134e − 15.600e − 37.490e − 21.000e − 302.263e − 19.300e − 3E251.210e − 21.098e − 11.000e − 304.345e − 16.000e − 37.780e − 21.100e − 33.000e − 42.934e − 19.050e − 3E261.490e − 21.221e − 11.100e − 304.049e − 15.400e − 37.350e − 21.000e − 31.000e − 42.299e − 11.015e − 2E271.220e − 21.104e − 11.000e − 304.263e − 16.900e − 38.320e − 21.200e − 302.268e − 19.550e − 3E281.190e − 21.089e − 11.000e − 304.286e − 18.000e − 38.970e − 21.200e − 302.874e − 19.950e − 3E291.220e − 21.107e − 11.000e − 304.325e − 15.400e − 37.360e − 21.000e − 302.874e − 18.800e − 3E301.220e − 21.103e − 11.000e − 303.906e − 16.200e − 37.850e − 21.100e − 302.934e − 19.200e − 3SugenoE11.440e − 21.199e − 11.100e − 31.000e − 45.404e − 15.600e − 37.480e − 21.000e − 304.038e − 11.000e − 2E21.410e − 21.185e − 11.100e − 307.422e − 17.300e − 38.540e − 21.200e − 31.000e − 44.235e − 11.070e − 2E33.710e − 21.926e − 11.700e − 308.781e − 13.300e − 21.817e − 12.500e − 31.000e − 44.450e − 13.505e − 2E41.380e − 21.177e − 11.100e − 307.526e − 17.400e − 38.570e − 21.200e − 303.190e − 11.060e − 2E52.630e − 21.621e − 11.500e − 31.000e − 46.490e − 12.380e − 21.544e − 12.100e − 32.000e − 42.735e − 12.505e − 2E62.190e − 21.480e − 11.300e − 305.430e − 11.600e − 21.263e − 11.800e − 302.630e − 11.895e − 2E72.270e − 21.505e − 11.400e − 304.939e − 11.150e − 21.073e − 11.500e − 32.000e − 42.760e − 11.710e − 2E81.440e − 21.199e − 11.100e − 31.000e − 45.404e − 15.600e − 37.480e − 21.000e − 304.038e − 11.000e − 2E91.410e − 21.185e − 11.100e − 307.422e − 17.300e − 38.540e − 21.200e − 31.000e − 44.235e − 11.070e − 2E103.710e − 21.926e − 11.700e − 308.781e − 13.300e − 21.817e − 12.500e − 31.000e − 44.450e − 13.505e − 2E111.380e − 21.177e − 11.100e − 307.526e − 17.400e − 38.570e − 21.200e − 303.190e − 11.060e − 2E122.630e − 21.621e − 11.500e − 31.000e − 46.490e − 12.380e − 21.544e − 12.100e − 32.000e − 42.735e − 12.505e − 2E132.190e − 21.480e − 11.300e − 305.430e − 11.600e − 21.263e − 11.800e − 302.630e − 11.895e − 2E141.590e − 21.260e − 11.100e − 304.849e − 13.400e − 35.840e − 28.000e − 403.523e − 19.650e − 3E152.440e − 21.563e − 11.400e − 301.0251.370e − 21.171e − 11.600e − 303.429e − 11.905e − 2E161.440e − 21.199e − 11.100e − 31.000e − 45.404e − 15.600e − 37.480e − 21.000e − 304.038e − 11.000e − 2E171.410e − 21.185e − 11.100e − 307.422e − 17.300e − 38.540e − 21.200e − 31.000e − 44.235e − 11.070e − 2E183.710e − 21.926e − 11.700e − 308.781e − 13.300e − 21.817e − 12.500e − 31.000e − 44.450e − 13.505e − 2E191.370e − 21.173e − 11.100e − 308.274e − 16.600e − 38.150e − 21.100e − 33.000e − 42.699e − 11.015e − 2E201.320e − 21.147e − 11.000e − 306.574e − 11.100e − 21.049e − 11.500e − 31.000e − 42.720e − 11.210e − 2E211.310e − 21.146e − 11.000e − 307.139e − 15.700e − 37.520e − 21.000e − 31.000e − 43.258e − 19.400e − 3E223.330e − 21.825e − 11.700e − 307.276e − 14.300e − 22.074e − 12.900e − 31.000e − 44.596e − 13.815e − 2E231.600e − 21.267e − 11.200e − 305.921e − 13.000e − 35.470e − 28.000e − 402.554e − 19.500e − 3E241.420e − 21.190e − 11.100e − 306.453e − 15.300e − 37.290e − 21.000e − 303.736e − 19.750e − 3E251.450e − 21.203e − 11.100e − 307.968e − 17.700e − 38.800e − 21.200e − 303.432e − 11.110e − 2E263.140e − 21.772e − 11.600e − 307.730e − 13.050e − 21.748e − 12.400e − 303.733e − 13.095e − 2E273.230e − 21.797e − 11.600e − 308.779e − 13.600e − 21.896e − 12.600e − 32.000e − 44.436e − 13.415e − 2E282.020e − 21.422e − 11.300e − 306.508e − 19.800e − 39.900e − 21.400e − 32.000e − 42.504e − 11.500e − 2E291.270e − 21.128e − 11.000e − 305.114e − 12.320e − 21.522e − 12.100e − 305.471e − 11.795e − 2E302.230e − 21.495e − 11.400e − 301.5331.450e − 21.202e − 11.700e − 33.000e − 42.531e − 11.840e − 2ANFISE15.800e − 37.630e − 27.000e − 404.805e − 19.600e − 39.790e − 21.400e − 304.916e − 17.700e − 3E26.300e − 37.930e − 27.000e − 404.233e − 11.460e − 21.209e − 11.700e − 304.356e − 11.045e − 2E36.600e − 38.140e − 27.000e − 404.779e − 11.050e − 21.025e − 11.400e − 31.000e − 43.850e − 18.550e − 3E45.900e − 37.710e − 27.000e − 404.204e − 19.200e − 39.600e − 21.300e − 303.447e − 17.550e − 3E55.900e − 37.670e − 27.000e − 404.267e − 12.060e − 21.437e − 12.000e − 304.528e − 11.325e − 2E66.200e − 37.900e − 27.000e − 404.602e − 11.630e − 21.276e − 11.800e − 31.000e − 44.401e − 11.125e − 2E77.700e − 38.750e − 28.000e − 406.428e − 11.040e − 21.020e − 11.400e − 301.9739.050e − 3E85.800e − 37.630e − 27.000e − 404.805e − 19.600e − 39.790e − 21.400e − 304.916e − 17.700e − 3E96.300e − 37.930e − 27.000e − 404.233e − 11.460e − 21.209e − 11.700e − 304.356e − 11.045e − 2E106.600e − 38.140e − 27.000e − 404.779e − 11.050e − 21.025e − 11.400e − 31.000e − 43.850e − 18.550e − 3E115.900e − 37.710e − 27.000e − 404.204e − 19.200e − 39.600e − 21.300e − 303.447e − 17.550e − 3E125.900e − 37.670e − 27.000e − 404.267e − 12.060e − 21.437e − 12.000e − 304.528e − 11.325e − 2E136.200e − 37.900e − 27.000e − 404.602e − 11.630e − 21.276e − 11.800e − 31.000e − 44.401e − 11.125e − 2E146.100e − 37.800e − 27.000e − 403.892e − 11.210e − 21.098e − 11.500e − 305.189e − 19.100e − 3E157.400e − 38.570e − 28.000e − 404.765e − 11.030e − 21.016e − 11.400e − 303.246e − 18.850e − 3E165.800e − 37.630e − 27.000e − 404.805e − 19.600e − 39.790e − 21.400e − 304.916e − 17.700e − 3E176.300e − 37.930e − 27.000e − 404.233e − 11.460e − 21.209e − 11.700e − 304.356e − 11.045e − 2E186.600e − 38.140e − 27.000e − 404.779e − 11.050e − 21.025e − 11.400e − 31.000e − 43.850e − 18.550e − 3E195.700e − 37.540e − 27.000e − 405.253e − 11.350e − 21.163e − 11.600e − 303.970e − 19.600e − 3E206.000e − 37.720e − 27.000e − 404.289e − 14.400e − 36.630e − 29.000e − 404.331e − 15.200e − 3E215.800e − 37.640e − 27.000e − 404.796e − 11.300e − 21.141e − 11.600e − 303.546e − 19.400e − 3E226.400e − 38.030e − 27.000e − 404.255e − 19.400e − 39.710e − 21.300e − 304.152e − 17.900e − 3E235.900e − 37.680e − 27.000e − 404.113e − 11.600e − 21.265e − 11.800e − 303.894e − 11.095e − 2E245.100e − 37.150e − 26.000e − 404.074e − 18.700e − 39.340e − 21.300e − 303.482e − 16.900e − 3E256.000e − 37.770e − 27.000e − 404.473e − 12.520e − 21.587e − 12.200e − 301.0221.560e − 2E266.800e − 38.220e − 27.000e − 407.388e − 11.060e − 21.029e − 11.400e − 306.182e − 18.700e − 3E277.300e − 38.530e − 28.000e − 404.120e − 11.290e − 21.134e − 11.600e − 305.387e − 11.010e − 2E286.200e − 37.900e − 27.000e − 405.990e − 11.410e − 21.186e − 11.600e − 31.000e − 44.475e − 11.015e − 2E296.000e − 37.720e − 27.000e − 406.191e − 18.900e − 39.460e − 21.300e − 307.285e − 17.450e − 3E306.400e − 37.990e − 27.000e − 407.983e − 18.400e − 39.180e − 21.300e − 303.319e − 17.400e − 3MamdaniE11.260e − 21.121e − 11.000e − 31.000e − 44.457e − 15.900e − 37.710e − 21.100e − 302.925e − 19.250e − 3E21.020e − 21.008e − 19.000e − 44.000e − 44.474e − 11.060e − 21.032e − 11.400e − 31.000e − 44.095e − 11.040e − 2E31.060e − 21.032e − 19.000e − 404.760e − 18.900e − 39.440e − 21.300e − 32.000e − 43.095e − 19.750e − 3E41.130e − 21.065e − 11.000e − 304.353e − 19.300e − 39.640e − 21.300e − 31.000e − 43.226e − 11.030e − 2E59.300e − 39.630e − 29.000e − 41.000e − 45.068e − 17.100e − 38.430e − 21.200e − 302.516e − 18.200e − 3E61.080e − 21.038e − 19.000e − 405.431e − 13.730e − 21.932e − 12.700e − 32.000e − 45.414e − 12.405e − 2E71.010e − 21.004e − 19.000e − 404.932e − 17.600e − 38.700e − 21.200e − 32.000e − 43.735e − 18.850e − 3E81.260e − 21.121e − 11.000e − 31.000e − 44.457e − 15.900e − 37.710e − 21.100e − 302.925e − 19.250e − 3E91.020e − 21.008e − 19.000e − 44.000e − 44.474e − 11.060e − 21.032e − 11.400e − 31.000e − 44.095e − 11.040e − 2E101.060e − 21.032e − 19.000e − 404.760e − 18.900e − 39.440e − 21.300e − 32.000e − 43.095e − 19.750e − 3E111.130e − 21.065e − 11.000e − 304.353e − 19.300e − 39.640e − 21.300e − 31.000e − 43.226e − 11.030e − 2E129.300e − 39.630e − 29.000e − 41.000e − 45.068e − 17.100e − 38.430e − 21.200e − 302.516e − 18.200e − 3E131.080e − 21.038e − 19.000e − 405.431e − 13.730e − 21.932e − 12.700e − 32.000e − 45.414e − 12.405e − 2E141.010e − 21.004e − 19.000e − 404.932e − 17.600e − 38.700e − 21.200e − 32.000e − 43.735e − 18.850e − 3E151.060e − 21.030e − 19.000e − 41.000e − 44.650e − 19.900e − 39.950e − 21.400e − 32.000e − 44.870e − 11.025e − 2E161.260e − 21.121e − 11.000e − 31.000e − 44.457e − 15.900e − 37.710e − 21.100e − 302.925e − 19.250e − 3E171.020e − 21.008e − 19.000e − 43.000e − 44.474e − 11.070e − 21.033e − 11.400e − 31.000e − 44.095e − 11.045e − 2E181.090e − 21.042e − 19.000e − 404.405e − 19.200e − 39.570e − 21.300e − 33.000e − 44.044e − 11.005e − 2E191.080e − 21.037e − 19.000e − 41.000e − 44.450e − 19.500e − 39.730e − 21.400e − 31.000e − 43.174e − 11.015e − 2E201.160e − 21.077e − 11.000e − 306.269e − 18.600e − 39.260e − 21.300e − 32.000e − 44.455e − 11.010e − 2E219.900e − 39.950e − 29.000e − 404.951e − 18.900e − 39.430e − 21.300e − 32.000e − 45.101e − 19.400e − 3E221.000e − 21.002e − 19.000e − 404.415e − 19.900e − 39.940e − 21.400e − 31.000e − 43.294e − 19.950e − 3E231.260e − 21.121e − 11.000e − 31.000e − 44.457e − 15.900e − 37.710e − 21.100e − 302.925e − 19.250e − 3E241.020e − 21.008e − 19.000e − 44.000e − 44.474e − 11.060e − 21.032e − 11.400e − 31.000e − 44.095e − 11.040e − 2E251.060e − 21.032e − 19.000e − 404.760e − 18.900e − 39.440e − 21.300e − 32.000e − 43.095e − 19.750e − 3E261.130e − 21.065e − 11.000e − 304.353e − 19.300e − 39.640e − 21.300e − 31.000e − 43.226e − 11.030e − 2E279.300e − 39.630e − 29.000e − 41.000e − 45.068e − 17.100e − 38.430e − 21.200e − 302.516e − 18.200e − 3E281.080e − 21.038e − 19.000e − 405.431e − 13.730e − 21.932e − 12.700e − 32.000e − 45.414e − 12.405e − 2E291.010e − 21.004e − 19.000e − 404.932e − 17.600e − 38.700e − 21.200e − 32.000e − 43.735e − 18.850e − 3E301.060e − 21.030e − 19.000e − 41.000e − 44.650e − 19.900e − 39.950e − 21.400e − 32.000e − 44.870e − 11.025e − 2The implemented model is related to the run that presents the best level of precision for each of the six proposals, resulting as follows:(i)
Sugeno with fuzzy clustering, run 13 with anMSE of 9.10e − 3.(ii)
ANFIS with fuzzy clustering, run 26 with anMSE of 4.75e − 3.(iii)
Mamdani with fuzzy clustering, run 12 with anMSE of 8.45e − 3.(iv)
Sugeno, run 21 with anMSE of 9.40e − 3.(v)
ANFIS, run 20 with anMSE of 5.20e − 3.(vi)
Mamdani, run 5, 12, or 27 with anMSE of 8.20e − 3.The arithmetic means of the error values for the six proposed models are shown in Table5, where the lowest errors are presented in the ANFIS models.Table 5
Mean error values for the runs of the predictive models.
Fuzzy inference systemTrainingValidationMSE¯RMSE¯MAE¯MIN¯MAX¯MSE¯RMSE¯MAE¯MIN¯MAX¯Sugeno cluster1.500e − 21.213e − 11.090e − 36.667e − 64.446e − 19.760e − 39.351e − 21.293e − 33.667e − 52.628e − 1ANFIS cluster6.237e − 37.866e − 27.167e − 404.401e − 11.296e − 21.109e − 11.550e − 32.333e − 54.567e − 1Mamdani cluster1.284e − 21.132e − 11.023e − 33.333e − 64.185e − 16.793e − 38.220e − 21.147e − 37.000e − 52.560e − 1Sugeno2.069e − 21.413e − 11.283e − 31.667e − 57.227e − 11.523e − 21.154e − 11.597e − 38.333e − 53.555e − 1ANFIS6.230e − 37.889e − 27.067e − 404.854e − 11.247e − 21.102e − 11.530e − 32.000e − 55.084e − 1Mamdani1.073e − 21.035e − 19.267e − 48.333e − 54.772e − 11.142e − 21.022e − 11.420e − 31.267e − 43.728e − 1The values obtained in the training phase based on the prediction of each of the models with respect to the real values are shown in Figure2, on the abscissa, the time period between May 24 and July 22, 2021, and on the ordinate, the relative humidity values in percentage (%).Figure 2
Comparison of real values and predictive models in the training phase.The comparison of the values obtained from the prediction of the models and the real values in the validation phase is shown in Figure3, obtaining homogeneous results in each model with a high degree of precision.Figure 3
Real values compared to predictive models in the validation phase.TheMSE obtained in each of the models for the training phase is shown in Figure 4, obtaining the error between the predicted moisture data and the real values, where the abscissa corresponds to time and the ordinate corresponds to error.Figure 4
Real error values compared to those of the predictive models in the training phase.Similarly, theMSE obtained in the models for the validation phase is shown in Figure 5, obtaining the error between the predicted moisture data and the real values.Figure 5
Real error values compared to those of the predictive models in the validation phase.


### 5.1. Model Selection

To select of the model to be implemented, each of the six proposals is related as shown in Table6, indicating the MSE of the best iteration, the mean MSE of all iterations, and the precision value for both columns, and an interpretability value for the specific type of model is calculated, thus obtaining the ranking of the model and choosing the one with the highest value.Table 6
Accuracy and interpretability analysis for predictive models.
Fuzzy inference systemBestMSEPrecision 1MSE¯Precision 2Precisión¯InterpretationRankingSugeno cluster9.100e − 32.01.238e − 22.02.03.05.0ANFIS cluster4.750e − 36.09.598e − 35.05.51.06.5Mamdani cluster8.450e − 33.09.815e − 34.03.55.08.5Sugeno9.400e − 31.01.796e − 21.01.04.05.0ANFIS5.200e − 35.09.352e − 36.05.52.07.5Mamdani8.200e − 34.01.108e − 23.03.56.09.5The model selected for relative humidity prediction is run 5 of the Mamdani-type fuzzy inference system, optimized by a hybrid method using genetic and interior point algorithms.The temperature input of the model is shown in Figure6, where the current temperature value input set corresponds to Figure 6(a), that with one shift corresponds to Figure 6(b), and that with two shifts corresponds to Figure 6(c).Figure 6
Temperature fuzzy sets: (a) fuzzy set at current time; (b) fuzzy set with one shift in time; (c) fuzzy set with two shifts in time.
(a)(b)(c)The CO2 concentration value input set corresponds to Figure 7, where the current temperature value input set corresponds to Figure 7(a), that with one shift corresponds to Figure 7(b), and that with two shifts corresponds to Figure 7(c).Figure 7
Fuzzy sets of CO2: (a) fuzzy set at the current time; (b) fuzzy set with one shift in time; (c) fuzzy set with two shifts in time.
(a)(b)(c)The soil moisture input is shown in Figure8, where the current soil moisture value input set corresponds to Figure 8(a), that with one shift corresponds to Figure 8(b), and that with two shifts corresponds to Figure 8(c).Figure 8
Soil moisture fuzzy sets: (a) fuzzy set at current time; (b) fuzzy set with one shift in time; (c) fuzzy set with two shifts in time.
(a)(b)(c)The output of the model, indoor relative humidity, is shown in Figure9, where the initial structures of the very low, low, medium, high, and very high inputs are maintained, adjusting the values of their membership functions.Figure 9
Fuzzy sets of relative humidity.The ruled surface that reflects the behaviour of the rules through the sample space for the input and output variables is shown in Figure10. The three components are specified at the current times where it is shown. The surface formed by the entries temp and co2_ppm for the output variable is shown in Figure 10(a), the surface formed by temp and ground_humidity_per with the output variable in Figure 10(b), and the surface formed by co2_ppm and ground_humidity_per with the output variable in Figure 10(c).Figure 10
Ruled surface: (a) ruled surface with one and two shifts in time; (b) ruled surface with one and three shifts in time; (c) ruled surface with two and three shifts in time.
(a)(b)(c)A two-samplet-test is performed, using the real data with those generated by the model, taking into account that α=0.05, and the test produces a pvalue=0.1740, and since the pvalue is greater than α, the null hypothesis is not denied. Therefore, both come from samples with equal means and variances, where the test yields a possible variance value of 0.1301. Furthermore, taking into account the RMSE of the run 9.03e − 2, the effectiveness percentage is obtained with a value of 90.97% for this model.


## 5.1. Model Selection

To select of the model to be implemented, each of the six proposals is related as shown in Table6, indicating the MSE of the best iteration, the mean MSE of all iterations, and the precision value for both columns, and an interpretability value for the specific type of model is calculated, thus obtaining the ranking of the model and choosing the one with the highest value.Table 6
Accuracy and interpretability analysis for predictive models.
Fuzzy inference systemBestMSEPrecision 1MSE¯Precision 2Precisión¯InterpretationRankingSugeno cluster9.100e − 32.01.238e − 22.02.03.05.0ANFIS cluster4.750e − 36.09.598e − 35.05.51.06.5Mamdani cluster8.450e − 33.09.815e − 34.03.55.08.5Sugeno9.400e − 31.01.796e − 21.01.04.05.0ANFIS5.200e − 35.09.352e − 36.05.52.07.5Mamdani8.200e − 34.01.108e − 23.03.56.09.5The model selected for relative humidity prediction is run 5 of the Mamdani-type fuzzy inference system, optimized by a hybrid method using genetic and interior point algorithms.The temperature input of the model is shown in Figure6, where the current temperature value input set corresponds to Figure 6(a), that with one shift corresponds to Figure 6(b), and that with two shifts corresponds to Figure 6(c).Figure 6
Temperature fuzzy sets: (a) fuzzy set at current time; (b) fuzzy set with one shift in time; (c) fuzzy set with two shifts in time.
(a)(b)(c)The CO2 concentration value input set corresponds to Figure 7, where the current temperature value input set corresponds to Figure 7(a), that with one shift corresponds to Figure 7(b), and that with two shifts corresponds to Figure 7(c).Figure 7
Fuzzy sets of CO2: (a) fuzzy set at the current time; (b) fuzzy set with one shift in time; (c) fuzzy set with two shifts in time.
(a)(b)(c)The soil moisture input is shown in Figure8, where the current soil moisture value input set corresponds to Figure 8(a), that with one shift corresponds to Figure 8(b), and that with two shifts corresponds to Figure 8(c).Figure 8
Soil moisture fuzzy sets: (a) fuzzy set at current time; (b) fuzzy set with one shift in time; (c) fuzzy set with two shifts in time.
(a)(b)(c)The output of the model, indoor relative humidity, is shown in Figure9, where the initial structures of the very low, low, medium, high, and very high inputs are maintained, adjusting the values of their membership functions.Figure 9
Fuzzy sets of relative humidity.The ruled surface that reflects the behaviour of the rules through the sample space for the input and output variables is shown in Figure10. The three components are specified at the current times where it is shown. The surface formed by the entries temp and co2_ppm for the output variable is shown in Figure 10(a), the surface formed by temp and ground_humidity_per with the output variable in Figure 10(b), and the surface formed by co2_ppm and ground_humidity_per with the output variable in Figure 10(c).Figure 10
Ruled surface: (a) ruled surface with one and two shifts in time; (b) ruled surface with one and three shifts in time; (c) ruled surface with two and three shifts in time.
(a)(b)(c)A two-samplet-test is performed, using the real data with those generated by the model, taking into account that α=0.05, and the test produces a pvalue=0.1740, and since the pvalue is greater than α, the null hypothesis is not denied. Therefore, both come from samples with equal means and variances, where the test yields a possible variance value of 0.1301. Furthermore, taking into account the RMSE of the run 9.03e − 2, the effectiveness percentage is obtained with a value of 90.97% for this model.


## 6. Discussion

Based on correlated variables and Mamdani fuzzy inference systems, the model used enabled a highly interpretable approach that allows users with no specialised knowledge in mathematical representations to interpret the behaviour of indoor humidity, facilitating monitoring and control of the variable in the development of greenhouse crops.The models obtained have high levels of precision, without affecting their interpretability, optimized by a hybrid method that combines genetic and interior point algorithms.A comparison is made with other greenhouse internal humidity prediction models, as shown in Table7, comparing their MSE values obtained in other studies, showing that the developed model presents the highest accuracy value with an MSE value of 8.2e − 3. It is also evident that the use of fuzzy inference systems does not significantly affect the accuracy value compared to the use of other accuracy-focused techniques such as neural networks or deep learning techniques.Table 7
Comparison with other prediction models.
ResearchMain techniqueMSE[33]Fuzzy inference system4.014e − 1[27]Fuzzy inference system1.200e − 2[34]Fuzzy inference system9.722e − 1[35]Multiple linear regressionARIMAMLP feed-forward network5.766e + 15.496e + 13.973e + 1[36]CNN and GRU network7.458e + 0[37]RNN-LSTM8.237e + 0Mamdani fuzzy model developed8.200e − 3It must be taken into account that the models are designed to consider the variables of indoor relative humidity, indoor temperature, soil moisture, light intensity, CO2, luminosity, and the activation of ventilation system, irrigation system, and heating system. If it is necessary to add another actor or sensor, the correlation between the variables must be analyzed and it must be verified if the model could be implemented without modifications. In addition, if it is necessary to improve the precision with a specific crop, the model can be trained again, maintaining the same configuration and structure in the fuzzy inference systems.The developed models can be used for the management of automated greenhouses, implementing fuzzy controllers or predictive controllers based on models. Similarly, to increase the levels of precision while maintaining interpretability, a network of fuzzy inference systems can be created by combining different model proposals developed in this study. However, due to the seasonal behaviour of humidity, ways can be investigated to guarantee a more precise model behaviour, either through combinations of various training methods for fuzzy inference systems and recurrent neural networks or through the development of an automatic adjustment of the models based on the error trend and a set ofn historical data.


## 7. Conclusions

The six different configurations established resulted in a high level of interpretability and a high degree of precision, using a predictive model of indoor relative humidity in greenhouses based on correlated variables, through a Mamdani fuzzy inference system with an effectiveness percentage of 90.97% and anMSE value of 8.2e − 3.For the prediction of indoor humidity in greenhouses, the use of fuzzy inference system configurations that implement optimization through a hybrid method made up of a genetic algorithm and an interior point algorithm significantly increases the degree of accuracy of the models, without affecting their level of interpretability.



---

*Source: 4764919-2023-01-06.xml*