October 09, 2026
Predictive Model for Pest Incidence in Sugarcane with Temporal Validation
Predictive Model for Pest Incidence in Sugarcane with Temporal Validation
Luiz Otávio Leonardo; Orlando da Silva Junior
DOI: 10.22167/2675-6528-202603215
Article derived from a Course Conclusion Work (TCC), with content based on the student’s original work and adapted to the editorial format of the E&S Magazine with the support of the ResumeAI tool, an artificial intelligence solution developed by Instituto Pecege for textual synthesis and organization.
Summary
The incidence of pests in sugarcane represented a relevant challenge for phytosanitary planning, due to its temporal and spatial variability and impact on monitoring decisions. A predictive approach was developed and evaluated to estimate pest incidence, using climatic variables and recent history, respecting the temporal structure of the records and addressing the excess of zeros in the response variable. The research used a public Kaggle database, where preprocessing, quality diagnosis, exploratory analysis, and feature engineering were performed, including lags, moving windows, and cyclic encoding of seasonality. A two-stage system was implemented: a classification model estimated the occurrence (zero versus greater than zero) and a regression model estimated the conditional intensity. Validation occurred by temporal split between training and testing, with specific metrics and interpretability analysis by permutation importance. The results indicated low discriminative capacity in the occurrence stage and limited performance in intensity prediction, with difficulty in representing peaks and the long tail, suggesting informational restriction of the available variables. It was concluded that the pipeline was methodologically coherent and reproducible for zero-inflated data, but the predictive gain depended on enriching the database with agronomic and operational variables more directly related to the infestation mechanism.
Keywords: Machine Learning; Sugarcane; Predictive modeling; Agricultural pests; Temporal validation.
1. Introduction
Sugarcane cultivation holds significant economic and operational relevance in agribusiness, with its productive performance intrinsically linked to phytosanitary management and efficient response capacity to pest incidence events. Within the context of Integrated Pest Management, decision-making regarding when and where to intensify monitoring and intervention is fundamental, depending on reliable and timely information, as well as the understanding of temporal and spatial patterns of the phenomenon (Kogan, 1998; Dent, 2000).
In practice, field records often exhibit heterogeneity across regions, coverage variations, and gaps over time. This reality amplifies uncertainty and hinders the anticipation of critical infestation periods, generating a demand for quantitative approaches that can support operational planning, without disregarding the inherent limitations of observational data.
In recent years, data science and machine learning have been widely employed to enhance analytical capabilities in agricultural problems, both for prediction and decision support. These methods are valued for their ability to handle non-linear relationships and complex interactions between variables (Bishop, 2006; Goodfellow; Bengio; Courville, 2016). However, the validity of conclusions on real-world datasets depends on the quality and completeness of the variables, and evaluations that disregard the temporal structure of the data may overestimate performance and compromise the validity of the results. For time series, the separation between training and testing must respect chronological order, avoiding information leakage and producing realistic estimates for future forecasting scenarios (Hyndman; Athanasopoulos, 2021).
Additionally, pest incidence bases often exhibit an asymmetric count distribution, with a long tail and excess zeros. This pattern is compatible with situations where a significant portion of the records indicates the absence of the event, while another part concentrates positive occurrences with varying intensities. Statistical literature addresses this scenario through zero-inflated models, such as the Zero-Inflated Poisson (Lambert, 1992). Hurdle-type models and two-process formulations, like Cragg’s (1971) proposal, support two-stage modeling, distinguishing the probability of the event’s occurrence from the conditional intensity when the event occurs. This distinction is relevant, as occurrence and intensity may respond differently to covariates.
In the context of applied data science, model construction must be accompanied by methodological traceability and interpretability, especially when the objective is to support decisions. Permutation importance-based interpretability is a consolidated strategy for examining the relative contribution of variables (Breiman, 2001). Reproducibility is favored by widely used machine learning libraries, provided that the steps, parameters, and validation procedures are explicitly stated (Pedregosa et al., 2011). Given this scenario, the realization of this study is justified by the need to evaluate, on a real public dataset of sugarcane pest incidence, the extent to which climatic variables and recent history would be capable of sustaining useful predictions in an environment marked by temporal gaps, regional heterogeneity, and excess zeros. The relevance of the problem stems from the potential to contribute to monitoring planning and operational prioritization, maintaining methodological rigor and describing the limitations imposed by the data (Gil, 2008; Vergara, 2016).
The objective was to develop and evaluate a predictive approach to estimate pest incidence in sugarcane from climatic variables and recent history, respecting the temporal structure of the records and explicitly addressing the zero-inflated nature of the target through a two-stage modeling: (i) a classification model to estimate occurrence (0 versus >0) and (ii) a regression model to estimate conditional intensity when occurrence is predicted, with interpretation supported by permutation importance and metrics suitable for the tasks.
2. Material and Methods
The present study was characterized as an applied research, with a quantitative approach, and descriptive and explanatory objectives. Applied research was oriented towards the solution of a practical problem related to the prediction of pest incidence in sugarcane cultivation, seeking to generate knowledge for practical application in the agricultural context (Gil, 2008; Vergara, 2016). The quantitative approach involved the treatment of numerical data, statistical modeling, and evaluation by objective performance metrics.
Regarding the objectives, the research was descriptive, as it sought to characterize the behavior of the pest incidence variable, identifying distribution patterns, presence of zeros, seasonality, and regional heterogeneity. It was also explanatory, by analyzing the relationships between climatic, temporal, and contextual variables and the occurrence and intensity of the phenomenon through predictive models (Gil, 2008; Vergara, 2016).
The database used was obtained from the online repository Kaggle, a public platform that provides structured datasets for research. This database gathered observational records related to pest incidence in sugarcane cultivation, as well as climatic, temporal, and contextual information. The data collection period included records accumulated over the years available in the database, covering various harvests and cultivation cycles, in different locations and sugarcane varieties.
The main response variable consisted of the count of pests found by observation, characterized by asymmetric distribution and a relevant presence of zeros. The predictor variables encompassed climatic information, such as precipitation, seasonal components derived from the calendar, and categorical attributes related to sampling location and cane variety. The selection of variables was guided by agronomic plausibility and availability in the public database.
Data preprocessing was conducted to ensure consistency and integrity. Structural inspection of the dataset was performed, including checking variable types, identifying missing values, detecting inconsistencies, and preliminary analysis of the response variable distribution. A specific diagnosis of climatic variables was carried out, with an emphasis on precipitation, to identify anomalous patterns that could indicate systemic inconsistency.
Duplicated records were identified and categorical fields were standardized to ensure uniformity. Temporal variables were converted to the appropriate date format, enabling correct chronological ordering. The preprocessing aimed to balance data preparation for modeling with the preservation of the original characteristics of the observed phenomenon, avoiding interventions that could distort the zero-inflated nature of the response variable.
After preprocessing, the variables were integrated and standardized into a single tabular format, with each row representing an observation associated with a period, location, and set of explanatory variables. Temporal consistency was treated as a central element, with dates converted to a standardized format, allowing for proper chronological ordering and analyses based on the actual sequence of events.
The division between training set and test set was performed respecting the time progression, using historical data for training and a later period for evaluation, simulating a real forecasting scenario and avoiding information leakage (Hyndman; Athanasopoulos, 2021). Collection gaps were maintained in the original base, without artificial insertion of records.
Exploratory data analysis was conducted to understand the behavior of the response variable and the explanatory variables. Descriptive measures of pest incidence were examined, including minimum, maximum, median, dispersion, and the proportion of records with zero values. Distributions by region and variety were analyzed, and the temporal dimension was investigated through time series, visualizing trends and seasonality.
The feature engineering step expanded the model’s explanatory capacity. Temporal lags of climatic variables, especially precipitation, were created, and statistics were calculated in moving windows, such as accumulated averages. Seasonality was incorporated through temporal variables derived from the calendar, with the month transformed by trigonometric encoding (sine and cosine).
Categorical variables, such as collection region and sugarcane variety, were transformed into a numerical format compatible with supervised learning algorithms. Encoding was performed consistently between the training and testing sets, using, when applicable, the one-hot encoding strategy to avoid artificial ordering among nominal categories.
The predictive modeling was structured in two stages to address the count response variable with excess zeros (Cragg, 1971; Lambert, 1992). In the first stage, a supervised classification model was implemented to estimate the probability of pest occurrence (zero versus greater than zero). The model was trained with the prepared explanatory variables, respecting the temporal division.
In the second stage, a regression model was implemented to estimate the intensity of the response variable, conditioned on the prediction of a positive occurrence from the previous stage. The regression model was trained only with observations of positive values, and the response variable was transformed into the logarithmic space (log1p) to handle asymmetry and extreme values. The combination of the stages resulted in an integrated predictive system.
The calibration of the decision threshold at the occurrence stage was performed automatically based on the distribution observed in the test set, seeking to align the proportion of records classified as absence of pests with the actual proportion of zeros. In the training of the intensity model, numerical stabilization strategies were adopted, including control of predicted extreme values and limitation of estimates to the interval compatible with the maximum observed in the training set.
The model’s performance evaluation was conducted separately for each stage and for the final combined prediction. In the occurrence stage, binary classification metrics were used, such as Area Under the ROC Curve (AUC), confusion matrix, accuracy, precision, and recall. For the intensity stage and the final prediction, error metrics for continuous data were employed, including Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), and coefficient of determination (R²).
Considering the asymmetry of the response variable, relative metrics such as WMAPE and sMAPE were included. The evaluation was performed exclusively on the test set, respecting the temporal split. To understand the relative contribution of the explanatory variables, permutation importance analysis was applied at both stages (Breiman, 2001).
The development of the treatment, modeling, and evaluation stages was carried out in a computational environment using the Python language, with the aid of the pandas and NumPy libraries for data manipulation. Exploratory analyses and graph generation were performed with Python visualization libraries. The supervised modeling stages were implemented with machine learning libraries, with explicit definition of parameters and manual calculation of performance metrics (Pedregosa et al., 2011).
Additionally, a complementary analysis was performed with monthly data aggregation, consolidating records by monthly period and aggregating climatic variables in a compatible manner. This approach sought to investigate possible gains in stability resulting from the reduction of operational noise, while maintaining the same methodological strategy of temporal division, two-stage modeling, and evaluation by metrics.
3. Results and Discussion
The study sought to develop and evaluate a predictive approach to estimate pest incidence in sugarcane, using climatic variables and recent history. The findings revealed that, although the two-stage modeling architecture was methodologically consistent for data with excess zeros, the final predictive capacity was substantially limited by the informational richness of the available variables. Both the occurrence and intensity stages presented challenges, indicating that climatic and historical attributes, by themselves, were not sufficient to capture the complexity of infestation dynamics with the precision required for operational planning.
The model’s performance evaluation in line mode, which maintained the original granularity of the records, demonstrated significant challenges. The Area Under the ROC Curve (AUC) for the occurrence stage, responsible for classifying the presence or absence of pests, was 0.4984. This value, very close to 0.5, indicates a low discriminative capacity, suggesting that the model failed to robustly distinguish between cases of absence and presence of pests based on the provided input variables. Such a result points to a fundamental limitation in the model’s ability to predict the onset of an infestation.
The model’s performance at the occurrence stage, which resembles random classification, suggests that the available variables, such as climatic data, seasonal components, and recent historical records, did not contain a strong enough predictive signal to identify pest outbreak patterns. This can be attributed to the absence of crucial explanatory factors, often present in real agricultural contexts, such as specific management practices, crop phenological stage, local pest pressure, history of pesticide applications, and monitoring sampling effort. The lack of this information prevents the model from capturing the complexity underlying the phenomenon.
In the intensity stage, which aimed to estimate the magnitude of pest incidence when occurrence was predicted, the model also exhibited limited performance. The Mean Absolute Error (MAE) was 40.9601 and the Root Mean Squared Error (RMSE) reached 72.9624. Additionally, the coefficient of determination (R²) resulted in a negative value of -7.0909. A negative R² is an indication that the model performed worse than a simple benchmark model that would use only the average of observed values as a prediction, highlighting the difficulty in explaining the variability of pest incidence.
The high errors and negative R² in the intensity stage reflect the model’s difficulty in representing the long-tail distribution, characteristic of pest incidence data. A tendency to underestimate occurrence peaks and an inability to capture extreme values present in the dataset were observed. This behavior is often associated with heteroscedasticity, where the variance of errors is not constant, and the complexity of predicting rare but high-magnitude events. Although the logarithmic transformation of the response variable was applied for numerical stability, it did not add new predictive information.
The analysis of the relationship between observed and predicted values in the line mode revealed considerable dispersion, with errors tending to increase as the actual pest incidence grew. This pattern confirmed heteroscedasticity and the model’s difficulty in predicting higher infestation levels. The model frequently underestimated significant peaks, while in some intermediate ranges, overestimation occurred. Over time, the model partially followed the direction of variations but showed low fidelity in amplitude, especially during peak events, suggesting a weak temporal signal and dependence on unobserved factors.
The distribution of model residuals in line mode corroborated these observations, showing asymmetry and pronounced tails. This indicates that prediction errors were not limited to small variations but included substantial deviations, particularly at points of higher incidence. This pattern reinforces the influence of outliers and the long tail on the degradation of global performance metrics. The model’s inability to accurately capture these extreme events and the overall data variability limited its practical utility for precise operational planning, where accurate prediction of high-incidence periods is fundamental.
The permutation importance analysis of variables in the intensity stage, in the line mode, provided insights into the relative contribution of each explanatory attribute. The ranking of variables indicated that attributes derived from historical and climatic aggregations, such as monthly precipitation, had a greater influence on the model’s predictions. This result is consistent with the hypothesis that pest incidence is affected by accumulated effects and lagged responses to environmental conditions. However, the magnitude of the performance gain associated with these variables remained limited, reinforcing the conclusion that the dataset lacked robust informational signals for accurate prediction.
The predominance of temporal components, seasonal indicators, and climatic aggregations among the most relevant variables, as identified by permutation importance (Breiman, 2001), suggests that the model primarily captured patterns related to calendar cycles and recent history. Although these patterns are consistent with seasonality-influenced biological phenomena, they proved insufficient for accurately predicting the occurrence and magnitude of pest infestations. This limitation highlights the critical need to enrich the dataset with more detailed agronomic and operational variables, such as specific cane varieties, planting dates, soil conditions, and pest management interventions, to enhance the model’s predictive power.
In addition to the baseline mode, a complementary analysis was performed using monthly aggregated data, with the objective of investigating possible stability gains by reducing short-term noise. However, the aggregation resulted in a decrease in the number of observations and altered the distribution of the target variable, with a predominance of positive values. In monthly mode, the AUC for the occurrence stage was 0.0870, a substantially lower value than in the baseline mode, which further compromised the utility of the classification step.
For the regression stage in aggregate monthly mode, performance metrics also showed significant degradation. The RMSE was 1005.4727 and the MAE was 641.0765, with a negative R² of -4.2737. These values indicate that the model’s predictions were considerably worse than a simple baseline, reflecting the challenges introduced by the change in scale and the reduction in sample size. The dispersion between observed and predicted values remained high, with larger absolute errors due to the effect of the monthly sum, and the variability between months and the presence of concentrated peaks continued to dominate the global metrics.
The distribution of residuals in the monthly mode also exhibited high variability and asymmetry, consistent with the high RMSE. This pattern suggests that temporal aggregation failed to resolve the limitation of the explanatory signal. The comparison between the two data granularity modes indicated that aggregation did not provide a consistent improvement in predictive performance. This may be attributed to the reduction in the number of observations, which may have weakened statistical robustness, and to the alteration of the target variable’s distribution, which potentially reduced the contrast between classes in the occurrence stage and amplified instability due to scale changes.
The two-stage modeling architecture, adopted in this study, was methodologically consistent with the nature of the data, which presented a count distribution with excess zeros, asymmetry, and a long tail. This approach is aligned with the literature on zero-inflated models (Lambert, 1992) and hurdle models (Cragg, 1971), which distinguish the probability of an event’s occurrence from its conditional intensity. However, empirical results consistently demonstrated that the final predictive capability was severely limited by the informational content available in the public dataset, reinforcing that machine learning performance critically depends on both the algorithm and the informativeness and quality of the variables (Bishop, 2006).
The low discriminative capacity observed at the occurrence stage, with an AUC value close to 0.5 in the line mode, suggests that the available climatic and historical variables were insufficient to consistently differentiate the presence from the absence of pest infestations. This limitation points to the absence of unobserved factors in the dataset that are crucial for agricultural pest dynamics. Such factors include management practices, crop phenological stage, local pest pressure, pesticide application history, and monitoring sampling effort, which are determinants of pest occurrence and are generally not present in generic public databases.
Temporal validation, which chronologically separated the training and testing sets, strengthened the credibility of the results by preventing information leakage and providing a more realistic assessment of the model’s performance in future prediction scenarios, as recommended for time series (Hyndman; Athanasopoulos, 2021). However, at the intensity stage, the combination of high errors and a negative R² indicated that the model did not outperform a simple baseline. This behavior is expected in scenarios with heteroscedasticity and the difficulty of anticipating extreme values, as models tend to underestimate peaks and concentrate predictions in intermediate ranges.
The application of logarithmic transformation and other stabilization mechanisms contributed to the numerical robustness of the intensity model, but did not introduce new information where it did not exist. This reinforces the conclusion that the main limitation was informational, not just algorithmic. Permutation importance interpretation was valuable for identifying the few variables that sustained the signal captured by the model (Breiman, 2001). This model-agnostic method offered a transparent view of the relative contribution of attributes, confirming that the model was primarily based on temporal patterns and climatic aggregations.
In summary, the study developed and evaluated a predictive approach for pest incidence in sugarcane, following rigorous methodological standards, including temporal validation and a two-stage model for zero-inflated data. The results consistently demonstrated that, although the structure was robust, the predictive utility of the available climatic and historical variables in the public dataset was limited. Significant improvements in predictive performance would depend on enriching the dataset with more relevant agronomic and operational variables, such as detailed management practices, crop phenology, and standardized monitoring data, in addition to a higher temporal density of records.
4. Conclusion
This study sought to develop and evaluate a predictive approach to estimate pest incidence in sugarcane, using climatic variables and recent history, with due consideration of the temporal structure of the records and the zero-inflated nature of the response variable through a two-stage modeling. It was found that, although the proposed modeling architecture was methodologically coherent and reproducible for data with excess zeros, the final predictive capacity was substantially limited by the informational richness of the available variables. In the occurrence stage, low discriminative capacity was observed, with the model failing to robustly distinguish between the presence and absence of pests. Similarly, in the intensity stage, performance was limited, with high errors and a negative coefficient of determination, indicating difficulty in representing the long-tail distribution and occurrence peaks. Permutation importance analysis revealed that historical attributes and climatic aggregations exerted some influence, but the overall predictive signal remained weak. The main contribution of the work lies in the empirical and methodologically rigorous demonstration that the predictability of pest incidence, with the set of climatic and historical variables available in public databases, is restricted, providing a technical basis for future improvements in decision support for phytosanitary management.
The study’s limitations stem mainly from the absence of crucial explanatory factors in the public dataset, such as specific management practices, the crop’s phenological stage, local pest pressure, the history of pesticide applications, and the sampling effort for monitoring, which are determinants of the occurrence and intensity of infestations. The monthly aggregation of data, explored as a complementary analysis, did not result in a consistent improvement in predictive performance, reinforcing the informational restriction. To significantly enhance predictive power, it is suggested that future studies enrich the database with agronomic and operational variables more directly related to the infestation mechanism, in addition to seeking greater standardization and temporal density of records, allowing for a more complete understanding and more precise modeling of pest dynamics in sugarcane.
Bibliographic References
Bishop, C.M. 2006. Pattern Recognition and Machine Learning. Springer, New York, NY, USA. 738 р.
Breiman, L. 2001. Random Forests. Machine Learning 45(1): 5-32.
Cragg, J.G. 1971. Some Statistical Models for Limited Dependent Variables with Application to the Demand for Durable Goods. Econometrica 39(5): 829-844.
Dent, 2000 [Referência completa não encontrada no documento original]
Gil, A.C. 2008. Métodos e Técnicas de Pesquisa Social. 6ed. Atlas, São Paulo, SP, Brasil. xvi, 200 р.
Goodfellow, I.; Bengio, Y.; Courville, A. 2016. Deep Learning. MIT Press, Cambridge, MA, USA. 800 p.
Hyndman, R.J.; Athanasopoulos, G. 2021. Forecasting: Principles and Practice. 3ed. OTexts, Melbourne, Australia. Disponível em: https://otexts.com/fpp3/. Acesso em: 26 fev. 2026.
Kogan, M. 1998. Integrated Pest Management: Historical Perspectives and Contemporary Developments. Annual Review of Entomology 43(1): 243-270.
Lambert, D. 1992. Zero-Inflated Poisson Regression, With an Application to Defects in Manufacturing. Technometrics 34(1): 1-14.
Pedregosa, F.; Varoquaux, G.; Gramfort, A.; Michel, V.; Thirion, B.; Grisel, O.; Blondel, M.; Prettenhofer, P.; Weiss, R.; Dubourg, V.; Vanderplas, J.; Passos, A.; Cournapeau, D.; Brucher, M.; Perrot, M.; Duchesnay, É. 2011. Scikit-learn: Machine Learning in Python. Journal of Machine Learning Research 12: 2825-2830.
Vergara, S.C. 2016. Projetos e Relatórios de Pesquisa em Administração. 16ed. Atlas, São Paulo, SP, Brasil. 94 p.
Article originating from the Final Course Project of the Specialization in Data Science and Analytics of the MBA USP/Esalq
To learn more about the course, click here and access the MBX Academy platform