Fuzzy Control System for Smart Energy Management in Residential Buildings Based on Environmental Data

: Modern energy automation solutions and demand response applications rely on load proﬁles to monitor and manage electricity consumption effectively. The introduction of smart control systems capable of handling additional fuzzy parameters, such as weather data, through machine learning methods, offers valuable insights in an attempt to adjust consumer behavior optimally. Following recent advances in the ﬁeld of fuzzy control, this study presents the design and implementation of a fuzzy control system that processes environmental data in order to recommend minimum energy consumption values for a residential building. This system follows the forward chaining Mamdani approach and uses decision tree linearization for rule generation. Additionally, a hybrid feature selector is implemented based on XGBoost and decision tree metrics for feature importance. The proposed structure discovers and generates a small set of fuzzy rules that highlights the energy consumption behavior of the building based on time-series data of past operation. The response of the fuzzy system based on sample input data is presented, and the evaluation of its performance shows that the rule base generation is derived with improved accuracy. In addition, an overall smaller set of rules is generated, and the computation is faster compared to the baseline decision tree conﬁguration.


Introduction
Modern energy applications often use load profiles resulting from time-series data of electricity usage to monitor and manage the power consumption of customers efficiently and reliably [1]. In an attempt to maintain the balance between power supply and demand, energy consumption patterns are further processed and as a result, a plethora of models aiming at the adjustment of customer behavior are developed. The insights extracted from the energy data convey more interpretable trends and patterns, which can be used by the energy provider as a management tool for the control of distribution and pricing. Additionally, the output of such models can be useful to customers as a recommendation engine, helping them make more informed decisions and reschedule their daily tasks when opportunities arise for them to participate in more dynamic pricing plans [2]. In the past, simpler prediction and recommendation models were linear and faced many challenges such as data dimensionality, trend detection, and uncertainty. Since the study of residential and industrial environments requires a more detailed definition of all the variables that contribute toward energy consumption, the energy datasets used in modern applications often contain many important measurements ranging from appliance consumption values to weather parameters. Consequently, the dimensions of the inputs and outputs grow, and this could hinder the computational performance of more traditional models, rendering the resulting energy applications less efficient [3]. Furthermore, linear models sometimes fail to capture the trends that can be observed from the data, and the mathematical models used to describe them do not express the dynamic and complex nature of those environments as they evolve over time. Hence, linear forecasting models and decision-making applications yield less accurate and suboptimal results, respectively [4]. Moreover, many input parameters used to define those environments often have a more imprecise and uncertain meaning that is often associated with human perception and expert knowledge. Therefore, it is difficult to fit those crisp values in a strict mathematical model without further interpretation and achieve decent performance [5].
Solutions to some of the challenges mentioned above can be found in the fields of machine learning and fuzzy logic. Traditional machine learning methods, such as decision tree classification, are capable of achieving highly accurate and interpretable results, while more advanced techniques such as artificial neural networks preserve the complex and dynamic nature of those environments and assist in constructing more adaptive models with impressive performance. Fuzzy logic methods tackle the challenges of uncertainty and partial truth in decision-making systems, since the environments are processed in a more interpretable way with the introduction of linguistic terms that express the vagueness of human perception for input and output parameters. Since fuzzy systems are defined by sets of rules that are close to real world expert rules, decision-making models based on fuzzy logic are popular due to their computational efficiency and overall simplicity [6]. The main practical advantages of using fuzzy theory can be observed from several successful Enterprise Resource Planning (ERP) and power system control applications. Fuzzy logic can handle the ambiguities and vagueness of qualitative factors covered by ERP software [7]. Additionally, the stability problems of multi-area interconnected power systems caused by nonlinearities can be resolved through fuzzy logic approaches by approximating nonlinear models into linear sub-models [8]. Hybrid techniques utilizing concepts from both fields such as fuzzy neural networks are proven valuable in the development of robust energy applications due to their adaptability and their black-box behavior [9].
However, it is worth mentioning that there are still questions, challenges, and research gaps that arise with the evolution of those fields. Firstly, the challenge of dimensionality is a recurring threat to the performance and interpretability of those applications and design philosophies around feature engineering should be applied in order to isolate the features that are more relevant and important in a particular environment. In general, modern energy applications based on those models need to yield results within specific time intervals with the upper limit being the time that new data would normally be measured by smart meters in order to be considered relevant and acceptable. Therefore, systems using highly dimensional input data could yield slower performance outside of the acceptable time intervals. Secondly, there is a level of ambiguity that surrounds the design process of each energy application, which is mostly related to the available knowledge and information about the environment as well as the intended behavior of the finalized model. For example, residential environments could be clustered together, and available expert knowledge could extract a more generalized set of rules that is applicable to that group but on an individual basis, expert knowledge could not always be readily available, and the historical data as well as the behavior of each occupant could be more important in the extraction of meaningful rules. Additionally, fuzzy logic models and machine learning models often need to be retrained to reflect major changes in some vital parameters such as occupancy and number of appliances. Since the environments evolve over time, respective models need to adapt to the new data easily, because decisions and recommendations based on outdated rules could hinder customer satisfaction.
A thorough examination of the literature shows that there exists relevant research work highlighting aspects of fuzzy logic and machine learning in the development of systems that offer optimizations, management solutions, and forecasting potential in the energy sector. In 2008, Azadeh et al. [10] presented a framework that combines fuzzy logic and a data mining approach in order to predict electricity demand. In their work, they briefly outline different methods of rule extraction from decision trees and offer other meaningful comparisons of their work with modern machine learning methods such as artificial neural networks. The same year, Lau et al. [11] presented a case study of a fuzzy logic forecasting system in a clothing manufacturing plant, drawing optimal strategies for efficient energy consumption forecasts in that environment. In 2015, Suganthi et al. [12] published a useful review of fuzzy logic applications in renewable energy systems and concluded that these models provide realistic estimates. In 2017, Emagbetere et al. [13] developed a fuzzy prediction system for power consumption forecasts following the Mamdani approach. Their system utilized a small set of predefined rules, and their work offered a concise error comparison between different membership functions. Javaid et al. [14] used Mamdani and Sugeno fuzzy systems in order to evaluate their adaptive thermostat. In their work, the simplicity and flexibility of fuzzy inference systems is highlighted. Zhang et al. [15] presented a fuzzy forecasting method utilizing historical data found in time series through link prediction. Furthermore, Bissey et al. [16] developed a fuzzy logic method for the optimization of electricity consumption in an individual residential environment, thus allowing for the better management of appliances and for the flexibility to reshape the load profile should that be desirable. This work is particularly important for our project, since it shares a similar scope. In 2018, Krishna et al. [17] proposed a smart home energy management system based on fuzzy logic with a hardware implementation that renders it ready for installation and deployment. The impact of fuzzy reasoning on energy applications developed for residential environments can be clearly seen in the work of Nebot and Mugica [18], published in 2020, where a side-by-side comparison of two fuzzy logic methodologies shows the importance of feature selection and correct identification of the most relevant building parameters.
Machine learning and fuzzy logic methods are strongly interrelated, and relevant research on the field reinforces the notion that one approach can benefit from the integration of the other. Sophisticated machine learning methods such as neural networks follow a data-driven modeling approach that utilizes a numerical representation in order to prepare the data for relationship induction and model inference. Since relationships between data points are often presented as complex computational graphs, the interpretability and flexibility of those models is poor due to the lack of a human-machine interface. Therefore, it is easy to understand that machine learning succeeds in the statistical induction of models from observations and data, but there are considerable difficulties when attempting to derive conclusions from premises, models, and assumptions. Fuzzy logic extends existing machine learning models through concepts, tools, and techniques that introduce knowledge-based design elements and a symbolic representation of data that is more interpretable. As a result, the logical deduction of conclusions is a significant contribution of fuzzy logic to machine learning methods. Additionally, fuzzy systems can be significantly improved with the integration of data-driven approaches. The development and implementation of machine learning methods in state-of-the-art fuzzy systems could address the potential sparsity of expert knowledge. Furthermore, the insights and data processing techniques used in machine learning models could lead to the generation of smaller and more accurate sets of rules while enabling future changes as the data evolves without the continuous supervision of an expert [19].
In this study, we focus on fuzzy control systems for individual residential environments without the contribution of expert knowledge. We believe that many interesting design approaches can be discussed in an attempt to tackle the challenges mentioned in order to develop intelligent systems that merge aspects of fuzzy logic and machine learning effectively. The main purpose of this work is to present the design and implementation process of a fuzzy energy system for an individual residential environment; the system discovers and generates rules based on a decision tree model that integrates a hybrid feature selection method for the choice of the most important linguistic variables. The proposed system should be viewed as a contribution to the development of intelligent decision-making, recommendation, and management tools in the energy sector, since the expected output denotes the optimal energy consumption value based on environmental parameters such as weather data. This system could be integrated into client-side appli- cations in order to derive recommendations that could help reschedule the daily tasks of consumers and minimize energy consumption within short intervals. Additionally, electricity providers could utilize this system as a secondary management and control tool for regulation and electricity pricing in more customizable and dynamic models that apply to individual customers indirectly. Classification methods and load profile monitoring could be powerful tools that contribute toward the creation of electricity plans, but the realization that these plans are usually formed from generalized consumer patterns greatly reinforces the need of having localized models that could help the adjustment of those existing plans at a greater detail in an attempt to increase customer satisfaction and plan flexibility. To the best of our knowledge, the combination of machine learning methods and feature engineering techniques explored in this paper has not been discussed before in the context of individual energy consumption recommendations without the availability of expert knowledge. Therefore, we believe that our project presents a novel and intuitive fuzzy system structure that addresses the challenges and the complexity of the residential environment while maintaining simplicity. Section 2 presents a concise overview of the design process used in the development of a fuzzy control system, and the core structure is expanded by outlining the components of the proposed model. Section 3 presents the results by providing a sample response of the fuzzy system and listing the most important improvements when compared to a simpler variant that does not utilize a hybrid feature selector. Finally, Section 4 offers a discussion of the results obtained from the design and implementation process and identifies directions for the utilization of the system and future work.  [20] and fuzzy logic principles [21], the fuzzy control system includes several components that form a pipeline that is used to derive crisp output values from a given set of crisp inputs. Uncertainty and imprecision are present and often impact on the decision-making process considerably, since people use non-numerical information to evaluate and interpret real world scenarios. To understand the entire design process, we explain each component of our proposed model in turn and present the resulting algorithm of the base Mamdani system.

