Zero Labs
Industry News / Technology

Product Sales Forecasting through Time Series Analysis (EDA)

Source · Towards AI By Nikumbhdeepti

From the publisher’s feed, collected in the ZeroLabs newsroom.

This blog is part 2 of the blog series on “Product Sales Forecasting through Time Series Analysis.” In this part we will discuss in detail the exploratory data analysis through univariate analysis, bivariate analysis, time series decomposition, missing value detection, outlier detection, and treatment.The dataset can be found on the link.EDA (Exploratory Data Analysis) is a systematic approach to understanding the data, uncovering trends, detecting outliers, performing feature engineering, and visualizing relationships within the dataset.One obvious question is how is Power BI analysis different from the EDA?Power BI visualization provides a high-level, business-oriented view of sales performance. This is done through interactive dashboards and KPIs. On the other hand, Exploratory Data Analysis (EDA) goes a step deeper by statistically analyzing the data to uncover patterns, distributions, anomalies, and relationships. Power BI answers what is happening in the business, whereas EDA helps explain why it is happening and prepares the data for predictive modeling. Power BI visualizations are mainly for the business users and stakeholders, whereas EDA is used by data analysts and data scientists.Exploratory Data Analysis (EDA)To understand the distribution of sales and order volumes in different regions, daily average sales and daily average orders for each region (R1–R4) are computed. A univariate analysis using histograms is performed on these data. Histograms examine the central tendency, spread, and skewness of the data.Across all regions, the average sales distributions are right-skewed as well as left-skewed, indicating that while most days record moderate sales, a smaller number of days contribute significantly higher sales values and lower sales values.Region R1 shows the highest average sales range, with the distribution centered at a higher value (red dotted line) compared to other regions. This indicates R1’s strong sales performance, also observed in the Power BI analysis. Regions R2 and R4 display relatively similar sales distributions, though their mean sales (red dotted line) are lower than R1. Region R3 exhibits a longer right tail, suggesting occasional high-sales days but less consistency. The presence of extreme values in all regions suggests outliers. The possible reason for outliers could be because of seasonal variations, promotional events, or exceptional demand days.In the case of average orders (red dotted line), region R1 has higher average order volumes, aligning with its dominant sales performance. Regions R2 ,R3 and R4 show moderate order volumes. Relatively tighter distributions are observed for R2 and R3, indicating more stable daily demand. The narrower spread in orders compared to sales suggests that sales variability is influenced not only by order count but also by order value. Higher sales are not solely driven by higher order counts; average order value plays a significant role, especially in regions like R1.Histogram of average sales and average ordersThe presence of skewness in average orders across all regions is seen. This indicates fewer high-order or low-order days. These are treated as outliers, and robust outlier removal methods may be required during modeling.The univariate analysis reveals that both sales and order volumes across regions are skewed. Region R1 consistently outperforms others in terms of central tendency. Variability across regions highlights the influence of high-value transactions and seasonal demand spikes.Further, region-wise store distributions are presented. Clearly a higher number of stores are present in R1, which justifies its higher sales. The count of stores in R2 and R3 is higher than R4, but if we look at the overall sales, the contribution by R4 is higher than these two.Bar chart of region-wise store countBivariate AnalysisTo better understand the relationship between location type, store type, and sales across regions, region-wise heatmap visualizations are created. These heatmaps provide a clear view of how different combinations of store types and location types contribute to overall sales performance.The analysis reveals that Location Type L1 has all store types and consistently contributes the highest share of sales in every region. This indicates that L1 locations are strategically important and serve as key revenue drivers.In contrast, combinations involving Location Types L3, L4, and L5 with Store Types S3 and S4 are either sparse or entirely absent across most regions. This lack of presence explains the relatively lower sales contribution from these store–location combinations.Across all regions, the combination of Location Type L1 and Store Type S4 generates the highest sales, followed closely by other high-performing store types operating within L1 locations. This pattern highlights the strong influence of both store format and location on sales performance.Heatmap visualization for region-wise, location-wise, and store-wise salesFurther in bivariate analysis, regional-wise sales performance across discounted and non-discounted days is done. The visualizations clearly indicate that sales are significantly higher on discounted days, highlighting the strong positive impact of promotional activities on customer purchasing behavior.In contrast, the comparison between holiday sales and regular non-holiday sales shows that holidays tend to generate relatively lower sales volumes. This suggests that, despite increased customer footfall expectations, holidays do not necessarily translate into higher sales, possibly due to reduced store operations or altered consumer spending patterns.Sales on discounted and non discounted daysSales on holiday and non-holiday daysTo better understand the temporal behavior of sales across regions, a time series decomposition is performed on the average daily sales for each region. The decomposition separates the series into trend and seasonal components, enabling clearer insights into long-term movements and recurring patterns.Region-wise trend decompositionAll regions demonstrate no strong long-term upward or downward trend, suggesting a mature sales pattern. Variations are primarily driven by short-term effects rather than structural growth or decline.Region-wise seasonal decompositionThe seasonal plots highlight recurring patterns that repeat at fixed intervals over time. All regions exhibit strong and consistent seasonality, with identical repeating patterns throughout the year.The magnitude of seasonal fluctuations is significant, indicating that sales are heavily influenced by calendar effects, such as● Weekly buying cycles● Monthly demand surges● Promotional and discount-driven spikesThe seasonal pattern remains stable across years, suggesting predictable customer behavior. Regions R1 and R3 show slightly higher seasonal amplitude, indicating stronger responsiveness to periodic factors.Regions R2 and R4 show similar seasonal structures but with lower intensity.The decomposition reveals that sales across all regions are seasonality-driven rather than trend-driven. While regional sales volumes differ, the underlying temporal behavior is structurally similar, making time-series–based forecasting models highly suitable for this dataset.Strong seasonality implies that forecasting models must explicitly account for seasonal effects (e.g., SARIMAX, Prophet, LSTM). Since trends are relatively stable, short-term forecasting accuracy will depend more on capturing seasonality than long-term growth patterns.Inventory planning, staffing, and promotional strategies should be aligned with these recurring seasonal cycles rather than relying solely on trend growth.As part of the exploratory data analysis, outlier detection and treatment were performed to ensure data robustness. Region-wise box plot visualizations of both sales and order quantities were used to identify extreme values.Outlier detection on average sales and average ordersOutliers were handled using the Interquartile Range (IQR) method. For each variable, the first (Q1) and third (Q3) quartiles were computed, and the IQR was defined as the difference between Q3 and Q1. Based on this, lower and upper bounds were established. Observations falling below the lower bound were capped at the lower bound value, while those exceeding the upper bound were capped at the upper bound. This approach preserves data volume while reducing the influence of extreme values.# removing the outliersi = 1outlier_treated_data={}for region, data in region_eda_avg.items(): q1_s=data['avg_sales'].quantile(0.25) q3_s=data['avg_sales'].quantile(0.75) iqr_s=q3_s-q1_s lower_bound = q1_s - 1.5 * iqr_s upper_bound = q3_s + 1.5 * iqr_s data['avg_sales'] = np.where(data['avg_sales'] > upper_bound, upper_bound,np.where(data['avg_sales'] q1_o=data['avg_orders'].quantile(0.25) q3_o=data['avg_orders'].quantile(0.75) iqr_o=q3_o-q1_o lower_bound = q1_o - 1.5 * iqr_o upper_bound = q3_o + 1.5 * iqr_o data['avg_orders'] = np.where(data['avg_orders'] > upper_bound, upper_bound,np.where(data['avg_orders'] A missing value assessment confirmed that no missing values were present in the dataset, eliminating the need for imputation.For feature engineering, categorical variables were transformed into numerical representations using appropriate encoding techniques such as one-hot encoding, label encoding, and embeddings, depending on the nature of the feature. Care was taken to avoid data leakage by ensuring that encoding strategies were applied correctly during model training and evaluation.Overall, the EDA process comprehensively covered univariate analysis, bivariate analysis, time series analysis, categorical feature exploration, and data quality treatment, providing a clean and reliable foundation for subsequent modeling stages.Product Sales Forecasting through Time Series Analysis (EDA) was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.