Data Science And Analytics For Operations
November 19, 2026
Predictive Analysis Methodology for Performance Optimization in E-commerce: Correlation between Public Data and Paid Media
Rodrigo Prendim Kerassiotis; Edivan Alexandre Ferreira
DOI: 10.22167/2675-6528-202603823
Article derived from a Final Course 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
A predictive analysis methodology was developed for e-commerce, integrating transactional data and public search trends. The objective was to develop and validate a predictive model, based on machine learning algorithms, capable of correlating organic search trends with sales performance and paid media costs in the Beauty and Health category of Brazilian e-commerce. The Brazilian E-Commerce Public Dataset by Olist and data from Google Trends were used, processed in Python with the Random Forest Regressor algorithm. A moderate inverse correlation (r = -0.43) with a seven-day lag was identified between organic search volume and purchase. Initial models, based solely on behavioral variables, presented insufficient metrics (R² = -0.47; MAE of R$ 2,120.54). The incorporation of microeconomic (average ticket and shipping) and macroeconomic (exchange rate and Ibovespa index) variables raised the R² of the final model to 0.29, with an MAE of R$ 1,489.63, representing a 24.7% reduction in error compared to the baseline. Temporal cross-validation showed that, in periods of mature operation (2018), the model achieved an R² of 0.42. It was concluded that isolated search volume explains the consumer’s interest timing, but not the financial magnitude of sales, making the fusion with transactional and economic data mandatory for predictive viability.
Keywords: Beauty and Health; Consumer Behavior; Google Trends; Machine Learning; Time Series.
1. Introduction
The transformation of information into strategies in the digital marketing universe represents a fundamental contemporary challenge. Organizations face a scenario where data abundance does not necessarily mean strategic intelligence, as highlighted by Davenport (2014).
In the specific context of e-commerce, the scalability of operations depends on the ability to convert paid media investments into measurable revenue. The market still faces limitations in modeling scenarios that integrate endogenous data, such as sales history and costs, with exogenous data, such as public search trends. Chen et al. (2012) highlight the potential of business intelligence to transform large volumes of data into significant impacts, overcoming traditional interpretation barriers. The increasing complexity of digital environments demands technical analysis approaches, with data science needing artificial intelligence to interpret complex patterns (Hand, 2018).
Given this scenario, the gap lies in the absence of a quantitative methodology that translates the complexity of public trend data into effective parameters for optimizing media and sales performance in e-commerce. The ability to anticipate consumer behavior based on their search intent, before the purchase is made, represents a strategic competitive advantage.
This work is justified by the need to develop an approach that allows e-commerce managers to anticipate demand variations and optimize investments. The proposed methodology was designed to be modular and replicable, and can be generalized to other categories and corporate contexts that have consistent transactional historical series. The Beauty and Health category was selected for initial application and empirical validation due to its high volumetric representativeness in the dataset, high purchase recurrence, and strong correlation with consumer digital search behavior, characteristics that make it a privileged environment for validation. According to Kotler and Keller (2012), convenience and self-care products are strongly influenced by informational stimuli and active search in digital channels. Based on the perspective of Chen et al. (2012) that business intelligence transcends simple descriptive analysis, the central objective of this work is to develop and validate a predictive model, based on machine learning algorithms, capable of correlating organic search trends (public data) with sales performance and paid media costs in the Brazilian e-commerce Beauty and Health category, using the Brazilian E-Commerce Public Dataset by Olist as an empirical basis.
2. Material and Methods
The research was quantitative and experimental in nature, designed to develop and validate a predictive model. The study employed a methodological approach based on machine learning algorithms and time series analysis, aiming to correlate organic search trends with sales performance and paid media costs in e-commerce. The central objective was the creation of a replicable methodology for performance optimization.
The unit of analysis consisted of the performance of sales and paid media costs in the Beauty and Health category of Brazilian e-commerce. The empirical object was the Brazilian E-Commerce Public Dataset by Olist, covering the period from 2016 to 2018. Complementarily, data on search volume from Google Trends and macroeconomic information for the same period were used.
For data collection, the Brazilian E-Commerce Public Dataset by Olist, available on the Kaggle platform, which contains information on over one hundred thousand orders, was used. Search trend data were extracted from Google Trends through the pytrends library, using the term “cosmetics” and its variations. Macroeconomic variables, such as the Dollar/Real exchange rate and the Ibovespa Index, were obtained daily via the yfinance library.
The processing and modeling of the data were carried out in the Python programming language, using the Google Colab environment. The Pandas libraries were employed for data manipulation and organization, while Scikit-Learn (Pedregosa et al., 2011) provided the machine learning algorithms. This choice allowed for the integration of heterogeneous data sources and the scalable processing of large volumes of data.
The preprocessing stage involved filtering the Olist dataset for the “Health and Beauty” category, daily revenue aggregation, and temporal synchronization of data series between January 1, 2017, and August 30, 2018. Outlier treatment and data normalization were performed to construct a consistent analytical window. The cross-referencing of the olist_orders, olist_order_items, and olist_products tables resulted in 602 daily revenue records.
In feature engineering, time lag variables were created for search volume, with lags of seven, fourteen, and thirty days, to test the temporal correlation with revenue. Seasonality markers were inserted, represented by binary variables for holidays. The daily average ticket and the average shipping value were also calculated from the filtered Olist dataset, as microeconomic variables.
For predictive modeling, the Random Forest Regressor algorithm (Breiman, 2001) was selected, an ensemble method that combines multiple decision trees. The model was trained with 80% of the older data and evaluated on the most recent 20%, respecting the chronological order of observations to simulate a real prediction scenario and avoid data leakage. Hyperparameter optimization was performed using the Grid Search technique.
The model performance evaluation used two main metrics: the coefficient of determination (R²) and the Mean Absolute Error (MAE). R² measured the proportion of the variance in the dependent variable explained by the independent variables, while MAE quantified the average of the absolute errors between the actual and predicted values, expressed in reais. Temporal cross-validation (Time Series Split) with five sequential folds was applied to assess the model’s robustness across different operational periods.
To establish a benchmark, a baseline model was built using the DummyRegressor from the Scikit-Learn library, with a simple mean strategy. This baseline predicted for each observation in the test set the arithmetic mean of the daily revenue observed in the training set. The comparison with this model allowed us to quantify the performance gain of the proposed methodology.
The predictive relevance criterion for the coefficient of determination (R²) was established a priori at 0.25. This threshold, although not approaching unity, is considered relevant in behavioral and marketing sciences, according to Cohen (1988) and Hair et al. (2019), indicating significant explanatory power for multicausal phenomena. The adoption of this threshold avoided the retrospective adjustment of the success parameter.
3. Results and Discussion
The analysis of the research results allowed the validation of the proposed methodology for predictive analysis in e-commerce, focusing on the Beauty and Health category. Initial findings concentrated on identifying the temporal correlation between organic search volume and purchase completion, as per the first specific objective. Subsequently, the investigation moved on to quantify the financial magnitude of sales, incorporating transactional and macroeconomic variables, in line with the second objective. The progressive approach revealed that business intelligence, by integrating diverse data sources, transcends simple descriptive analysis, as advocated by Chen et al. (2012), and offers a strategic differential for performance optimization.
The results demonstrate that the ability to anticipate consumer behavior, based on their search intent, is a crucial component for optimizing media investments and demand management. The developed methodology, by integrating public trend data with transactional and economic information, offers a replicable tool for e-commerce managers. The following discussion details each step of the analysis, the empirical findings, their interpretations, and the practical implications for the marketplace environment, always in strict accordance with the data and conclusions of the original work.
Analysis 1: The Moment of Consumer Interest
The initial investigation sought to determine if there was a temporal correlation between the volume of organic searches and the completion of the purchase, testing the hypothesis of immediate causality. It was found that the Pearson correlation between the search volume for the term “cosmetics” and the daily revenue on the same day (lag 0) was practically null, with a coefficient of r = -0.05. This result refuted the hypothesis that the consumer who searches today buys today, which is consistent with Kotler and Keller’s (2012) consumer journey theory, which postulates an intermediate phase of evaluating alternatives before the purchase decision.
To capture the temporal phenomenon of the consumer journey, the temporal feature engineering technique was applied, creating time lag variables for search volume over 7, 14, and 30 days. Upon recalculating the correlations, it was identified that the `cosmeticos_lag_7` variable showed the strongest correlation with daily revenue, with a coefficient of r = -0.43. This moderate inverse correlation suggests a purchase decision cycle of approximately one week, where the peak of interest (organic search) precedes the order fulfillment by seven days.
The observed inverse correlation indicates that periods of high organic search tend to precede, on average, periods of slightly below-trend revenue. This dynamic can be explained by the concentration of searches in pre-purchase consideration phases, when the consumer is still evaluating alternatives and comparing prices before converting. This finding, although it does not guarantee a satisfactory R² in isolation, offers an actionable insight for e-commerce managers, allowing them to anticipate demand variations a week in advance and adjust inventory, logistics, and paid media investments before conversion peaks.
Based on these findings, a first Machine Learning model was trained using the Random Forest Regressor algorithm, with the predictor variables `cosmeticos`, `cosmeticos_lag_7`, `cosmeticos_lag_14`, and `cosmeticos_lag_30`. The dependent variable was the daily revenue of the Health and Beauty category. The model achieved an R² of -0.47 and a Mean Absolute Error (MAE) of R$ 2,120.54. This means that, on average, the model’s prediction missed the daily revenue by R$ 2,120.54 more or less, indicating a performance lower than the historical average.
The feature importance analysis in Model 1 confirmed that `cosmeticos_lag_7` was the greatest predictor used by the algorithm, followed by `cosmeticos_lag_30`. This reinforces the influence of weekly and monthly cycles on consumer behavior, possibly related to repurchase patterns or payment dates. However, the negative R² demonstrated that, although the model identified the moment of interest, it was still unable to predict the financial scale of sales, signaling the need for enrichment with new variables to achieve predictive viability.
Additionally, the hypothesis of using searches for major brands or seasonality flags as a proxy for media investment did not generate performance gains. Retraining the model with these variables resulted in R² oscillating between -0.43 and -0.53. This result suggests that the dynamics of a marketplace, such as Olist, have different influence vectors than large retailers, where promotions from major brands do not necessarily spill over into sales for small sellers. Purely behavioral and seasonal data, in isolation, proved insufficient to capture the total revenue variance of a fragmented e-commerce.
Analysis 2: The Quantification of Financial Magnitude
The limitation identified in Analysis 1, which revealed the inability to predict revenue magnitude using only behavioral search data, directed the second phase of the research. This stage focused on incorporating variables representing both the consumer’s transactional context and the macroeconomic environment, based on the hypothesis that “how much” the consumer spends is influenced by their purchasing power and willingness, not just search interest.
Incorporation of Microeconomic Variables
In the first model expansion, microeconomic variables extracted directly from the Olist dataset were incorporated. The average ticket (`avg_ticket`), representing the average transaction value in the Health and Beauty category, and the average freight value (`avg_freight`), corresponding to the average logistic cost per order, were calculated daily. The inclusion of these variables resulted in an immediate improvement in the model’s performance, raising the R² from -0.47 to 0.26 and reducing the MAE to R$ 1,495.60.
The importance analysis of the variables revealed that the average ticket (`avg_ticket`) became the predictor with the greatest power in the model, surpassing the behavioral variable `cosmeticos_lag_7`. This finding is interpreted as a confirmation that, regardless of the volume of interest generated by searches, perceived cost is a final deciding factor. The consumer converts when the price and shipping conditions are compatible with their budget, which is aligned with the alternative evaluation stage of the consumer journey described by Kotler and Keller (2012).
Incorporation of Macroeconomic Variables
In the second expansion, macroeconomic variables related to the dataset’s coverage period (2017-2018) were integrated. The Dollar/Real exchange rate (`dolar`), as an indicator of inflationary pressure on products with imported components, and the Bovespa Index (`ibovespa`), used as a proxy for the financial market confidence index and the propensity to consume non-essential items, were included. The integration of these variables refined the final model, resulting in an R² of 0.29 and an MAE of R$ 1,489.63.
The Bovespa Index (`ibovespa`) emerged as the third most relevant variable in the model, suggesting that the financial market confidence index acts as a thermometer for the propensity to consume non-essential items, such as beauty products. Although the marginal gain of these macroeconomic variables was lower than that of the transactional variables, their inclusion contributed to adjusting the prediction to the current economic environment, providing a more complete context for decision-making.
Comparative Validation and Model Robustness
To prove the methodology’s effectiveness, the final model was compared to a naive baseline, the Dummy Regressor with a simple average strategy. The baseline presented an R² of -0.39 and an MAE of R$ 1,977.33. In contrast, the final model achieved an R² of 0.29 and an MAE of R$ 1,489.63. This comparison demonstrates that the proposed model reduced the average error by approximately 24.7% compared to the baseline, representing a material gain of R$ 487.70 per day in the average error.
The negative R² of the baseline is an indicator of the non-stationarity of the revenue series, where the consistent growth of Olist’s operation in 2017 and 2018 caused the historical average to underestimate future values. The R² of 0.29 for the final model, although not close to one, exceeds the threshold of 0.25 established a priori as a criterion for predictive relevance, according to statistical conventions for behavioral sciences and marketing (Cohen, 1988; Hair et al., 2019). It is recognized, however, that approximately 71% of the daily revenue variance remains unexplained, which limits the application of the methodology to directional tactical planning, and not to financial projection with accounting precision.
Operational Maturity Analysis
Temporal cross-validation, using the Time Series Split technique with five folds, revealed a crucial insight into the methodology’s applicability. A significant disparity in model performance was observed between the analyzed periods. For early-stage operations (2017), R²s ranged between -0.45 and -0.03, indicating high volatility and low data volume that prevented accurate prediction. In contrast, for mature operation periods (2018), the model achieved R²s of 0.42 and 0.29.
This phenomenon demonstrates that the methodology’s applicability is directly proportional to the consistency and granularity of the transactional history available for calibration. In more mature operational environments, where noise is lower and transaction volume is more constant, the model performs satisfactorily, validating its usefulness for consolidated companies. Operations in the ramp-up phase, with inconsistent data, do not provide sufficient signal for effective calibration of the predictive model.
Layered Architecture of the Proposed Methodology
The evolutionary trajectory of the model, starting from an initial R² of -0.47 with isolated behavioral data to a definitive R² of 0.29 (and 0.42 in mature operation) with micro and macroeconomic variables, validates the layered architecture of the proposed methodology. This architecture organizes the predictive process into three main factors: Anticipation, Calibration, and Context. Public organic search data acts as the central element of anticipation, being calibrated by contextual variables that quantify the magnitude of conversion.
The Anticipation layer is represented by the Behavioral factor, using the key variable `cosmeticos_lag_7`, whose function is to anticipate the moment of consumer interest by seven days. The Calibration layer, of a Financial nature, employs the key variable `avg_ticket` to quantify the expected magnitude of conversion. Finally, the Context layer, of a Macroeconomic character, uses the key variable `ibovespa` to adjust the prediction to the current economic environment. This modular and replicable structure allows the methodology to be extended to other product categories and corporate contexts, provided that there are consistent transactional historical series and representative search terms.
In summary, the research demonstrated that the volume of organic searches, although crucial for identifying the moment of consumer interest, is not sufficient to predict the financial magnitude of sales in a marketplace environment. The fusion with transactional data, such as average ticket and shipping costs, and macroeconomic variables, such as exchange rate and Ibovespa Index, is mandatory for predictive viability. The definitive model, by integrating these layers of information, achieved relevant performance, surpassing the baseline and validating the methodology for tactical e-commerce performance optimization, especially in operations with a consistent transactional history.
4. Conclusion
This study aimed to develop and validate a predictive model, based on machine learning algorithms, capable of correlating organic search trends with sales performance and paid media costs in the Beauty and Health category of Brazilian e-commerce. Initially, a moderate inverse correlation was found, with a seven-day lag, between organic search volume and purchase completion, indicating a consumer decision cycle. Predictive models based exclusively on behavioral search variables showed insufficient metrics, with R² negative and MAE of R$ 2,120.54, demonstrating the inability to predict the financial magnitude of sales solely by the moment of interest. The incorporation of microeconomic variables, such as average ticket and shipping costs, increased R² to 0.26 and reduced MAE to R$ 1,495.60, with the average ticket emerging as the most relevant predictor. The inclusion of macroeconomic variables, such as exchange rate and Ibovespa Index, refined the final model to an R² of 0.29 and an MAE of R$ 1,489.63, representing a 24.7% reduction in error compared to the baseline. This methodology, organized in layers of anticipation, calibration, and context, offers a replicable tool for e-commerce managers.
Temporal cross-validation revealed that the methodology’s applicability is directly proportional to the consistency of the transactional history, achieving an R² of 0.42 in periods of mature operation. However, it is recognized that approximately 71% of the daily revenue variance remains unexplained, which limits the model’s application to directional tactical planning and not to accounting-precision financial projection. As a suggestion for future studies, the integration of proprietary paid media data is recommended to fill the “qualified intent” gap and refine predictability metrics. Additionally, confronting the model with seasonal naive baselines and replacing macroeconomic variables with specific sectoral indices can improve the methodology’s adherence to different market contexts. The study contributes a modular framework for e-commerce performance optimization, allowing for demand variations anticipation and data-driven investment optimization.
Bibliographic References
Breiman, L. 2001. Random Forests. Machine Learning, v. 45, n. 1, p. 5-32.
Chen, H.; Chiang, R. H. L.; Storey, V. C. 2012. Business Intelligence and Analytics: From Big Data to Big Impact. MIS Quarterly, v. 36, n. 4, p. 1165-1188.
Cohen, J. 1988. Statistical Power Analysis for the Behavioral Sciences. 2. ed. Lawrence Erlbaum Associates, Hillsdale, NJ, USA.
Davenport, T. H. 2014. Big Data no Trabalho: Eliminando Mitos, Descobrindo Oportunidades. Campus, Rio de Janeiro, RJ, Brasil.
Hair, J. F.; Risher, J. J.; Sarstedt, M.; Ringle, C. M. 2019. When to use and how to report the results of PLS-SEM. European Business Review, v. 31, n. 1, p. 2-24.
Hand, D. J. 2018. Artificial Intelligence Needs Data Science. International Statistical Review, v. 86, n. 3, p. 420-434.
Kotler, P.; Keller, K. L. 2012. Administração de Marketing. 14. ed. Pearson Prentice Hall, São Paulo, SP, Brasil.
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, E. 2011. Scikit-learn: Machine Learning in Python. Journal of Machine Learning Research, v. 12, p. 2825-2830.
Article originating from the Final Course Work 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