Materials and Methods
In the first step of the fuzzy control system design process, the input and output variables are selected, and fuzzy sets need to be constructed. Intuitively, fuzzy sets are regions of data points that, to some degree, belong to a certain linguistic interpretation of a variable given a range of values. For example, if we selected the temperature of a room as our input variable and decided to recognize the linguistic terms "cold", "warm", and "hot", a trapezoid-shaped curve could be defined to describe the fuzzy set that corresponds to the linguistic term "warm". Hence, there is the need to map each crisp input value to the fuzzy sets and receive the corresponding degrees of membership. Continuing the example above, a specific room temperature value could yield the set of membership degrees [0.8, 0.2, 0] denoting the real world equivalent of asking 100 people about their perception of the room temperature and 80% of them responding with "cold" while 20% would respond with warm. This assignment of values to membership degrees is achieved through the membership function defined for each linguistic term, and this process is executed by the fuzzification module of the control system. The number and types of the various membership functions used in the system structure are chosen by the designer based on experimentation, expert knowledge, or clustering. It is important to note that fuzzy systems that are designed to manage complex environments focus on having a low execution time, and consequently, the choice of three or five membership functions for a given variable is very common [22].
The second component of fuzzy control systems is the decision-making unit, which uses a set of fuzzy rules in order to map the input truth values to the desired output truth values. Fuzzy rules are IF-THEN statements between antecedents and are consequently expressed in linguistic terms. These rules utilize fuzzy operators [23] and are evaluated in parallel using fuzzy reasoning. The evaluation of each fuzzy rule entails the assignment of rule weights denoting their importance and the application of an implication method such as the minimum and product, which scale the output fuzzy set accordingly. The number of rules for a particular system heavily relies on the selection methods used, the intended usage of the fuzzy system, and the complexity of the environment. Since the rules constitute the basis for pattern identification, the number of rules should cover every possible result in the output. Fuzzy systems designed to produce predictions often use a larger set of rules to maintain high accuracy, whereas systems that focus on the regulation of a specific behavior or the extraction of recommendations and insights focus on the most important subset of rules that will be applicable in each case. Furthermore, rules can be manually constructed or generated based on the availability of expert knowledge, the variable dimensions, and the dependencies within a system. Simpler systems that remain static and explore a smaller input-output space usually work well with rules created by the designers in cooperation with experts on the field. On the other hand, dynamic systems that change and evolve over time as well as systems that handle highly dimensional datasets use rule discovery and generation techniques. Modern fuzzy systems use a variety of methods from the fields of artificial intelligence and machine learning such as grid partitioning, genetic algorithms, decision trees, and fuzzy neural networks in order to generate interpretable sets of rules [24][25][26][27].
The third and final component of fuzzy control systems using the Mamdani approach is the defuzzification unit, where the results of the rules are combined and distilled. The aggregate output fuzzy set of the rule evaluation step is now mapped back to a crisp set. There are a wide variety of methods used in the defuzzification process, which can be organized in distinct groups based on their properties. Maxima methods such as the mean of maxima are often used in fuzzy reasoning systems in order to calculate the most plausible result, whereas distribution methods and area methods such as the center of gravity are increasingly popular in fuzzy controllers due to the property of continuity [28]. The simulation and calculation of the crisp output using those methods is made easy due to various programming interfaces and libraries in Matlab (R2020b, The Mathworks, Natick, MA, USA) and Scikit-Fuzzy that carry out these operations efficiently. Figure 1 presents the core structure of a fuzzy system that contains the components analyzed above and serves as the basis upon which we shall expand for our proposed model. These components form the standard Mamdani fuzzy system, which will be structurally modified to address the challenges of the use case examined in this work. The algorithm of the standard Mamdani system used to compute the crisp output y from the crisp numerical input X = x given a rule base of statements in the form of "IF X is A k THEN Y is B k " where A k and B k are fuzzy sets appearing in the antecedent and consequent respectively that consist of four steps. In the first step, the degree of membership of input x in the fuzzy set A is computed as µ A k (x) and the corresponding rules with positive degrees of membership are activated. In the second step, the fuzzy set in the consequent of each rule is truncated at the level of the previously calculated degree of membership, forming the output fuzzy set µ output k|x , which follows the equation: In the third step of the algorithm, all the truncated fuzzy sets are aggregated to provide a single set µ Mamdani|x , which can be defined by the membership function: Lastly, the crisp output is calculated from the defuzzification of the fuzzy set using the horizontal axis projection of the center of gravity of the region under the membership function µ Mamdani|x in the final step. In the third step of the algorithm, all the truncated fuzzy sets are aggregated to provide a single set | , which can be defined by the membership function: Lastly, the crisp output is calculated from the defuzzification of the fuzzy set using the horizontal axis projection of the center of gravity of the region under the membership function | in the final step.

