论文解读
AI 辅助整理- 方法
- 离线注入漂移、尖峰、故障异常,60秒窗口随机森林,分组防泄漏。
- 发现
- 独立测试准确率64.2%、宏F1 0.624、事件召回0.889,但误报偏高。
- 机会点
- 缺乏自然故障验证,可研究真实故障数据下的异常检测与误报抑制方法。
论文摘要
在传感网监测的垂直农场中,将温湿度、二氧化碳、光照、pH与电导率信号分为正常、漂移、尖峰和故障四类,离线注入异常并分组防泄漏。60秒窗口随机森林独立测试准确率64.2%、宏F1为0.624,事件召回0.889,但误报偏高且未用自然故障验证。
全文
Agriculture (2026, 16)Academic Editor: Francesco Marinello
Received: 28 October 2026
Revised: 16 November 2026
Accepted: 23 November 2026
Published: 26 November 2026
Copyright: © 2026 by the authors.
Licensee MDPI, Basel, Switzerland.
This article is an open access article
distributed under the terms and
conditions of the Creative Commons
Attribution (CC BY) license.
Article
Characterization and Abnormal-Pattern Classification of
Environmental and Nutrient Sensor Data in a Lab-Scale
Vertical Farm
Md Razob Ali 1 , Gusti Ayu Putri Mei Ulianti 1
, Md Nasim Reza 1 , 2
, Arnab Majumder 1
, Kanghee Jeong 3 ,
Choa Mun Yun 4 and Sun-Ok Chung 1 , 2 , *
1 Department of Agricultural Machinery Engineering, Graduate School, Chungnam National University,
Daejeon 34134, Republic of Korea; ali1999@o.cnu.ac.kr (M.R.A.); gstayumei@o.cnu.ac.kr (G.A.P .M.U.);
reza5575@cnu.ac.kr (M.N.R.); majumderarnab@o.cnu.ac.kr (A.M.)
2 Department of Smart Agricultural Systems, Graduate School, Chungnam National University,
Daejeon 34134, Republic of Korea
3 Corporation X-One, Anyang 14119, Republic of Korea; engineer@x01.co.kr
4 SherpaSpace Inc., Daejeon 34028, Republic of Korea; cmunyun@sherpaspace.co.kr
- Correspondence: sochung@cnu.ac.kr; Tel.: +82-42-821-6712
Abstract
Reliable sensor operation is critical for effective environmental and nutrient management
in vertical farms. This study characterized environmental and nutrient sensor signals and
classified abnormal operating patterns as normal, drift, spike, or failure. A LoRaWAN-
based monitoring system was deployed to measure air temperature, relative humidity, CO2
concentration, light intensity, pH, and electrical conductivity. Calibrated measurements,
acquired at 2 s intervals, were segmented into 30, 60, 120, and 300 s analysis windows for sta-
tistical and temporal feature extraction. An event-grouped partitioning approach prevented
abnormal-event sharing among the training, validation, and independent test datasets. The
60 s unweighted random-forest configuration yielded the highest validation macro-F1 and
was selected for final evaluation. On 148 independent test windows, the random forest
achieved 64.2% accuracy, 65.9% balanced accuracy, and a macro-F1 score of 0.624 compared
to 39.2%, 38.4%, and 0.285 for the rule-based classifier. Of the 54 abnormal test events, 48
were detected, corresponding to an event recall of 0.889. The results indicate the potential of
the framework for sensor-fault classification; however, false-alarm reduction and validation
using long-term data and naturally occurring faults are required before deployment.
Keywords: vertical farm; sensor fault detection; anomaly classification; wireless sensor
network; random forest; environmental monitoring
- Introduction
Vertical farm systems are established as controlled crop-production facilities where en-
vironmental conditions, resource inputs, and cultivation operations are maintained within
enclosed structures [1]. Crop production occurs on stacked cultivation beds using artificial
lighting and soilless methods, enabling a larger cultivation area within a limited building
footprint [2]. Enclosed production facilities demonstrate greater water, land, and carbon
dioxide use efficiencies compared to conventional greenhouse cultivation, particularly for
lettuce under comparable conditions [3]. However, substantial electrical energy is required
for lighting, cooling, air circulation, and nutrient-solution management, which remains a
significant constraint on the economic and environmental sustainability of vertical farms [4].
Agriculture 2026, 16, 2608 https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 2 of 39
Therefore, precise monitoring and automated regulation are necessary to maintain op-
timal crop-growth conditions and prevent unnecessary consumption of energy, water,
and nutrients [5].
Recent advancements in precision agriculture, including the integration of smart sen-
sors, IoT communication protocols, and AI-driven decision-making, have transformed
traditional manual cultivation into automated, sensor-based vertical farms [6]. Distributed
wireless sensor nodes are installed at multiple cultivation positions to collect environmental
measurements and transmit data to a base station or monitoring server [7]. Monitoring ar-
chitectures have expanded to include sensor nodes, relay nodes, control devices, databases,
and remote user interfaces for continuous environmental supervision [8]. In the physical
layer of contemporary agricultural systems, real-time sensor measurements initiate pre-
cise control commands to regulate actuators such as pumps, valves, lighting, humidifiers,
and fans, thereby maintaining the microclimate required for optimal crop production [9].
Modern systems utilize localized AI models to address signal anomalies and validate faults,
thereby reducing dependence on cloud infrastructure and providing operators with accurate
and immediate environmental warnings [10].
Environmental sensors are employed to characterize cultivation conditions because
air temperature and relative humidity are closely linked to plant transpiration, water bal-
ance, disease development, and spatial uniformity of the crop environment [11]. Carbon
dioxide concentration and light intensity are monitored due to their direct association
with photosynthetic activity, biomass accumulation, crop morphology, and daily plant
growth responses [12]. Nutrient-solution pH and electrical conductivity serve as essen-
tial indicators, as nutrient availability, ionic concentration, and nutrient-supply strength
depend on these measurements [13]. Significant reductions in crop growth, leaf chloro-
phyll content, and marketable yield occur when unsuitable pH and electrical conductivity
conditions persist in hydroponic nutrient solutions [14]. Additionally, photosynthetic
rate, stomatal conductance, antioxidant activity, crop quality, and biomass production
are affected when nutrient-solution electrical conductivity deviates from the appropriate
crop-specific range [15].
Despite the increasing adoption of sensor-based monitoring, measurement reliability
remains a critical limitation because wireless sensor networks are susceptible to software
faults, hardware faults, communication failures, and unstable operating conditions [16].
Agricultural sensor nodes are also affected by component degradation, environmental expo-
sure, limited power availability, and long-term changes in sensor response, which can result
in measurements that do not accurately represent actual conditions [17]. Common sensor
faults include drift, spike, hard-over, erratic, stuck-value, offset, gain, out-of-range, and data-
loss conditions [18]. Multiple fault types may occur within continuous time-series data, and
abnormal samples can be difficult to distinguish from genuine environmental variations
when only instantaneous thresholds are applied [19]. In automated agricultural systems,
faulty measurements may be transferred to control algorithms, potentially resulting in incor-
rect irrigation, ventilation, nutrient supply, or environmental adjustment [20]. Malfunctions
in pH and electrical conductivity sensors are particularly significant because incorrect nu-
trient measurements can lead to unnecessary fertilizer addition, nutrient-solution disposal,
reduced resource-use efficiency, and unstable crop nutrition [21].
Previous smart farm studies have primarily focused on network configuration, sensor-
data collection, remote visualization, threshold alarms, and the integration of environmental
monitoring with control platforms [22]. Sensor fault studies are generally conducted using
supervised machine-learning classifiers that require labeled datasets containing simulated
or experimentally induced fault conditions [23]. Signal-processing and threshold-based
techniques have also been investigated because their lower computational requirements
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 3 of 39
enable real-time implementation on microcontrollers, gateways, and resource-constrained
monitoring devices [24]. However, limited attention has been given to a unified frame-
work in which environmental and nutrient sensors are calibrated, statistically character-
ized, temporally evaluated, and classified according to normal operation, drift, spike, and
failure conditions [25].
Previous research on agricultural sensor reliability has examined wireless sensor
network faults, threshold-based anomaly detection, machine-learning classification, and
equipment-condition monitoring [16–19,22–29]. While these methods have advanced fault
identification and agricultural monitoring, their objectives and evaluation procedures do
not align with the requirements for integrated environmental and nutrient-solution sensor
assessment in vertical farms. Network-oriented studies focus on communication or node
reliability, whereas equipment-monitoring approaches address actuator or machinery condi-
tions. Threshold-based methods provide interpretability and low computational demands
but may fail to distinguish abnormal signals from normal variability when baseline char-
acteristics vary among sensor types. Machine-learning approaches can integrate multiple
features; however, performance comparisons alone do not confirm whether fault events
are sufficiently separated between dataset partitions or whether detection performance
remains consistent across abnormality classes. Furthermore, environmental measurements
such as temperature, relative humidity, CO2 concentration, and light intensity exhibit differ-
ent temporal characteristics compared to nutrient-solution pH and electrical conductivity
measurements. Therefore, a direct comparison of sensor-specific baseline and temporal char-
acteristics, multiclass fault classification, and event-level detection performance is necessary
to assess the reliability of these heterogeneous measurements within a unified framework.
The primary contribution of this work is the integration of these elements and their evalua-
tion using an event-grouped independent test dataset, rather than the development of a
novel classification algorithm.
Three primary contributions are made. First, an integrated sensor-reliability evaluation
framework was established by combining calibration, sensor-specific statistical characteri-
zation, temporal feature extraction, and multiclass classification across six environmental
and nutrient-solution sensor variables. Second, an event-grouped fault-generation and
partitioning strategy was implemented to prevent event-level data leakage in time-series
classification. Unlike random window-level splitting, which can distribute samples from
the same fault event across different datasets and artificially inflate performance estimates,
this method ensured that entire fault events remained within distinct partitions. As a result,
classification performance was assessed on previously unseen fault-event groups, thereby
enhancing the reliability of independent test results. Third, a comparative evaluation of
rule-based and random-forest classifiers was conducted using identical extracted features,
with performance assessed at both the analysis-window and event levels. Unlike a study
focused solely on developing a new classifier, the present work integrated sensor calibration,
heterogeneous signal characterization, controlled fault generation, and independent-test
evaluation within a single sensor-reliability assessment framework. Accordingly, the ob-
jective was to characterize six environmental and nutrient-solution sensor variables and
evaluate rule-based and random-forest classification of normal, drift, spike, and failure
conditions in a lab-scale vertical farm.
2. Materials and Methods
2.1. AI-Assisted Software and Language Editing Tools
ChatGPT (GPT-6, OpenAI, San Francisco, CA, USA) and Grammarly Pro (Grammarly,
Inc., San Francisco, CA, USA) were used during manuscript preparation and revision.
ChatGPT assisted with academic language refinement, sentence restructuring, improving
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 4 of 39
clarity and coherence. Grammarly Pro was used for grammar checking, paraphrasing,
sentence restructuring, and improving readability. These tools were not used to gener-
ate or modify experimental data, perform statistical analyses, or produce the reported
numerical results and figures. All AI-assisted suggestions were critically reviewed and
edited by the authors, who retain full responsibility for the scientific content, interpretation,
and conclusions.
2.2. Experimental Vertical Farm, Wireless Sensor Monitoring, and Sensor Calibration
The experiment took place in a laboratory-scale vertical farm at the Department of
Agricultural Machinery Engineering, Chungnam National University, Daejeon, Republic
of Korea, from 13 to 21 April 2026. The facility replicated the structural and operational
configuration of an indoor crop-production system, incorporating multilayer cultivation
racks, cultivation beds, artificial lighting, nutrient-solution tanks, circulation pumps, and a
wireless environmental and nutrient monitoring system. Plants were not included in the ex-
periment, as the primary objective was to characterize sensor signals and evaluate abnormal
sensor operating patterns rather than assess crop growth or horticultural performance.
The experimental facility comprised four cultivation racks, each with three cultivation
levels and three parallel beds per level, for a total of nine beds per rack. Each bed measured
approximately 850 mm in length and 100 mm in width, arranged within a cultivation span
of about 600 mm. Adjacent beds were spaced approximately 150 mm apart. Six nomi-
nal planting positions were distributed along each bed at intervals of roughly 140 mm.
The cultivation sections were approximately 910 mm wide, with vertical clearances of 480
mm, 550 mm, and 550 mm between the lower equipment area and the cultivation levels.
Principal dimensions and the structural arrangement are illustrated in Figure 1. The experi-
mental activities were conducted from 13 to 21 April 2026, whereas the principal dataset
used for signal characterization and fault classification was restricted to 24 h of continu-
ous fault-free measurements. This dataset represented sensor operation under controlled
laboratory conditions and was not intended to capture the full variability of commercial
vertical-farm environments.
Figure 1. Experimental vertical farm and sensor-node arrangement. (a) Schematic layout of sensor-
node positions in the vertical farm. (b) Photograph of the lab-scale vertical farm showing the six
sensor-node locations. (c) Structural schematic and dimensions of the vertical farm system.
Artificial light sources were positioned above the cultivation beds, and the lighting
system was operated throughout the measurement period. However, crop-specific pho-
toperiods and horticultural lighting setpoints were not established because no plants were
cultivated during the experiment. The lighting configuration was therefore evaluated as
part of the sensor-monitoring environment rather than as a crop-production lighting treat-
ment. Photosynthetically active radiation (P AR) and photosynthetic photon flux density
(PPFD) were not measured during the experiment and therefore could not be reported for
comparison with commercial vertical-farm lighting conditions.
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 5 of 39
The absence of living plants imposed specific constraints on the experimental condi-
tions. In the absence of a crop canopy, processes such as plant transpiration, canopy-induced
shading, crop CO2 uptake, and plant-driven nutrient-solution uptake were not represented.
As a result, the measured environmental signals did not capture crop-induced changes
in humidity, light distribution, or CO2 concentration, and the pH and EC signals did not
reflect nutrient uptake and depletion associated with plant growth. The nutrient-solution
system comprised storage reservoirs and circulation pumps installed beneath the cultivation
structure. Six pH probes and six electrical conductivity (EC) probes were connected to a
shared nutrient-solution reservoir. Consequently, the recorded pH and EC measurements
represented repeated sensor measurements under shared solution conditions rather than
independent fertigation systems. No crop-specific nutrient recipe or horticultural nutrient-
management setpoints were applied because the experiment was conducted without plants.
The reported nutrient-sensor characteristics therefore represented sensor operation under
the tested solution conditions rather than crop-specific fertigation performance. The ex-
periment consequently represented sensor operation under controlled no-crop conditions
rather than the full environmental and nutrient dynamics present in an actively cultivated
vertical farm.
Environmental sensing components were installed at fixed locations adjacent to the
monitored beds. Air temperature, relative humidity, CO2 concentration, and light intensity
were measured to characterize environmental sensor behavior within the vertical farm
structure. Nutrient-solution pH and EC were measured from the nutrient-solution system
to assess nutrient-sensor responses. In the absence of a crop canopy, environmental sensors
were positioned relative to the cultivation-bed surface rather than a plant canopy. Identical
sensor positions were maintained across the monitored beds to minimize positional effects
in signal comparisons. Measurements were collected during controlled operation of the
vertical farm infrastructure. Artificial lighting and the nutrient-solution circulation system
were operated throughout the measurement period to generate representative environ-
mental and nutrient sensor signals. No CO2 enrichment associated with crop production
was applied. In the subsequent analysis, the term “normal condition” refers exclusively to
normal sensor operation without any introduced faults. Normal sensor operation does not
imply that the measured temperature, relative humidity, CO2 concentration, light intensity,
pH, or EC represent optimal horticultural conditions.
2.3. Wireless Sensor Node Design and Calibration Procedure
Six wireless sensor nodes were deployed within the cultivation area, with one node
assigned to each monitored bed. Identical sensor configurations were implemented across
all nodes to facilitate direct comparison of measurements among cultivation positions.
Wireless sensing is widely utilized in controlled agricultural environments, as it enables
continuous data acquisition from spatially distributed locations and minimizes wiring re-
quirements [30]. During farm operation, air temperature, relative humidity, carbon dioxide
concentration, light intensity, pH, and electrical conductivity were monitored. Air tempera-
ture, relative humidity, carbon dioxide concentration, and light intensity characterized the
local cultivation environment, while pH and electrical conductivity represented nutrient-
solution conditions. These nutrient variables are commonly used to evaluate nutrient
availability and solution concentration in hydroponic crop production. Data from all six sen-
sor nodes were incorporated into subsequent signal characterization and classification. For
pH and electrical conductivity (EC), measurements from each of the six probes were main-
tained as distinct sensor streams, despite all probes sampling the same nutrient-solution
reservoir. Therefore, the six pH and EC streams reflected repeated sensor measurements
under identical solution conditions rather than six independent reservoir-level observations.
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 6 of 39
The principal fault-free dataset consisted of 24 h of continuous measurements col-
lected at 2 s intervals (0.5 Hz), resulting in 43,200 observations per sensor stream. These
data provided a controlled baseline for subsequent offline fault injection and classification.
However, the dataset reflected sensor responses only during operation of the laboratory-
scale vertical-farm infrastructure and did not capture day-to-day variability, crop-induced
environmental changes, or long-term sensor behavior under commercial cultivation condi-
tions. These fault-free measurements were subsequently calibration-corrected and used
as the baseline dataset for offline generation of drift, spike, and failure conditions. Each
observation included the measurement time, sensor node identification, and corresponding
sensor values. Node-specific data were maintained to enable independent evaluation of
temporal signal behavior at each monitoring location. The collected measurements were
subsequently used for calibration, signal characterization, and classification of normal and
abnormal sensor operating conditions.
The wireless monitoring architecture consisted of sensor nodes, a LoRaWAN gateway,
a communication layer, a monitoring server, a database, and a visualization interface. Mea-
surements collected at the cultivation beds were transmitted from the sensor nodes to the
gateway using LoRaWAN communication. The received data were then transferred to the
monitoring server and stored in the database for visualization and further signal analysis.
Comparable IoT-based architectures have been implemented for continuous environmen-
tal monitoring and data management in controlled agricultural facilities. Each wireless
node was configured as an integrated monitoring unit containing a microcontroller, power
module, communication antenna, temperature, RH sensor, CO2 sensor, light sensor, pH
sensor, and EC sensor. Individual sensing modules were connected to the microcontroller
through their corresponding analog or digital interfaces. Electrical power was supplied
through the node power module, while wireless transmission was supported through
the communication antenna. The sensor node and circuit configuration are presented
in Figure 2.
Sensing components were selected based on the environmental and nutrient variables
essential for farm operation. Air temperature and relative humidity were measured us-
ing a combined temperature and humidity sensor, while carbon dioxide concentration
was monitored with a CO2 sensor. Light conditions were assessed using a light sensor,
and nutrient-solution pH and electrical conductivity (EC) were measured with dedicated
nutrient sensors. All sensing components were connected to a microcontroller for sig-
nal acquisition and processing. The sensors differed in measurement accuracy, resolu-
tion, operating voltage, sampling capability, and response characteristics. These specifica-
tions were evaluated during sensor-node integration and data acquisition, as summarized
in Table 1.
Table 1. Specifications of selected environmental and nutrient sensors.
Variable Module Manufacturer Range Accuracy Resolution Response Time Interface
Tempera-
ture and
humidity
DHT22
Aosong Electronics
Co., Ltd.,
Guangzhou, China
−40–80 °C,
0–100% RH
±2% RH;
+/−0.5 °C
0.1% RH,
0.1 °C 2 s Single-wire digital
CO2 CM1106
Cubic Sensor and
Instrument Co., Ltd.,
Wuhan, China
0–5000 ppm ± 50 ppm 1 ppm ±120 s UART-TTL, PWM, and I2 C
Light
intensity P5144-9
ROHM
Semiconductor,
Kyoto, Japan
1–65,535 lx ± 20% 4.9 mV 0.5 ms I2 C
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 7 of 39
Table 1. Cont.
Variable Module Manufacturer Range Accuracy Resolution Response Time Interface
pH pH sensor DFRobot, Shanghai, China pH 0–14 ± 0.1 pH ± 0.1 <2 min Analog output, 0–2.3 V
EC EC sensor DFRobot, Shanghai, China 0–20 mS/cm ± 5% 0.001 mS/cm <2 min Analog output; BNC probe connector
Figure 2. Wireless sensor node and monitoring architecture for environmental and nutrient sensing
in the vertical farm. (a) Photograph of the wireless sensor node. (b) Circuit design of the wireless
sensor node showing the microcontroller, power module, and connected sensors. (c) IoT-based
communication, data acquisition, and processing architecture of the monitoring system.
Calibration of sensors was performed using reference instruments or calibration stan-
dards specific to each measured variable. Temperature and relative humidity were assessed
with a digital thermo-hygrometer, CO2 concentration with a portable NDIR CO2 detec-
tor, and light intensity with a digital illuminance meter. Certified buffer solutions were
employed for pH calibration, while certified conductivity standards were used for EC cali-
bration. Three calibration points were applied for both pH and EC, whereas five points were
used for the environmental sensors. At each calibration point, paired sensor and reference
measurements were collected and fitted using linear regression. Sensor-specific regression
coefficients were obtained for each monitored variable and were applied to the correspond-
ing measurements before subsequent signal characterization and abnormal-pattern analysis.
Details regarding instrument specifications, calibration ranges, measurement durations,
and evaluation metrics are provided in Table 2.
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 8 of 39
Table 2. Calibration conditions and reference instruments or standards used for environmental and
nutrient sensor evaluation.
Variable Reference Instrument Manufacturer/Model Calibration Range No. of Points Duration/Point EvaluationMetrics
Temperature
and humidity
Digital thermo-
hygrometer
CAS/T023/Yangju,
Republic of Korea
Temperature:
0–50 °C; RH:
20–95%
Temperature:
5; RH: 5 10 min MAE, RMSE, mean bias, and R2
CO2 Portable NDIR CO2 gas detector Bosean/BH-90A-CO2 /Henan, China 0–1500 ppm 5 5 min MAE, RMSE, mean bias, and R2
Light
intensity
Digital
illuminance
meter
JW Company,
Shenzhen,
China/WT81
0–1400 lx 5 5 min MAE, RMSE, mean bias, and R2
pH Certified pH buffer solutions YSI, Yellow Springs, OH, USA/3821, 3822, and 3823 pH 4.00, 7.00, and 10.00 at 25 °C 3 5 min MAE, RMSE, mean bias, and R2
EC
Certified EC
standard
solutions
Supelco
(Sigma-Aldrich,
Merck) Darmstadt,
Germany/06999,
06949, and 51795
0.5, 1.0, and
2.0 mS/cm 3 5 min MAE, RMSE, mean bias, and R2
To minimize the influence of systematic measurement errors on subsequent abnormal-
signal classification, sensor calibration was performed prior to time-series characterization.
Raw sensor measurements were compared with those from calibrated reference instruments
at multiple measurement points. This calibration process aimed to reduce gain and offset
errors and to prevent systematic measurement deviations from being misinterpreted as
sensor drift or abnormal baseline behavior.
Each of the six sensor units for every sensor type was calibrated individually using the
corresponding reference instrument or certified standard. Calibration was conducted at
five points for temperature, relative humidity, CO2 concentration, and light intensity, and
at three points for pH and electrical conductivity. For temperature and relative humidity,
measurements were recorded for 10 min at each point; for the remaining variables, mea-
surements were recorded for 5 min at each point. At all calibration point, paired sensor
and reference measurements were collected after readings stabilized. Linear regression
was applied to the paired measurements, and unit-specific slope and intercept coefficients
were subsequently used for each sensor unit. Calibration performance was evaluated using
R2 , mean absolute error (MAE), root mean square error (RMSE), and mean bias [31]. The
relationship between the raw sensor output and the reference measurement is described
by Equation (1):
𝑦𝑖 = 𝑎𝑥𝑖 + 𝑏 (1)
where yi denotes the raw sensor measurement, xi denotes the corresponding reference
measurement, a denotes the regression slope, and b denotes the intercept. Calibration-
corrected values were then calculated by rearranging the linear regression equation, as
shown in Equation (2) [31]:
𝑥𝑖, 𝑐𝑜𝑟𝑟 = 𝑦𝑖, 𝑟𝑎𝑤 − 𝑏𝑎 (2)
where xi,corr is the calibration-corrected measurement and yi,raw is the raw sensor reading.
Regression coefficients were estimated independently for each monitored variable, and the
corrected measurements were subsequently used for time-series signal characterization and
abnormal-pattern classification. The complete calibration procedure is presented in Figure 3.
Calibration was conducted individually for all six sensor units of each type, utilizing the
reference instruments and standard solutions specified in Table 2. Measurements were
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 9 of 39
recorded after stabilization at each calibration point. Five calibration points were used for
environmental sensors, and three for nutrient sensors. Calibration ranges were chosen to
assess sensor responses under the specific experimental conditions rather than across the full
nominal measurement ranges. Certified standard solutions served as calibration references
for pH and EC. The resulting sensor-specific regression coefficients were subsequently
applied to monitoring measurements. Calibration sampling frequencies, detailed in Table 3,
varied according to sensor characteristics. In contrast, the continuous monitoring dataset
was collected at a uniform interval of 2 s (0.5 Hz). Although the available calibration
records document the reference instruments and procedures, they do not independently
establish instrument-level metrological traceability, repeated-session reproducibility, or
environmental control tolerances.
Figure 3. Sensor calibration workflow and reference measurement procedure.
Table 3. Additional sensor calibration sampling conditions and reference units.
Sensor Measured Points Sampling Frequency Duration per Point Reference Instrument Reference Unit
Temperature 5 0.5 Hz 10 min Thermo-hygrometer °C
Relative humidity 5 0.5 Hz 10 min Thermo-hygrometer % RH
CO2 5 1 Hz 5 min CO2 analyzer ppm
Light intensity 5 8 Hz 5 min Lux meter lux
pH 3 1 Hz 5 min Certified pH buffer solutions pH
EC 3 1 Hz 5 min Certified EC standard solutions mS/cm
Figure 3 presents the overall calibration workflow . Unit-specific regression coefficients were
derived from paired sensor and reference measurements and subsequently applied to the corre-
sponding sensor streams prior to signal characterization and abnormal-pattern classification.
2.4. Sensor Data Processing, Fault Generation, and Operating-Class Definition
Time-series environmental and nutrient data were collected from wireless sensor nodes
installed in the vertical farm. Air temperature, relative humidity, CO2 concentration, light
intensity, pH, and electrical conductivity were continuously monitored. Measurements
were acquired at 2 s intervals and transmitted via the LoRaWAN communication network
to the gateway. For each observation, timestamp and sensor-node identification were
retained to facilitate sensor-specific temporal analysis. Calibrated signals collected without
intentionally introduced abnormalities served as fault-free reference data. Prior to fault
generation, timestamp consistency, missing observations, repeated measurements, negative
values, and measurements outside the sensor range were examined. Each sensor was
processed separately due to differences in measurement range, baseline variability, and
temporal response. The term “normal” denotes sensor operation without an introduced
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 10 of 39
fault and does not imply that the measured environmental or nutrient condition was optimal
for crop production.
Controlled abnormal signals were generated offline using copies of the calibrated
normal measurements. Synthetic fault injection is widely used when naturally occurring
labeled faults are insufficient for supervised sensor-fault analysis [18,32–34]. Drift, spike,
stuck, offset, and data-loss patterns were represented by modifying fault-free time-series
measurements while preserving the original baseline behavior [32,33]. Before fault gen-
eration, the calibrated fault-free time-series records were assigned to training, validation,
and independent test source partitions. For each sensor 𝑠, the fault-generation magnitude
was normalized according to the normal sensor range derived exclusively from the training
partition. A robust baseline range 𝑅𝑠 was calculated from the 5th and 95th percentiles of
the corresponding normal training measurements using Equation (3):
𝑅𝑠 = 𝑄95,𝑠 − 𝑄5,𝑆 (3)
where Q95,s and Q5,s represent the 95th and 5th percentiles of the normal measurements for
sensor s. Fault intensity I was varied from 0.1 to 1.0 in increments of 0.1. This range was
selected following the multi-intensity fault-generation approach reported for wireless sensor
measurements [33]. The use of a sensor-specific baseline range prevented the same absolute
perturbation from being applied to variables measured on substantially different scales.
Drift was generated as a progressive additive deviation from the original signal. For drift
beginning at time t0 , the faulty measurement was calculated using Equation (4) [32,33,35].
𝑥𝑓 (𝑡) = 𝑥(𝑡) + 𝑑𝐼𝑅𝑆
𝑡 − 𝑡0
𝐷 (4)
In this equation, x(t) denotes the fault-free measurement, xf (t) denotes the generated
faulty measurement, d indicates the drift direction (either +1 or −1), I represents fault
intensity, and D represents drift duration. Linear accumulation of measurement bias is
commonly used to represent sensor drift [33]. Drift durations of 60, 120, and 300 s were
included to capture gradual abnormalities across multiple temporal scales. Spike faults
were generated as abrupt positive or negative deviations from the normal signal. The faulty
signal was calculated as shown in Equation (5) [33,35].
𝑥𝑓 (𝑡) = 𝑥(𝑡) + 𝑑𝐼𝑅𝑆 (5)
The disturbance was maintained for one to three consecutive samples, corresponding
to durations of 2 to 6 s. Both positive and negative directions were included. Short-duration
additive disturbances are widely used to represent spike or transient sensor faults [18,32,33].
Spike duration was intentionally set shorter than the evaluated analysis windows to assess
the ability of extracted temporal features to identify localized abnormalities.
Failure conditions were defined as sensor responses from which a reliable measurement
could no longer be obtained. Multiple failure subtypes were included, as complete sensor
failure does not always manifest as missing data. Stuck or flat-line failure was generated
by holding the measurement at the value immediately preceding fault onset. Data-loss
failure was represented by missing measurements. Signal-drop failure was represented by
an abrupt reduction from the normal baseline, and out-of-range failure was represented
by a measurement beyond the valid sensor range. Stuck, data-loss, fixed, and out-of-range
faults are widely recognized in sensor-fault studies [16,33,34].
Failure durations ranged from 6 to 60 s. A minimum duration of three consecutive
samples was applied to flat-line responses so that isolated repeated measurements were not
automatically labeled as failure. The valid measurement ranges of the sensing components
were also considered during generation of out-of-range conditions. The evaluated ranges
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 11 of 39
were −40 to 80 °C for temperature, 0 to 100% RH for relative humidity, 0 to 5000 ppm
for CO2 concentration, 1 to 65,535 lx for light intensity, 0 to 14 for pH, and 0 to 20 mS/cm
for electrical conductivity. Fault-insertion positions were selected from eligible locations
within the normal time-series records. Generated events were prevented from overlapping,
and sufficient normal measurements were retained before and after each abnormal event
to preserve the temporal context required for feature extraction. A fixed random seed
was applied during fault generation to enable reproducible selection of event locations.
Randomized fault-insertion positions have previously been used to represent uncertainty
in sensor-fault occurrence time [32].
Within the four-class classification framework, generated abnormal conditions were
mapped to drift, spike, and failure, while fault-free sensor operation was assigned to normal.
Gradual progressive deviations and sustained baseline displacement were assigned to
drift. Abrupt positive or negative short-duration excursions were assigned to spike. Flat-
line, stuck-value, missing-data, signal-drop, and out-of-range responses were assigned as
failure subtypes rather than being treated as separate target classes. Fault events were
subsequently generated within the corresponding training, validation, and independent
test source partitions. Event boundaries were constrained so that no abnormal event was
shared among the three partitions. Analysis windows crossing partition boundaries were
discarded to prevent event-level information leakage. The fault-generation parameters and
the distribution of complete abnormal events in the event-grouped independent test dataset
are summarized in Table 4.
Table 4. Parameters used to generate sensor fault events and event distribution in the event-grouped
independent test dataset.
Sensor Fault Class Fault Subtype Magnitude or Range Duration No. of Test Events Generation Method
Temperature Drift Positive or negative drift Final deviation 0.1Rs to 1.0Rs 60–300 s 1 Linear additive bias
Temperature Spike Positive or negative spike ±0.1Rs to ±1.0Rs 2–6 s 4 Short additive disturbance
Relative
humidity Drift Positive or negative drift Final deviation 0.1Rs to 1.0Rs 60–300 s 2 Linear additive bias
Relative
humidity Failure Signal drop Sensor-specific baseline reduction 6–60 s 0 Signal-value replacement
CO2 Drift Positive or negative drift Final deviation 0.1Rs to 1.0Rs 60–300 s 1 Linear additive bias
CO2 Spike Positive or negative spike ±0.1Rs to ±1.0Rs 2–6 s 34 Short additive disturbance
CO2 Failure Signal drop or data loss Abrupt reduction or missing value 6–60 s 0 Signal replacement or removal
Light
intensity Drift Positive or negative drift Final deviation 0.1Rs to 1.0Rs 60–300 s 1 Linear additive bias
Light
intensity Failure Flat line Pre-fault value held constant 6–60 s 8 Constant-value replacement
Light
intensity Failure Signal drop Abrupt reduction from baseline 6–60 s 0 Signal-value replacement
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 12 of 39
Table 4. Cont.
Sensor Fault Class Fault Subtype Magnitude or Range Duration No. of Test Events Generation Method
pH Drift Positive or negative drift Final deviation 0.1Rs to 1.0Rs 60–300 s 1 Linear additive bias
pH Failure Invalid or abrupt response Beyond normal baseline or valid range 6–60 s 0 Signal-value replacement
EC Drift Positive or negative drift Final deviation 0.1Rs to 1.0Rs 60–300 s 1 Linear additive bias
EC Failure Out-of-range response <0 or >20 mS/cm 6–60 s 1 Out-of-range replacement
Total 54
The distribution of generated fault events was uneven across sensor types and ab-
normality classes. In the independent test dataset, 34 of 38 spike events originated from
CO2 measurements, while eight of nine failure events were associated with light-intensity
measurements. Drift events were represented across all six sensor types, but were relatively
limited in number. These counts reflect the realized distribution of the generated and re-
tained fault events rather than a balanced sensor–fault experimental design. Consequently,
some fault classes were strongly associated with particular sensor variables, which could in-
fluence the classification patterns learned by the model. The resulting dataset was therefore
used to evaluate performance under the available fault-event distribution rather than to es-
tablish uniform classification capability across all sensor types and abnormality conditions.
The independent test partition contained 54 abnormal events, including 7 drift events,
38 spike events, and 9 failure events. The relatively large number of spike events was
mainly associated with the CO2 signal, in which repeated short-duration excursions were
represented. Event counts were recorded separately from analysis-window counts because
a single abnormal event could overlap multiple analysis windows. After fault generation,
complete abnormal events were assigned to the training, validation, or independent test
partition before window segmentation. Event boundaries were preserved so that no abnor-
mal event was shared among the three dataset partitions, and windows crossing partition
boundaries were discarded to prevent event-level information leakage.
The calibrated time-series signals were subsequently segmented using analysis win-
dows of 30, 60, 120, and 300 s. A window was assigned an abnormal operating class only
when the corresponding interval overlapped a predefined fault event. Measurements pre-
ceding the onset of a drift event were labeled normal, whereas measurements following the
onset were labeled drift for the remaining duration of the generated event. This event-local
labeling procedure prevented complete sensor records from being assigned an abnormal
class when the abnormality was restricted to a specific temporal interval. Representative
signal patterns for normal, drift, spike, and failure conditions are presented in Figure 4.
Sensor operating status was categorized into four target classes comprising normal,
drift, spike, and failure. Abnormal signal manifestations were treated as subtypes and as-
signed to one of these four primary classes rather than being considered independent target
classes. Normal was defined as fault-free sensor operation with temporal characteristics
consistent with the sensor-specific baseline. The term “normal” referred only to sensor op-
erational status and did not indicate that the measured environmental or nutrient condition
was within a crop-specific optimum range. Drift represented gradual baseline displacement
or persistent positive or negative bias associated with sustained measurement deviation.
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 13 of 39
Spike represented abrupt short-duration positive or negative excursions and isolated er-
ratic disturbances that subsequently returned toward the baseline. Failure represented
conditions in which reliable sensor information could no longer be obtained [32,33,36,37].
Flat-line, signal loss, missing data, stuck-value, signal-drop, saturation, out-of-range, and
persistent erratic responses were therefore treated as failure subtypes. This hierarchical
mapping was applied consistently during fault labeling, feature extraction, model train-
ing, and performance evaluation. The definitions, temporal characteristics, and principal
indicators of the four operating classes are summarized in Table 5.
Figure 4. Representative signal patterns for normal, drift, spike, and failure operating conditions.
Table 5. Definition of normal and abnormal sensor operating conditions.
Status Definition Statistical Characteristics Temporal Pattern Classification Rule Reference
Normal Expected stable sensor response Low baseline deviation and normal variability Stable signal No abnormal criterion detected [36]
Drift Gradual deviation from baseline Increased slope or mean deviation Sustained directional change Slope or baseline deviation exceeds threshold [37]
Spike
Abrupt
short-duration
deviation
High local variation
or peak/drop
magnitude
Sudden peak or
drop
Local change exceeds
threshold [32]
Failure Missing, constant, or invalid response Missing values or near-zero variation Data gap, flat line, or signal loss Missing-data or flat-line criterion exceeded [33]
The calibrated signals were segmented into retrospective analysis windows of 30, 60,
120, and 300 s. With a 2 s acquisition interval, these durations corresponded to 15, 30, 60,
and 150 samples, respectively. Multiple window durations were evaluated to account for the
temporal characteristics of drift, spike, and failure conditions. Shorter windows preserved
localized excursions and signal-drop responses, whereas longer windows provided greater
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 14 of 39
temporal context for gradual drift and sustained failure patterns. Window duration was
selected exclusively using the event-grouped validation dataset, and no independent test
observations were used during model selection. Accuracy, balanced accuracy, and macro-F1
were evaluated for each candidate duration using the unweighted random-forest configura-
tion. The 60 s window achieved the highest validation accuracy of 0.650 and the highest
macro-F1 of 0.625. The corresponding balanced accuracy was 0.672. The 60 s window also
produced the highest balanced accuracy among the evaluated unweighted configurations
and was selected because macro-F1 was defined as the primary model-selection metric.
Drift was represented across all evaluated window durations, with seven drift validation
windows for the 30 and 60 s durations and six for the 120 and 300 s durations. The validation
results are summarized in Table 6.
Table 6. Validation performance of the random-forest classifier according to analysis-window duration.
Window
Duration
Validation
Windows Accuracy Balanced Accuracy Macro-F1 Drift Support
30 s 141 0.617 0.611 0.584 7
60 s 140 0.650 0.672 0.625 7
120 s 133 0.541 0.492 0.476 6
300 s 124 0.597 0.512 0.509 6
Statistical and temporal features were extracted from each analysis window to charac-
terize sensor behavior under normal, drift, spike, and failure conditions. The mean and
standard deviation were calculated to describe the central level and dispersion of each
sensor signal, while the coefficient of variation was retained only as a descriptive measure
of within-sensor variability. Direct comparison of CV among sensing variables was avoided
because the monitored variables differed in measurement scale and physical interpretation.
Temporal characteristics were represented using signal slope, baseline deviation, and stan-
dardized baseline deviation to identify gradual displacement from normal sensor behavior.
Abrupt abnormalities were characterized using positive peak magnitude, negative drop
magnitude, and normalized peak, standard-deviation, and range ratios. Failure-related
behavior was characterized using the missing-data ratio, flat-line fraction, and flat-line
duration. These features were calculated independently for each analysis window and were
subsequently used as inputs for the rule-based and random-forest classifiers. The overall
feature-extraction procedure is illustrated in Figure 5.
Sensor-specific baseline characteristics were estimated exclusively from normal mea-
surements in the training partition to prevent information leakage. For each sensor stream,
the baseline mean and standard deviation characterized normal operating behavior. Base-
line deviation was defined as the difference between the analysis-window mean and the
corresponding training-derived baseline mean. Standardized baseline deviation was cal-
culated by dividing this difference by the baseline standard deviation. Peak magnitude,
signal variability, and temporal range were normalized relative to the corresponding sensor-
specific baseline characteristics. These normalized features allowed measurements with
different physical units and operating ranges to be incorporated into a pooled classification
dataset, thereby reducing dependence on absolute measurement scales.
A universal coefficient of variation threshold was not applied because baseline vari-
ability differed substantially among the monitored sensor variables. Instead, sensor-specific
thresholds were derived exclusively from normal windows in the training dataset. Valida-
tion and independent test data were excluded from threshold estimation. For each sensor,
the 99th percentile of the corresponding feature distribution obtained from training–normal
windows was used as the reference level. The peak or drop threshold was defined as
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 15 of 39
1.5 times the 99th percentile of the maximum peak or drop magnitude. The local-variability
threshold was defined as three times the 99th percentile of the window standard deviation,
while the slope threshold was defined as three times the 99th percentile of the absolute
temporal slope. An absolute standardized baseline-deviation threshold of 3.0 was applied
to all sensors. Failure conditions were evaluated first. A window was classified a failure
when the missing-data ratio was at least 0.20 or the flat-line fraction was at least 0.50. For the
selected 60 s window containing 30 samples, a missing-data ratio of 0.20 corresponded to at
least six missing observations. A flat-line fraction of 0.50 represented an unchanged-value
sequence occupying at least half of the analysis window, corresponding to approximately
30 s of persistent repeated measurements.
Figure 5. Statistical and temporal feature extraction from calibrated sensor signals.
Windows that did not satisfy the failure criteria were subsequently evaluated for spike
behavior. A spike label was assigned when either the positive peak or negative drop magni-
tude exceeded the corresponding sensor-specific threshold or when the window standard
deviation exceeded the local-variability threshold. Windows not assigned to failure or
spike were subsequently evaluated for drift. A drift label was assigned when either the
absolute temporal slope exceeded the corresponding sensor-specific slope threshold or
the absolute standardized baseline deviation exceeded 3.0. Windows that did not satisfy
any abnormality criterion were classified as normal. The sequential rule-based decision
order was therefore failure, spike, drift, and normal. Sensor-specific threshold values were
derived exclusively from normal observations in the training partition and are summarized
in Table 7, while the corresponding classification sequence is illustrated in Figure 6. Thresh-
old multipliers and cutoff criteria were not optimized using the validation or independent
test datasets. Validation data were used for analysis-window and random-forest configu-
ration selection, whereas the independent test dataset was reserved exclusively for final
performance evaluation.
A random forest (RF) classifier was implemented using the statistical and temporal
features extracted from each analysis window. Random forest was selected because en-
sembles of decision trees can represent nonlinear relationships and interactions among
sensor features while reducing the prediction variance associated with individual decision
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 16 of 39
trees [16,38]. The conventional random-forest algorithm was applied without algorithmic
modification. Bootstrap resampling, random feature selection at individual tree nodes,
and majority voting across classification trees were retained during model construction.
Therefore, the developed classifier was treated as a conventional random-forest model
rather than a modified random-forest algorithm. The classifier was implemented in Python
3.13.5 using the RF classifier from scikit-learn version 1.8.0. A total of 300 decision trees
were constructed with a maximum tree depth of 12.
Table 7. Sensor-specific thresholds used for rule-based classification with 60 s analysis windows.
Sensor Peak or Drop Threshold SD Threshold Absolute Slope Threshold Absolute Standardized Baseline-Deviation Threshold Missing-Data Ratio Flat-Line Fraction
Temperature (°C) 0.269 0.203 0.00725 3.0 0.20 0.50
Relative humidity (%) 0.264 0.202 0.01040 3.0 0.20 0.50
CO2 243.34 202.47 11.2757 3.0 0.20 0.50
Light intensity (lx) 31.10 18.94 0.74951 3.0 0.20 0.50
pH 1.105 0.797 0.03536 3.0 0.20 0.50
EC (mS cm−1 ) 0.0391 0.0356 0.001254 3.0 0.20 0.50
Figure 6. Rule-based classification flowchart for normal, drift, spike, and failure sensor operating conditions.
The random-forest classifier was implemented using extracted statistical and temporal
features from the pooled sensor dataset. Sensor-specific baseline information was incorpo-
rated via derived deviation and normalized variability features, enabling the model to assess
abnormal patterns relative to corresponding Normal sensor characteristics. The model
utilized 300 trees and a maximum depth of 12 as fixed configuration settings to control
tree complexity. These parameters were not independently optimized during the reported
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 17 of 39
validation comparison. Instead, validation-based selection focused on analysis-window
duration and class weighting. The same fixed tree-structure settings were applied across all
evaluated configurations to ensure consistent comparison and reproducibility.
Gini impurity was applied as the node-splitting criterion. A minimum of two samples
was required for an internal node to be divided, while a minimum of one sample was
required for each terminal leaf. Three candidate features were randomly considered at each
split. Bootstrap sampling with replacement was applied during construction of individual
trees, and a fixed random seed of 42 was used to ensure reproducibility. Two class-weight
configurations, unweighted and balanced, were evaluated because the frequencies of normal,
drift, spike, and failure windows were unequal. Analysis-window durations of 30, 60, 120,
and 300 s were also evaluated. The combinations of the four window durations and two
class-weight configurations produced eight principal model configurations.
Model selection was performed exclusively using the event-grouped validation dataset,
with macro-F1 designated as the primary selection metric because equal importance was as-
signed to all four operating classes. The unweighted 60 s configuration produced the highest
validation macro-F1 and was therefore selected for final evaluation using the independent
test dataset. The principal tree-structure parameters were fixed before evaluation of the
independent test dataset and were not adjusted using test observations. Window duration
and class weighting were selected using only the validation dataset, while the independent
test partition was reserved for final performance assessment. No abnormal event was shared
among the training, validation, and independent test partitions during model development
or evaluation. The final random-forest configuration and model-selection procedure are
summarized in Table 8.
Table 8. Random-forest implementation and hyperparameter settings used for sensor-fault classification.
Parameter Evaluated Values or Status Final Setting Selection or Basis
Programming environment Fixed Python 3.13.5
Implementation
environment used for final
rerun
ML package Fixed scikit-learn Standard random-forest implementation
Package version Fixed 1.8.0 Version used for final rerun
Classifier Fixed Random-forest classifier Conventional random forest
Split criterion Fixed Gini Fixed model setting
Number of trees Fixed 300 Fixed model setting
Maximum tree depth Fixed 12 Fixed model setting
Minimum samples to split Fixed 2 Fixed model setting
Minimum samples per leaf Fixed 1 Fixed model setting
Features considered per
split Fixed 3 Random feature subset at each split
Bootstrap sampling Fixed True Sampling with replacement
Bootstrap sample size Fixed Training-set size max_samples = None
Class weighting None, balanced None Higher validation macro-F1
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 18 of 39
Table 8. Cont.
Parameter Evaluated Values or Status Final Setting Selection or Basis
Analysis-window duration 30, 60, 120, 300 s 60 s Highest validation macro-F1
Random seed Fixed 42 Reproducibility
Principal validation
configurations
4 windows × 2 weighting
schemes 8 configurations Validation-based model comparison
Primary model-selection
metric
Accuracy, balanced
accuracy, macro-F1 Macro-F1 Primary criterion for model selection
Final model Candidate configurations above Unweighted RF with 60 s window Highest validation macro-F1
Independent test data Excluded during model selection Used only after model selection Final independent performance evaluation
2.5. Analytical Procedures
The selected 60 s dataset comprised 757 labeled analysis windows that were allocated
to training, validation, and independent test partitions using an event-grouped partitioning
procedure that prevented event-level leakage. Complete abnormal events were assigned to
only one partition so that no fault event contributed analysis windows to more than one
dataset partition. Normal windows without associated fault-event identifiers retained the
corresponding temporal source allocation. A total of 19 complete drift events were assigned
to training, 7 to validation, and 7 to independent testing. After partitioning, 469 windows
were retained for training, 140 windows for validation, and 148 windows for independent
testing. The training partition comprised 201 normal, 37 drift, 151 spike, and 80 failure
windows. The validation partition comprised 67 normal, 7 drift, 38 spike, and 28 failure
windows. The independent test partition comprised 61 normal, 13 drift, 49 spike, and
25 failure windows. The resulting dataset distribution is summarized in Table 9.
Table 9. Distribution of selected 60 s analysis windows and abnormal events represented by at least
one retained analysis window across the event-grouped dataset partitions.
Partition Normal Drift Spike Failure Total Windows Total Fault Events
Training 201 37 151 80 469 144
Validation 67 7 38 28 140 40
Independent test 61 13 49 25 148 53
Total 329 57 238 133 757 237
Note. The independent test partition contained 54 injected abnormal events. Of these, 53 were
represented by at least one retained 60 s analysis window. The remaining failure event did not produce
a retained 60 s analysis window and was counted as undetected in the event-level recall calculation.
The partitioning procedure was based on complete abnormal-event groups rather
than strict chronological separation. Consequently, no abnormal event was shared among
the training, validation, and independent test partitions. However, temporally separated
observations originating from the same physical sensor streams could still occur in more
than one partition. Therefore, the reported independent-test performance represented
generalization to previously unseen abnormal-event groups and analysis windows rather
than generalization to entirely unseen sensor units. A total of 237 unique abnormal event
groups were represented across the final event-grouped dataset. The independent test
dataset contained 54 injected abnormal events, of which 53 were represented by at least one
retained 60 s analysis window.
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 19 of 39
Four retrospective analysis-window durations of 30, 60, 120, and 300 s were evaluated.
Window-duration selection was performed exclusively using the event-grouped validation
dataset, while the independent test dataset was excluded from model-selection proce-
dures. Among the evaluated durations, the 60 s window produced the highest validation
macro-F1 and was therefore selected for final performance evaluation. The independent
test dataset contained 54 injected abnormal events, of which 53 were represented by at
least one retained 60 s analysis window. The remaining failure event did not produce
a retained 60 s analysis window and was retained as an undetected event in the event-
level recall calculation. Two classification approaches were compared using the same
selected analysis-window dataset. The first approach employed sensor-specific statisti-
cal and temporal thresholds as an interpretable rule-based baseline, while the second
approach used a random-forest classifier trained on the extracted signal features. Ran-
dom forest was selected because the ensemble of decision trees can represent nonlinear
relationships and interactions among multiple input features and can support multiclass
classification [38].
Classification performance was evaluated using accuracy, precision, recall, F1 score,
balanced accuracy, and macro-averaged F1 score [39]. Balanced accuracy and macro-F1 were
included because the numbers of normal, drift, spike, and failure windows were unequal
among the dataset partitions. Macro-F1 was used as the primary model-selection metric
because equal importance was assigned to the four operating classes. Final performance
metrics were calculated exclusively using the independent test dataset after completion of
model selection. Precision for each operating class 𝑘 was calculated using Equation (6).
Precisionk = TPkTPk + FPk (6)
Recall for each class was calculated using Equation (7).
Recallk = TPkTPk + FNk (7)
The F1 score was calculated as the harmonic mean of precision and recall using Equation (8).
F1k = 2 × Precisionk × RecallkPrecisionk + Recallk (8)
Overall classification accuracy was calculated using Equation (9):
Accuracy =
∑kk=1 TPK
N (9)
where 𝑇𝑃𝑘 represented the number of correctly classified windows belonging to class 𝑘, 𝐹𝑃𝑘
represented windows incorrectly assigned to class 𝑘, 𝐹𝑁𝑘 represented windows belonging
to class that were assigned to another class, 𝐾 represented the total number of operating
classes, and 𝑁 represented the total number of evaluated windows. Balanced accuracy was
calculated from the mean recall across the four operating classes using Equation (10) [40].
Balanced Accuracy = 1K K∑K=1 Recallk (10)
Macro-averaged F1 was calculated by assigning equal importance to the F1 score of
each class using Equation (11).
Macro-F1 = 1K K∑K=1 F1k (11)
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 20 of 39
A four-class confusion matrix was constructed to evaluate classification performance
across normal, drift, spike, and failure conditions. Correct classifications are represented
along the diagonal, while off-diagonal entries indicate misclassifications between operating
classes. The matrix enabled identification of signal patterns that were difficult to distinguish
and facilitated comparison of classification performance between threshold-based and
random-forest methods.
Performance was also evaluated at the event level, recognizing that short-duration
abnormalities may constitute only a small fraction of an analysis window. Event-based
evaluation is recommended for time-series anomaly detection, as individual abnormal
samples may originate from a single continuous fault episode [41]. Consecutive abnormal
windows associated with the same reference fault were grouped as a single detected event.
An event was considered detected if the predicted abnormal interval overlapped the corre-
sponding labeled event and the operating class was correctly identified. Event-level recall
was calculated according to Equation (12):
Event Recall = Ndetected
Ntrue
(12)
where Ndetected represented the number of correctly detected fault events and Ntrue repre-
sented the total number of labeled fault events. Event-level precision was calculated from
correctly detected abnormal events and false-positive abnormal predictions originating from
normal test windows. Detection delay was determined from the time difference between
the first correct abnormal prediction and the labeled fault onset using Equation (13):
D = tdetected − tstart (13)
where D represented the detection delay, tdetected represented the first time at which the
abnormal event was correctly identified, and tstart represented the labeled event onset. For
each correctly detected event, 𝑡detected was defined as the end timestamp of the first 60 s
analysis window that was correctly classified as the corresponding abnormal class. The
false-alarm rate was calculated from normal windows incorrectly classified as abnormal
using Equation (14):
FAR = Nfalse alarm
Nnormal
(14)
where Nfalse alarm represented the number of normal windows incorrectly classified as
abnormal and Nnormal represented the total number of normal windows evaluated.
Uncertainty in comparative classification performance was assessed using paired
bootstrap resampling of independent test predictions. The resampled test observations were
used to compute accuracy, balanced accuracy, and macro-F1 for both classifiers. Differences
between classifiers were calculated for each resample. The 95% confidence intervals for these
differences were derived from the 2.5th and 97.5th percentiles of the bootstrap distributions.
Wilson 95% confidence intervals for event recall were calculated based on the numbers of
detected and total abnormal events.
3. Results
3.1. Sensor Calibration
Calibration results indicated strong linear relationships between sensor outputs and
reference measurements, with R2 values near 0.99. Because R2 reflects linear association
rather than measurement agreement, calibration performance was also assessed using
mean absolute error (MAE), root mean square error (RMSE), and mean bias. These
metrics quantified residual deviations between calibration-corrected sensor readings and
corresponding reference values, as summarized in Table 10. The reported errors describe
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 21 of 39
agreement for the calibration observations evaluated; independent validation performance
cannot be determined from the available records. Therefore, the results support the use of
sensor-specific calibration corrections within the investigated measurement ranges, but do
not imply equivalent accuracy across the entire nominal operating ranges.
Table 10. Regression parameters and post-calibration residual error metrics for environmental and
nutrient sensor calibration.
Variable Regression Equation R2 MAE RMSE Mean Bias
Temperature 𝑦 = 0.995𝑥 + 0.1801 0.99 0.55 °C 0.60 °C −0.32 °C
Relative humidity 𝑦 = 0.9930𝑥 + 0.2100 0.99 1.25% RH 1.29% RH +0.00% RH
CO2 𝑦 = 0.9900𝑥 + 8.0121 0.99 22.16 ppm 22.62 ppm +1.00 ppm
Light intensity y = 0.9987x + 9.4301 0.99 6.41 lx 6.55 lx +0.80 lx
EC 𝑦 = 0.9596𝑥 + 0.0738 0.99 0.070 mS cm−1 0.078 mS cm−1 +0.007 mS cm−1
pH 𝑦 = 0.9031𝑥 + 0.4941 0.99 0.281 pH 0.301 pH +0.006 pH
Temperature calibration produced the regression equation y = 0.995x + 0.1801 with
an R2 of 0.99, while relative humidity calibration produced y = 0.9930x + 0.2100 with an R2
of 0.99. For CO2 concentration, the regression equation was y = 0.9900x + 8.0121 with an
R2 of 0.99. The regression slopes for temperature, relative humidity, and CO2 concentration
remained close to unity, while the CO2 intercept indicated a measurable offset in the raw
sensor response before calibration correction.
Light-intensity calibration produced the regression equation y = 0.9987x + 9.4301
with an R2 of 0.99. Electrical conductivity calibration produced y = 0.9596x + 0.0738
with an R2 of 0.99, while pH calibration produced y = 0.9031x + 0.4941 with an R2 of
0.99. Greater deviations of the EC and pH regression slopes from unity indicated larger
proportional differences between raw sensor outputs and reference measurements compared
with temperature, relative humidity, and light intensity. Sensor-specific calibration equations
were therefore applied before subsequent signal characterization and abnormal-pattern
analysis. The regression parameters and corresponding post-calibration residual error
metrics are summarized in Table 10.
Individual calibration relationships are presented in Figure 7. The measurement points
for all monitored variables were distributed close to the corresponding fitted regression
lines, which were consistent with the high coefficients of determination reported in Table 10.
Regression slopes for temperature, relative humidity, and light intensity were particularly
close to unity. A larger intercept was obtained for CO2 concentration, while greater devia-
tions from unity were observed for the EC and pH regression slopes. These sensor-specific
gain and offset characteristics could not be represented by R2 alone. Therefore, individual
regression equations were applied to each sensor variable during calibration correction.
After calibration, the corrected measurements were used for baseline characterization,
statistical feature extraction, temporal feature analysis, and abnormal-pattern classification.
Application of the calibration equations before feature extraction reduced the influence of
systematic measurement bias on the estimated mean, baseline deviation, temporal slope,
and related signal characteristics. This correction was particularly important for drift identi-
fication because persistent calibration bias could otherwise resemble sustained displacement
from the normal sensor baseline. Coefficients of determination of approximately 0.99 indi-
cated strong linear relationships across the evaluated calibration ranges, while the regression
slopes and intercepts indicated that sensor-specific gain and offset corrections were required.
Calibration-corrected signals were therefore used for subsequent characterization of normal,
drift, spike, and failure conditions.
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 22 of 39
Figure 7. Calibration relationships between sensor measurements and reference measurements for
temperature, relative humidity, CO2 concentration, light intensity, EC, and pH.
3.2. Sensor Data Characterization
Environmental and nutrient sensor signals were characterized under normal and abnor-
mal operating conditions using statistical and temporal features. Mean, standard deviation,
and coefficient of variation were retained as descriptive statistics for individual sensor
variables. Because the interpretation of coefficient of variation differed among measure-
ment scales, particularly for temperature expressed in degrees Celsius and logarithmic pH
measurements, direct cross-variable ranking based on CV was avoided. Sensor-status char-
acterization was instead based primarily on sensor-specific standardized baseline deviation,
temporal slope, peak and drop magnitude, missing-data ratio, and flat-line characteristics.
These features enabled gradual drift, short-duration spike, and failure-related abnormal-
ities to be evaluated relative to the characteristic normal behavior of each sensor. The
principal statistical characteristics of the six monitored variables are summarized in Ta-
ble 11. Signal-characterization results were obtained from measurements collected across
all six sensor nodes. For pH and electrical conductivity (EC), the reported statistics and
abnormal-pattern characteristics were based on data from six probes measuring the same
nutrient-solution reservoir. Consequently, these results characterized sensor responses
under shared solution conditions, rather than reflecting variability among independent
nutrient-solution reservoirs.
Table 11. Statistical characteristics of environmental and nutrient sensor signals under normal and
abnormal operating conditions.
Sensor Condition Mean SD CV (%) Main Signal Characteristic
Temperature
Normal 22.45 0.96 4.29 Stable response
Drift 23.60 1.42 6.02 Gradual baseline shift
Spike 22.11 0.90 4.07 Localized peak
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 23 of 39
Table 11. Cont.
Sensor Condition Mean SD CV (%) Main Signal Characteristic
Relative
humidity
Normal 63.0 0.8 1.20 Stable response
Drift 63.4 1.3 2.02 Gradual trend
Failure 60.7 5.3 8.69 Signal drop and high variability
CO2
Normal 1477.6 194.7 13.2 Naturally variable response
Spike 1255.6 228.6 18.2 Abrupt fluctuation
Failure 1413.9 195.5 13.8 Signal drop
Light intensity
Normal 868.2 42.9 4.9 Stable response
Failure (flat line) 851.3 101.5 11.9 Abnormal constant response
Failure (signal drop) 854.9 33.1 3.9 Short-duration decrease
pH Normal 7.62 0.05 0.62 Highly stable responseFailure 8.09 0.79 9.71 Abrupt fluctuation and drop
EC
Normal 1.68 0.01 0.50 Highly stable response
Drift 1.78 0.10 5.47 Gradual baseline deviation
Failure (out-of-range) 1.66 0.16 9.77 Sudden drop and instability
Temperature signals exhibited distinct temporal characteristics under normal, drift,
and spike conditions. During normal operation, the mean temperature was 22.45 °C with a
standard deviation of 0.96 °C, and no sustained directional displacement from the sensor-
specific baseline was observed. Under drift conditions, the mean increased to 23.60 °C and
the standard deviation increased to 1.42 °C. A gradual displacement from the baseline was
also observed. Temperature drift was therefore characterized primarily using standardized
baseline deviation and normalized temporal slope rather than relative variability. Coefficient
of variation values of 4.29% and 6.02% were obtained under normal and drift conditions,
respectively. These values were retained only as descriptive within-sensor statistics because
CV has limited physical interpretability for temperature expressed in degrees Celsius due
to the arbitrary zero point of the scale.
Under the temperature-spike condition, the mean was 22.11 °C and the CV was 4.07%,
which remained similar to the corresponding normal values despite the presence of a
localized abnormal excursion. The limited change in whole-signal descriptive statistics was
associated with the short duration of the spike event relative to the surrounding normal
measurements. Consequently, temperature-spike behavior was characterized primarily
using standardized peak magnitude and localized temporal changes rather than mean or
CV . Gradual temperature abnormalities were therefore represented mainly by baseline
displacement and temporal slope, whereas short-duration abnormalities were represented
by features sensitive to localized excursions. Similar combinations of statistical and temporal
features have been applied for sensor-fault discrimination when global variability measures
alone were insufficient [18].
Relative humidity also remained relatively stable during normal operation, with a
mean of 63.0% and a standard deviation of 0.8%. Under drift conditions, the mean shifted
to 63.4% and the standard deviation increased to 1.3%. Although the overall change in vari-
ability was limited, sustained displacement from the sensor-specific baseline was observed.
Standardized baseline deviation and normalized temporal slope were therefore used as the
principal indicators of relative-humidity drift. The CV values of 1.20% and 2.02% for normal
and drift conditions, respectively, were retained as descriptive within-sensor statistics rather
than as a basis for comparison with other sensing variables.
A more pronounced change was observed under relative-humidity failure conditions.
The standard deviation increased to 5.3% RH, together with abrupt signal decreases and
disruption of normal signal continuity. A CV of 8.69% was obtained under this condition.
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 24 of 39
However, failure characterization was based primarily on signal-drop magnitude, missing-
data behavior, continuity-related characteristics, and other temporal indicators rather than
CV alone. Classification of normal, drift, spike, and failure conditions was therefore based on
sensor-specific statistical and temporal features rather than a universal variability criterion.
Representative temperature and relative-humidity signals are presented in Figure 8.
Figure 8. Normal and abnormal time-series signals for temperature and relative humidity.
CO2 signals exhibited pronounced short-term variability during both normal and ab-
normal operating conditions. Under normal operation, a mean concentration of 1477.6 ppm
and a standard deviation of 194.7 ppm were obtained, with a CV of 13.2%. The relatively
high within-sensor variability under normal operation indicated that variability alone could
not reliably distinguish abnormal CO2 behavior. Therefore, CO2 abnormalities were evalu-
ated relative to the characteristic baseline and temporal behavior of the CO2 signal rather
than by applying a general variability threshold.
Under the CO2 spike condition, the standard deviation increased to 228.6 ppm and
the CV increased to 18.2%. Abrupt localized excursions were observed in the time-series
signal and were characterized primarily by peak or drop magnitude and localized tempo-
ral changes. In contrast, a CV of 13.8% was obtained under the Failure condition, which
was close to the normal value of 13.2%. Consequently, CO2 failure was characterized
primarily using signal-drop magnitude, missing-data behavior, duration, and temporal
continuity rather than CV alone. These results indicated that spike and failure condi-
tions could produce distinct temporal patterns despite partially overlapping whole-signal
variability characteristics.
Light intensity also demonstrated the importance of temporal features for abnormal-
pattern characterization. During normal operation, a mean light intensity of 868.2 lx and
a CV of 4.9% were obtained. Under the flat-line failure condition, the standard deviation
increased to 101.5 lx and the CV increased to 11.9%. The relatively high standard deviation
was calculated over the broader signal segment containing normal measurements, transition
periods, and the injected flat-line interval rather than from the constant flat-line interval
alone. Within the actual flat-line interval, the pre-fault value was held constant and local
variation was approximately zero. In contrast, the signal-drop failure condition produced a
CV of 3.9%, indicating that a localized decrease could occur without a corresponding increase
in whole-signal relative variability. Flat-line behavior was therefore characterized primarily
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 25 of 39
by the duration and fraction of repeated measurements, whereas signal-drop behavior was
characterized using abrupt reduction magnitude and temporal continuity. The CO2 and light-
intensity results further indicated that statistical features required interpretation relative
to the characteristic normal behavior of each sensor. Sensor-specific baseline and temporal
features were therefore used for classification rather than a universal variability criterion.
Representative CO2 and light-intensity signals are presented in Figure 9.
Figure 9. Normal and abnormal time-series signals for CO2 concentration and light intensity.
pH exhibited stable behavior during normal sensor operation, with a mean of 7.62
and a standard deviation of 0.05. A CV of 0.62% was obtained and was retained only as a
descriptive within-sensor statistic because pH is measured on a logarithmic scale. Under
failure conditions, the mean increased to 8.09 and the CV increased to 9.71%. Abrupt
positive and negative deviations were observed relative to the characteristic normal pH
response. Consequently, pH failure was characterized primarily using baseline deviation,
peak or drop magnitude, and localized temporal changes rather than CV alone. Previous
research has similarly indicated that pH sensor-fault identification requires consideration
of temporal signal behavior in addition to measurement magnitude [21].
Electrical conductivity exhibited a stable normal response with a mean of 1.68 mS
cm−1 and a CV of 0.50%. Under drift conditions, the mean increased to 1.78 mS cm−1
and the CV increased to 5.47%. The abnormal response developed progressively and was
therefore characterized primarily by standardized baseline deviation and temporal slope.
The out-of-range failure condition produced a CV of 9.77% together with a more abrupt
departure from the normal signal range. Differentiation between EC drift and failure was
therefore based on the temporal development and magnitude of the abnormal response
rather than variability alone.
The pH and EC results indicated that abnormal sensor conditions could be dis-
tinguished more effectively when descriptive statistics were interpreted together with
sensor-specific temporal features. Gradual baseline displacement was associated with
drift, whereas abrupt deviations and out-of-range responses were associated with failure.
Therefore, standardized baseline deviation, temporal slope, peak or drop magnitude, and
failure-related signal characteristics were used together during abnormal-pattern character-
ization. Representative pH and EC signals are presented in Figure 10.
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 26 of 39
Figure 10. Normal and abnormal time-series signals for pH and EC.
3.3. Abnormality Indicators and Framework Evaluation
A comparison of sensor signals indicated that abnormal conditions corresponded to
sensor-specific changes in variability and temporal patterns. The CV values were 18.2%
for the CO2 spike condition, 11.9% for the light-intensity flat-line condition, 9.77% for the
electrical conductivity (EC) out-of-range condition, 9.71% for pH failure, 8.69% for relative-
humidity failure, 6.02% for temperature drift, and 5.47% for EC drift. These CV values
were retained as descriptive indicators within each individual sensor rather than being
used for direct ranking among sensing variables. Increased CV therefore served as a useful
within-sensor indicator for several abnormal conditions.
However, the coefficient of variation alone was insufficient to detect all abnormal
patterns. Normal CO2 levels demonstrated relatively high variability, and brief temper-
ature spikes or reductions in light intensity could occur without substantially increas-
ing the overall CV . Drift conditions were primarily characterized by gradual baseline
shifts rather than abrupt changes in variability. Consequently, CV was evaluated along-
side temporal slope, baseline deviation, magnitude of peaks or drops, flat-line duration,
and signal-loss characteristics. The primary indicators of abnormality are summarized
in Table 12.
Table 12. Sensor-specific statistical and temporal indicators associated with abnormal operating conditions.
Sensor/Abnormal
Condition
Main Abnormality
Indicator Supporting Feature Interpretation
Temperature drift Baseline deviation Temporal slope Gradual displacement
Temperature spike Peak magnitude Local change Short localized excursion
RH failure Signal drop Continuity/SD Loss of stable response
CO2 spike Peak magnitude Local variability Abrupt excursion
CO2 failure Signal drop Continuity Abnormal reduction
Light-intensity failure Flat-line duration Signal drop Stuck or reduced response
pH failure Abrupt deviation Peak/drop magnitude Departure from stable baseline
EC drift Baseline deviation Temporal slope Gradual sensor bias
EC failure Out-of-range response Signal drop Invalid sensor response
The CV values shown in Figure 11 were retained as descriptive indicators of variability
within each individual sensor rather than as a basis for direct comparison among sensing
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 27 of 39
variables. Several abnormal operating conditions produced greater variability than the
corresponding normal condition, indicating that CV remained useful for describing changes
in signal stability within a given sensor. However, direct ranking of temperature, relative
humidity, CO2 , light intensity, pH, and EC according to CV was not performed because
the physical interpretation of CV differed among measurement scales. This limitation was
particularly relevant for temperature expressed in degrees Celsius and for logarithmic
pH measurements. Therefore, CV was interpreted together with sensor-specific tempo-
ral features, including standardized baseline deviation, temporal slope, localized peak
or drop magnitude, missing-data ratio, and flat-line duration. The combined interpreta-
tion provided a more appropriate basis for distinguishing gradual drift, short-duration
spike, and failure-related abnormalities relative to the characteristic normal behavior of
each sensor.
Figure 11. Coefficient of variation under normal and representative abnormal operating conditions
for individual environmental and nutrient sensors.
Validation performance was evaluated across four analysis-window durations and two
class-weight configurations to identify the most suitable random-forest configuration before
independent-test evaluation. Analysis-window durations of 30, 60, 120, and 300 s were
assessed using both unweighted and balanced class weighting. Accuracy, balanced accuracy,
and macro-F1 were calculated for each configuration. Macro-F1 was used as the primary
model-selection criterion because equal importance was assigned to normal, drift, spike,
and failure classes despite unequal class frequencies. The independent test dataset was not
used during this selection procedure. Here, n represents the total number of validation
analysis windows used for each window-duration and class-weighting configuration.
The highest validation macro-F1 was obtained using the unweighted random for-
est with a 60 s analysis window. Accuracy of 0.650, balanced accuracy of 0.672, and
macro-F1 of 0.625 were obtained with this configuration. The corresponding balanced
configuration produced an accuracy of 0.657, balanced accuracy of 0.677, and macro-F1
of 0.624. For the 30 s window, macro-F1 values of 0.584 and 0.597 were obtained with
the unweighted and balanced configurations, respectively. Although shorter windows
retained localized information from brief abnormal events, the 60 s window provided
additional temporal context for gradual drift and sustained failure patterns while maintain-
ing sensitivity to short-duration spike conditions. Validation results are given in Table 13
and Figure 12.
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 28 of 39
Table 13. Event-grouped validation performance according to analysis-window duration and class weighting.
Window Class Weighting Validation Accuracy Balanced Accuracy Macro-F1 Drift Support
30 s None 141 0.617 0.611 0.584 7
30 s Balanced 141 0.638 0.588 0.597 7
60 s None 140 0.650 0.672 0.625 7
60 s Balanced 140 0.657 0.677 0.624 7
120 s None 133 0.541 0.492 0.476 6
120 s Balanced 133 0.541 0.492 0.476 6
300 s None 124 0.597 0.512 0.509 6
300 s Balanced 124 0.589 0.471 0.475 6
Figure 12. Validation macro-F1 of unweighted and balanced random-forest configurations across
candidate analysis-window durations.
The validation results shown in Table 13 indicate that increasing the analysis-window
duration beyond 60 s did not improve overall four-class performance. Macro-F1 decreased
to 0.476 and 0.476 for the 120 s unweighted and balanced configurations, respectively. For
the 300 s window, macro-F1 values of 0.509 and 0.475 were obtained. Drift remained
represented across all evaluated window durations, with seven drift validation windows
for the 30 and 60 s durations and six for the 120 and 300 s durations.
The comparison of validation macro-F1 across window durations and class-weight
configurations is presented in Figure 12. The unweighted 60 s configuration produced
the highest macro-F1 among the eight evaluated configurations. Based on this result, the
60 s unweighted random forest was selected before any evaluation of the independent test
partition. The selected configuration was therefore considered the most appropriate model
within the available validation dataset rather than a universally optimal window duration.
After completion of model selection, the selected 60 s unweighted random-forest
classifier was evaluated using 148 independent test windows. No independent test ob-
servations had been used during threshold estimation, window selection, class-weight
selection, or model configuration. An overall accuracy of 0.642, balanced accuracy of
0.659, macro-precision of 0.618, macro-recall of 0.659, and macro-F1 of 0.624 were obtained.
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 29 of 39
These results represented the final window-level classification performance of the selected
random-forest configuration.
For comparison, the rule-based classifier was evaluated using the same 148 independent
test windows. The resulting accuracy, balanced accuracy, macro-precision, macro-recall,
and macro-F1 were 0.392, 0.384, 0.456, 0.384, and 0.285, respectively. In comparison, the
random-forest classifier demonstrated improvements of 0.250 in accuracy, 0.275 in balanced
accuracy, and 0.339 in macro-F1 over the rule-based classifier. Paired-bootstrap analysis
showed that the 95% confidence intervals for all three improvements did not include zero,
providing statistical support for the observed performance advantage of the random-forest
classifier. Nevertheless, the limited number of independent fault events restricted the
precision of class-specific event-level estimates.
The overall comparison indicated that the random-forest classifier provided substan-
tially better discrimination among the four operating classes than the fixed rule-based frame-
work. The results indicated that nonlinear combinations of baseline, variability, continuity,
and localized temporal features provided greater classification capability than individu-
ally defined sensor-specific thresholds. The comparative performance of the rule-based
and random-forest classifiers is illustrated in Figure 13. Higher values were obtained for
accuracy, balanced accuracy, and macro-averaged performance using the selected random
forest, indicating stronger window-level classification performance for the event-grouped
independent test dataset.
Figure 13. Independent-test performance comparison of the rule-based and selected random-forest classifiers.
Class-specific performance of the selected random forest was subsequently examined
to determine how classification performance varied among normal, drift, spike, and failure
conditions. Spike produced the highest F1 score of 0.776, with precision of 0.672 and recall
of 0.918. A total of 45 of the 49 spike windows were correctly identified. Drift produced
precision of 0.500, recall of 0.692, and F1 score of 0.581. However, only 13 drift windows were
available in the independent test partition, and the corresponding class-specific performance
was therefore interpreted cautiously. Failure produced precision of 0.652, recall of 0.600,
and F1 score of 0.625. Normal produced precision of 0.650 and an F1 score of 0.515, while
recall was limited to 0.426.
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 30 of 39
The class-wise results in Table 14 showed that spike conditions were detected most con-
sistently, whereas discrimination of normal and failure windows remained more challenging.
The comparatively low normal recall resulted from false-positive abnormal classifications
among normal windows. In contrast, the high spike recall indicated that the selected statis-
tical and temporal features effectively represented abrupt short-duration excursions. Drift
classification also showed relatively strong recall, although the smaller number of drift test
windows compared with normal and spike windows limited broader interpretation of the
corresponding estimate.
Table 14. Class-wise performance of the selected 60 s random-forest classifier on the independent test set.
Class Precision Recall F1 Score Support
Normal 0.650 0.426 0.515 61
Drift 0.500 0.692 0.581 13
Spike 0.672 0.918 0.776 49
Failure 0.652 0.600 0.625 25
Figure 14 presents the precision, recall, and F1 score for each operating class. Differ-
ences among the class-specific metrics further demonstrated that overall accuracy alone was
insufficient for interpretation of model performance. The combined use of precision, recall,
and F1 score provided a clearer representation of the trade-off between correct abnormality
detection and false-positive classification across the four target classes. The comparatively
high spike recall reflected strong sensitivity to abrupt short-duration abnormalities, whereas
the lower normal recall indicated a greater tendency for normal windows to be misclassified
as abnormal. Differences among drift and failure metrics further showed that classification
difficulty depended on the temporal characteristics and feature overlap associated with
each abnormal condition.
Figure 14. Class-wise precision, recall, and F1 score of the selected 60 s random-forest classifier.
The confusion matrix shown in Figure 15 provides further information regarding the
distribution of classification errors. Most spike windows were correctly assigned, while
normal windows showed the greatest tendency toward false abnormal classification. Of the
61 normal test windows, 35 were classified as abnormal. In addition, ten failure windows
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 31 of 39
were assigned to normal. These misclassification patterns indicated that separation between
fault-free variability and some abnormal signal patterns remained a principal limitation of
the selected model. Despite these errors, the overall independent-test results demonstrated
a substantial improvement over the rule-based classifier and supported the use of combined
statistical and temporal features for sensor-status classification.
Figure 15. Confusion matrix of the selected 60 s random-forest classifier on the independent test dataset.
The independent test partition contained 54 abnormal events: 7 drift events, 38 spike
events, and 9 failure events. A total of 48 events were correctly detected, corresponding to
an overall event recall of 0.889. Drift detection was obtained for 5 of 7 events, spike detection
for 35 of 38 events, and failure detection for 8 of 9 events. The overall retrospective median
detection delay was 28 s. Median delay was 28 s for spike and failure events, while drift
produced a median delay of 118 s. The larger drift delay reflected the gradual temporal
development of drift events and the placement of retained analysis windows relative to
event onset. Continuous causal sliding-window processing was not evaluated.
In sum, 35 of 61 normal test windows were classified as abnormal, corresponding to
a false-alarm rate of 0.574 per normal window. Under the conservative event-precision
assumption in which each false-positive normal window was counted as a separate false-
alarm event, overall event precision was 0.578 and event F1 was 0.701. Event-level results are
summarized in Table 15. The high event recall and relatively high false-alarm rate indicated
that deployment-oriented thresholding or persistence filtering would be required before
continuous operational use.
Permutation analysis indicated that flat-line fraction produced the largest decrease
in independent-test macro-F1 when permuted, with a mean decrease of 0.088. Flat-line
duration followed closely with a mean decrease of 0.088, while window mean produced a
mean decrease of 0.051. Standardized baseline deviation also contributed positively, with
a mean decrease of 0.016. Peak-up magnitude showed only a small positive contribution.
Missing-data ratio produced approximately zero marginal importance, while standard
deviation, drop magnitude, SD ratio, and temporal slope showed small negative marginal
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 32 of 39
importance values. These results indicated that information provided by some statistical
and temporal features was partly redundant with other correlated features in the selected
model. Feature importance was calculated only after model selection and did not influence
tuning. The ten highest-ranked features are shown in Figure 16.
Table 15. Event-level performance of the selected 60 s random-forest classifier on the independent
test dataset.
Fault
Class
True
Events
Detected
Events
Conservative
Event Precision Event Recall Event Recall(95% CI) Event F1 Median Delay (s)
Drift 7 5 0.500 0.714 0.714 (0.359–0.918) 0.588 118
Spike 38 35 0.614 0.921 0.921 (0.792–0.973) 0.737 28
Failure 9 8 0.500 0.889 0.889 (0.565–0.980) 0.640 28
Overall 54 48 0.578 0.889 0.889 (0.778–0.948) 0.701 28
Figure 16. Permutation feature importance of the selected random-forest classifier based on the
decrease in independent-test macro-F1.
4. Discussion
Distinct baseline and temporal characteristics were observed among the environmental
and nutrient sensor signals. CO2 exhibited relatively large short-term variability even under
normal operating conditions, whereas pH and electrical conductivity remained compar-
atively stable. Temperature and relative humidity showed moderate baseline variation,
while light intensity exhibited abnormal patterns that were more clearly represented by
flat-line duration and abrupt signal reduction. These differences confirmed that a universal
variability threshold was unsuitable for all monitored variables. Sensor-specific charac-
terization was therefore required so that abnormal behavior could be evaluated relative
to the normal baseline and temporal response of each sensor. Similar requirements for
reliable environmental sensing, sensor-drift management, and sensor-specific monitoring
have been emphasized for smart vertical-farm systems [42,43]. Similar limitations of fixed
abnormality thresholds have been reported in greenhouse and wireless sensor monitoring
applications [26,29].
https://doi.org/10.3390/agriculture16232608
Agriculture 2026, 16, 2608 33 of 39
The selected random-forest classifier achieved substantially better independent-test
performance than the rule-based classifier. Accuracy increased from 0.392 to 0.642, bal-
anced accuracy increased from 0.384 to 0.659, and macro-F1 increased from 0.285 to 0.624.
Improvements of 0.250, 0.275, and 0.339 were obtained for accuracy, balanced accuracy,
and macro-F1, respectively. These results suggested that fixed sensor-specific thresholds
were insufficient when normal, drift, spike, and failure conditions shared overlapping
statistical characteristics. Improved discrimination was obtained when multiple baseline,
variability, continuity, and localized temporal features were combined through the nonlinear
decision structure of the random forest. A similar transition from conventional threshold-
based anomaly detection toward machine-learning approaches has been reported for status
monitoring and anomaly detection in smart greenhouse systems [44].
The uneven distribution of fault events across sensor types may have affected classifica-
tion performance. Specifically, CO2 measurements comprised 89.5% of spike events, while
light-intensity measurements accounted for 88.9% of failure events in the independent test
dataset. As a result, the classifier may have learned baseline and variability characteristics
specific to each sensor, in addition to fault-related temporal features. This association may
explain the relatively high spike classification perform
论文原文与出版信息
Agriculture (2026, 16)