Proposed Model
Following the base fuzzy system design of the previous subsection, the design of our system, which features a decision-making unit that is enhanced by machine learning methods, is presented. Since the target environments of our system lie within the energy sector, and specifically the automatic regulation and management of electricity consumption at an individual level, certain aspects of the decision-making process need to be explored further in order to suggest fast and easily interpretable solutions. Energy data and environmental parameters such as weather variables form time series with complex patterns that create complex datasets that cannot be easily expressed by expert rules. It is easy to see that different consumers living in separate buildings have different needs and therefore generate different load profiles based on their individual schedules and their perception of the environment. Moreover, for the construction of the optimal recommended consumption response to a set of weather parameters, rules need to be discovered by a method that could easily be retrained on new datasets when drastic changes occur in the load profiles due to schedule or major appliance changes. The increased complexity and dynamic nature of these environments often result in larger sets of rules due to the high number of input features. Consequently, one of the main appeals of fuzzy logic methods, namely computational efficiency, could be hindered if no extra processing is performed on the input features.
In order to tackle the challenges mentioned above, we divided the decision-making unit into a feature engineering and a rule generation process, which proceed to organize rules and feed them to the inference engine of the Scikit-Fuzzy application programming interface (API) for evaluation. The feature engineering process focuses on reducing the number of distinct inputs while maintaining the most important linguistic terms associated with each input variable. One-hot encoding [29] is used in order to denote the presence or absence of a specific linguistic term based on the most dominant fuzzy labels produced by the membership function evaluation. The resulting state-based features are ranked based on their importance in a hybrid feature selection system including XGBoost (1.2.1, The XGBoost Contributors, Seattle, WA, USA) and decision tree metrics. The linguistic terms with scores above certain thresholds are appended to a list and passed down to the rule generation process as inputs. In this process, a decision tree classifier is constructed, and each branch of the resulting tree is linearized recursively into a relatively small set of IF-THEN rules. The crisp output is derived after the rule evaluation and defuzzification of results following the Mamdani approach. In Figure 2, we present a diagram of our proposed model outlining each step used to construct the rule base, and

Proposed Model
Following the base fuzzy system design of the previous subsection, the design of our system, which features a decision-making unit that is enhanced by machine learning methods, is presented. Since the target environments of our system lie within the energy sector, and specifically the automatic regulation and management of electricity consumption at an individual level, certain aspects of the decision-making process need to be explored further in order to suggest fast and easily interpretable solutions. Energy data and environmental parameters such as weather variables form time series with complex patterns that create complex datasets that cannot be easily expressed by expert rules. It is easy to see that different consumers living in separate buildings have different needs and therefore generate different load profiles based on their individual schedules and their perception of the environment. Moreover, for the construction of the optimal recommended consumption response to a set of weather parameters, rules need to be discovered by a method that could easily be retrained on new datasets when drastic changes occur in the load profiles due to schedule or major appliance changes. The increased complexity and dynamic nature of these environments often result in larger sets of rules due to the high number of input features. Consequently, one of the main appeals of fuzzy logic methods, namely computational efficiency, could be hindered if no extra processing is performed on the input features.
In order to tackle the challenges mentioned above, we divided the decision-making unit into a feature engineering and a rule generation process, which proceed to organize rules and feed them to the inference engine of the Scikit-Fuzzy application programming interface (API) for evaluation. The feature engineering process focuses on reducing the number of distinct inputs while maintaining the most important linguistic terms associated with each input variable. One-hot encoding [29] is used in order to denote the presence or absence of a specific linguistic term based on the most dominant fuzzy labels produced by the membership function evaluation. The resulting state-based features are ranked based on their importance in a hybrid feature selection system including XGBoost (1.2.1, The XGBoost Contributors, Seattle, WA, USA) and decision tree metrics. The linguistic terms with scores above certain thresholds are appended to a list and passed down to the rule generation process as inputs. In this process, a decision tree classifier is constructed, and each branch of the resulting tree is linearized recursively into a relatively small set of IF-THEN rules. The crisp output is derived after the rule evaluation and defuzzification of results following the Mamdani approach. In Figure 2, we present a diagram of our proposed model outlining each step used to construct the rule base, and in Figure 3, we include a diagram of the main use cases that could take advantage of this fuzzy system as it was discussed in a previous section. In the following subsections, we apply this model design on a real-world energy dataset of a building and analyze each step in more detail while explaining all the decisions formed in order to handle that data efficiently. For the Energies 2021, 14, 752 7 of 18 following case study, Pandas 0.25.3 and Numpy 1.17.3 were used for data manipulation, Matplotlib was used for visualization, and XGBoost 1.2.1 and Scikit-learn 0.24 were used for the rule generation and the hybrid feature selection. Scikit-Fuzzy 0.4.2 was used for the construction of the fuzzy system. The project was written in Python 3.7.5, and the simulation was executed on a desktop computer with an AMD Ryzen 1700X processor, 8 gigabytes of RAM, and an Nvidia 1080Ti graphics processor. The code of this project is available on Github [30]. in Figure 3, we include a diagram of the main use cases that could take advantage of this fuzzy system as it was discussed in a previous section. In the following subsections, we apply this model design on a real-world energy dataset of a building and analyze each step in more detail while explaining all the decisions formed in order to handle that data efficiently. For the following case study, Pandas 0.25.3 and Numpy 1.17.3 were used for data manipulation, Matplotlib was used for visualization, and XGBoost 1.2.1 and Scikit-learn 0.24 were used for the rule generation and the hybrid feature selection. Scikit-Fuzzy 0.4.2 was used for the construction of the fuzzy system. The project was written in Python 3.7.5, and the simulation was executed on a desktop computer with an AMD Ryzen 1700X processor, 8 gigabytes of RAM, and an Nvidia 1080Ti graphics processor. The code of this project is available on Github [30].  . Potential integration of the fuzzy system as a minimum energy consumption recommendation tool for consumer applications or as a secondary analysis tool for provider-side adjustments complementing the load curve.

Dataset Overview
In order to construct a complete simulation of the proposed system using Scikit-Fuzzy, we utilized the energy data found in [31]. This dataset contains a time series of energy consumption and weather data of a low-energy house designed according to in Figure 3, we include a diagram of the main use cases that could take advantage of this fuzzy system as it was discussed in a previous section. In the following subsections, we apply this model design on a real-world energy dataset of a building and analyze each step in more detail while explaining all the decisions formed in order to handle that data efficiently. For the following case study, Pandas 0.25.3 and Numpy 1.17.3 were used for data manipulation, Matplotlib was used for visualization, and XGBoost 1.2.1 and Scikit-learn 0.24 were used for the rule generation and the hybrid feature selection. Scikit-Fuzzy 0.4.2 was used for the construction of the fuzzy system. The project was written in Python 3.7.5, and the simulation was executed on a desktop computer with an AMD Ryzen 1700X processor, 8 gigabytes of RAM, and an Nvidia 1080Ti graphics processor. The code of this project is available on Github [30].  . Potential integration of the fuzzy system as a minimum energy consumption recommendation tool for consumer applications or as a secondary analysis tool for provider-side adjustments complementing the load curve.

Dataset Overview
In order to construct a complete simulation of the proposed system using Scikit-Fuzzy, we utilized the energy data found in [31]. This dataset contains a time series of energy consumption and weather data of a low-energy house designed according to . Potential integration of the fuzzy system as a minimum energy consumption recommendation tool for consumer applications or as a secondary analysis tool for provider-side adjustments complementing the load curve.

Dataset Overview
In order to construct a complete simulation of the proposed system using Scikit-Fuzzy, we utilized the energy data found in [31]. This dataset contains a time series of energy consumption and weather data of a low-energy house designed according to the passive house certification [32] in Stambruges with a total floor area of 280 m 2 and a total heated area of 220 m 2 . The house has four occupants: two teenagers and two adults. The data variables collected in this dataset consist of the appliance and lighting energy consumption, temperature and humidity values of nine different areas inside and outside the residence, wind speed, pressure, visibility, two random variables introduced in the original paper for the study of regression tasks as well as date and time-related features such as number of seconds from midnight, week status, day of the week, and a date timestamp. The energy consumption values as well as the values for humidity and temperature were recorded by sensors at ten-minute intervals and transmitted via XBee radio. Weather parameters such as wind speed, pressure, and visibility were collected from the weather station in Chièvres at an hourly sampling rate and were interpolated to produce 10-min measurements. The dataset contains records of a 137-day time span and further exploratory analysis of trends, feature correlation, and importance were carried out in the original paper.
For the purpose of our project, we selected the appliance energy consumption as the output variable, since the desired behavior of our fuzzy system was the generation of optimal energy consumption recommendations for the occupants based on environmental parameters. As for input, we selected the local temperature and humidity measurements for the nine areas as well as the weather variables of wind speed, visibility, and pressure, since the perception of each feature could vary between occupants, therefore making such features suitable for fuzzification. Since the input consists of a total of 21 columns, we can already observe that in the ensuing step of fuzzification, the feature space expands, and refinements are needed in order to deal with its size efficiently.

Fuzzification
In this subsection, we analyze the fuzzification process in which the crisp values of input and output variables are converted into fuzzy sets. In order to achieve that, we generate box plots, as presented in Figure 4, and further inspect the exploratory data analysis of the original paper. As a result, we infer the ranges and the universe of discourse for each variable, and we are able to define sets of linguistic terms as well as membership functions. In order to maintain the computational simplicity and interpretability of the system, we select to assign 3 linguistic terms and the associated membership functions for pressure, visibility, wind speed, and humidity while appliance consumption and area temperature are assigned 4 and 5 linguistic terms, respectively. A range of 3 to 5 terms and functions is very common in the literature and could adequately capture the human perception of a fuzzy variable. Furthermore, common membership function shapes are selected such as the triangular, trapezoidal, and sigmoid through the generators of Scikit-Fuzzy in order to contribute to the overall simplicity of the system. In Table 1, we list the linguistic terms assigned to each variable, and in Figure 5, we present the graphs of the associated membership functions. Since the human perception of temperature and humidity in any given area is universal and the different upper and lower bounds for each area individually would not alter the human decision in the characterization of those parameters, all nine temperature and humidity features share the same membership functions for temperature and humidity, respectively. However, the temperature and humidity of each area is defined as a different fuzzy input variable on the system in order to match the complexity of the environment we study. Intuitively, a human would make nine different decisions for each area of the building and aggregate those in order to make a deduction. It is worth noting that since the ranges for each variable are derived from dataset analysis, the input and output of our system can easily be parameterized to fit the load profiles of other buildings given a history dataset. Finally, the degrees of membership for each crisp record are calculated with the interp_membership method of Scikit-Fuzzy, forming fuzzy sets for each input and output value.

Decision-Making Unit
In this subsection, we follow the results of the fuzzification process and analyze the feature engineering and rule generation processes needed to construct the decision-making unit for our fuzzy system. Since the environment we study is based on a historical energy dataset of a building and there are many different parameters involved in the induction of the recommended appliance consumption values, we need to be able to extract rules that are general enough to address the most dominant states of each parameter and at the same time specific enough to include the most important states of each parameter that contribute the most to the construction of a rule. Furthermore, as the environment changes and evolves, we need to ensure that an easily interpretable model is in place that can be conveniently retrained to reflect the updated set of rules in case there

Decision-Making Unit
In this subsection, we follow the results of the fuzzification process and analyze the feature engineering and rule generation processes needed to construct the decision-making unit for our fuzzy system. Since the environment we study is based on a historical energy dataset of a building and there are many different parameters involved in the induction of the recommended appliance consumption values, we need to be able to extract rules that are general enough to address the most dominant states of each parameter and at the same time specific enough to include the most important states of each parameter that contribute the most to the construction of a rule. Furthermore, as the environment changes and evolves, we need to ensure that an easily interpretable model is in place that can be conveniently retrained to reflect the updated set of rules in case there are major changes in the occupancy, the appliance setup, and the general operation of the building.
The fuzzification process yielded membership scores for a crisp value on the corresponding set of linguistic terms. In order to derive the most dominant linguistic term that will be useful for rule extraction, we select the maximum membership score for each crisp value and construct a new dataset that consists of the dominant label for each input and output variable. For example, if the value for visibility yielded the highest membership value for the linguistic term "Medium", we set that as the dominant state of that record on the new dataset. Additionally, due to its simplicity, versatility, and interpretability, we selected the decision tree classifier as our base model for rule extraction. Since the new dataset of dominant terms contains categorical input and output variables, we apply one-hot encoding on the input and use the output terms as classes in order to enable the decision tree to process the data effectively. Therefore, the original entry of the above example is replaced with the appropriate three columns for low, medium, and high visibility while having the value 1 for medium visibility and 0 for all other terms. This data transformation introduces the challenge of dimensionality, since the combined total of 22 input and output feature columns is now increased to 85. One-hot encoding contributes to the desired behavior of the model, because all possible decision paths are represented in the branches of the decision tree. However, a large amount of decision paths could lead to a substantially large set of rules that not only hinders the interpretability of the decision-making model but also the computational performance of the fuzzy system.
In order to tackle the challenge mentioned above, we shift the focus to the pursuit of the most important terms that influence appliance consumption through the process of feature engineering. Since we now have state-based features for each variable, we no longer need to ask the question, "Does the temperature in the kitchen area have a significant impact on appliance energy consumption?" but rather ask, "How important is the state of feeling hot in the kitchen area for appliance energy consumption?" The difference between the above questions reflects the quality difference between feature engineering approaches in a fuzzified input space. Choosing to answer the second question is equivalent to examining the possible antecedents of a rule one by one without significant information loss. On the other hand, the first question could eliminate the entire feature of temperature, thus rendering the rules more general and sometimes less applicable to input sequences where an antecedent related to temperature would activate a specific rule for computation.
Therefore, for our fuzzy system, we select to apply a hybrid feature selector, inspired by the feature selection method proposed in [33] and based on the feature importance values derived from an XGBoost classifier and a decision tree classification model on their default configuration. The one-hot encoded dataset was split into a training and validation set with 70% of the data allocated to the former and 30% of the data reserved for the latter. These models were constructed with the expectation of retraining the decision-making unit in the future; thus, choosing the simple hold-out validation would be less computationally expensive than the other methods. The importance scores are extracted using the built-in methods of the Scikit-learn and XGBoost packages, and they are presented in Figure 6.
It can be easily observed that since each feature was split into several linguistic terms, the individual importance score of each term as a rule antecedent yields relatively low values in both cases. The feature selector uses a threshold for each classifier to append the most important state-based features into a list followed by duplicate elimination. The following formulas clarify the process of appending a feature to the list: where f and g denote the candidate feature groups to be appended to the list, and the vari- It can be easily observed that since each feature was split into several linguistic terms, the individual importance score of each term as a rule antecedent yields relatively low values in both cases. The feature selector uses a threshold for each classifier to append the most important state-based features into a list followed by duplicate elimination. The following formulas clarify the process of appending a feature to the list: where and denote the candidate feature groups to be appended to the list, and the variables [ ] and [ ] refer to the feature importance values derived from the XGBoost and Decision Tree classifiers, respectively. The symbols 1 and 2 represent the selection threshold of each method and are set to 0.035 and 0.045, respectively. Each threshold was selected after the inspection of each individual feature score. The values The resulting list of features is used as the input of a new decision tree classifier, where the output classes are the linguistic labels that characterize consumption. Decision trees are suitable for rule extraction, since they can be linearized to if-then statements [34]. Consequently, we inspect every path of the decision tree recursively and parse the corresponding rule based on the features appearing in that path. Each non-leaf tree node contains a statebased feature, which is selected as an antecedent for the rule. If the feature follows the left branch of a decision path, it is used with the negation operator, since the value for that term is 0. Alternatively, if the feature follows the right branch, it is included in the antecedent as is. The antecedents in each rule are connected in logical conjunction. Leaf nodes denote the consequents of each rule, since they are the linguistic terms that characterize appliance consumption. The rules are written in a text file, which is then processed and parsed to generate an executable Python code that can be used by the Scikit-Fuzzy API to perform simulations of the fuzzy logic system.

Results
In this section, we demonstrate the output response of the fuzzy logic system after the simulation of an input sample. We outline the performance and interpretability features of the system by highlighting the effectiveness of the changes made in the decision-making unit. Such changes affect the way input and input is handled during rule generation and shorten the response time of the computation process. Since the crisp output results from the aggregation of rules that get activated (that is, their antecedents are satisfied), using a reduced rule base consisting of the most important antecedents leads to fewer antecedent checks. Moreover, due to the nature of some defuzzification methods and the disjunctive effect of multiple rules as seen in [20], the output may not satisfy the consequent of any rule to any extent, because it would be the result of a compromise between different extreme regions on the consequent. Using a decision tree structure combined with a feature refinement technique should decrease the likelihood of those compromises, since the resulting branches are expected to be smaller and distinctly different on the variables that represent the antecedents. Therefore, rules that could point to different extreme regions, causing a compromise in the aggregation, are expected to include a higher number of different antecedents that need to be activated. The effect could still be present, but this expectation sets the requirement of having different antecedents and contributes to the interpretability of the system.
For our example, we assign as input values the crisp values of the first dataset record. Since this system does not predict energy consumption but is aimed at giving advice on the desired minimum consumption based on past operation, the selection of dataset records for demonstration purposes is a fast and convenient way of providing a realistic set of input values. Arbitrary input values for each dataset feature could still yield a response from the system, but the process of determining the probability of their occurrence for this building would be time consuming and lies outside the scope of this work. The fuzzy system was initialized with the integration of 281 rules derived by our decision-making unit. Since the record passed in the input may contain data fields that are not present as antecedents in that set of rules, we implemented conditions to check for their occurrence in the rule base and exclude the columns when those antecedents are not present. In this example, we observed that 11 out of the 21 input variables were not present in the final set of rules, hence excluding five temperature values, five humidity values, and the pressure value. After 1.27 s of computation time, the system yielded a response of 209.89 Wh for appliance consumption, which can be interpreted as the optimally typical consumption value based on the given environmental data and the history of operation of the building. In Figure 7, we present the resulting area that is used to calculate the crisp output value based on the Mamdani approach. Additionally, in Figure 8, we present the response of the fuzzy system for 500 10-min intervals, denoting the minimum energy consumption for 500 dataset records. While the inspection of an individual data point in Figure 7 provides significant details on the two fuzzy sets involved in the computation as well as their membership, the simulation in Figure 8 shows that the minimum energy consumption of the building could be characterized as mostly "Medium" for those timesteps. However, the crisp output values vary, showing the potential influence of fuzzy sets related to different linguistic terms. For example, for timesteps where the minimum energy consumption is below 140 Wh, we can assume that there could be a significant past contribution of several instances where "Low" consumption could occur given the environmental data in the input.
in the computation as well as their membership, the simulation in Figure 8 shows that the minimum energy consumption of the building could be characterized as mostly "Medium" for those timesteps. However, the crisp output values vary, showing the potential influence of fuzzy sets related to different linguistic terms. For example, for timesteps where the minimum energy consumption is below 140 Wh, we can assume that there could be a significant past contribution of several instances where "Low" consumption could occur given the environmental data in the input.   minimum energy consumption of the building could be characterized as mostly "Medium" for those timesteps. However, the crisp output values vary, showing the potential influence of fuzzy sets related to different linguistic terms. For example, for timesteps where the minimum energy consumption is below 140 Wh, we can assume that there could be a significant past contribution of several instances where "Low" consumption could occur given the environmental data in the input.   This control system features several improvements over the base ID3 model for this environment due to the implementation of the decision-making unit. Table 2 presents the accuracy scores and the number of resulting rules after the linearization. Through our experiments, we observed that the feature engineering process contributed to a slightly higher classification accuracy while considerably decreasing the number of input features and the number of the resulting set of rules. Consequently, the fuzzy system was capable of computing crisp values fast, despite the complexity and initial number of the linguistic variables. Moreover, it is important to mention that since the time interval of the measurements in the dataset is 10 min, we set that time as the upper limit for a fuzzy system response; this should be the maximum amount of time so that the computed optimal typical value would be the most valuable for applications. The base decision-making unit produced a significantly larger set of rules, and the fuzzy system did not yield a response during that time.

Discussion
This paper explored a fuzzy system design approach for a residential building based on weather parameters in order to derive recommendations for the minimum energy consumption values based on environmental data. Since the rules of the system are unknown and the nonlinearity of the recorded time series data increases the overall complexity of the environment, a machine learning model was constructed and the decision-making unit of the fuzzy system was modified in an effort to generate accurate rules based on the past operation of the building. Compared to the more traditional decision tree rule generation model, our structure managed to shrink the set of rules by 65% while achieving slightly better classification accuracy. Dimensionality proved to be another challenge for this system, since a total of 85 features would result in a large decision tree that would be hard to interpret, and the generated set of rules would slow down computation time. Therefore, the decision to implement a hybrid feature selector in an attempt to find the most important linguistic terms led to a significant structural optimization [35], since the remaining set of features was 84% smaller than the initial one, and crisp input values were essentially filtered against the rule base to eliminate redundant features-i.e., features that do not contribute to the conditions of any rule. Consequently, the computational performance is acceptable, since the response of the system is within the time interval of recording an energy consumption measurement through smart meters. The base linearized decision tree structure featuring all available variables resulted in a larger and less accurate set of rules. Therefore, there was no output for the base system within the 10-min intervals. For the purposes of this work, we are satisfied with an acceptable computation time within the measurement interval because the fuzzy rationale is not constantly exact, and the output of fuzzy systems may not be generally acknowledged [36]. Shifting the focus toward faster computation times could be detrimental to the stability of the system due to refinements that could be more impactful than feature importance, resulting in an insufficient amount of rule checks. Thus, we focused on the structure and the quality of the features in order to ensure proper knowledge representation.
Additionally, the decision-making module could be easily retrained to accommodate future changes in occupancy and appliance operation. The resulting energy consumption values represent the optimal consumption under the specified weather conditions and could be used by applications in order to inform the consumers, encouraging them to maintain or change their consumption habits, thus introducing fewer irregular patterns in their load profiles. Alternatively, the response of this fuzzy system could be utilized in demand response applications on the provider side in order to drive indirect adjustments to consumer behavior through varying pricing schemes. Since we believe that a direct adjustment targeting the load profile curve could lead to consumer dissatisfaction, an indirect adjustment based on the recommended consumption could provide an incentive to consumers to manage and plan their activities voluntarily. The integration of the proposed structure in consumer or provider applications could be overall user-friendly, since environmental measurements and smart metering information could be provided automatically, without the contribution of an expert for the extraction of knowledge in a particular residential building. Moreover, depending on the parameterization used in the configuration of membership functions for each use case, this system could be suitable for any residential building. Since we use fuzzy logic to map input and output to linguistic terms through an application programming interface, it could be convenient for developers to use those linguistic terms as an additional tag when referring to the output response, thus characterizing the minimum energy consumption in a more interpretable way.
However, it is worth noting that maintaining the transparency of the system and the simplicity in our approach could be regarded as an adaptability and performance hurdle under specific circumstances. The decision tree structure used in the rule generation process can be sensitive to changes in the data. Since the input and output are tied to linguistic terms, there is a level of protection tied to the range of values that corresponds to the same linguistic term but more extreme data variations that could result from significant changes in the appliances, the activities of the occupants, or extreme weather conditions; the model may need to be trained again to reflect the changes on the rules appropriately. Fortunately, in the localized residential environment, retraining the model would not be detrimental to the real-world performance of the system considering measurements recorded at 10-min intervals, but we can expect that a rule generation module based on a neural network and evolutionary algorithms would be more efficient under those extreme conditions while sacrificing interpretability.
In the future, comparisons between this decision-making model and other modern rule generation approaches such as fuzzy neural networks and genetic algorithms would be beneficial to the overall exploration of interpretable and computationally efficient solutions for similar datasets under the same assumptions. Additionally, the integration of similar fuzzy system designs featuring comparable feature engineering approaches would be an interesting area to explore, as automation solutions and demand response applications evolve with the help of machine learning. Last but not least, the extension of the existing system with the inclusion of a feedback module capable of regulating the desired behavior of the residential buildings based on specific thresholds set by the electricity providers would enhance the proposed structure.