
Abstract
A lightweight, interactive Python desktop app that predicts future monthly sales using linear regression and recent average trends. Designed for analysts, it requires no complex setup: just copy-paste your Excel data, click, and visualize 12-month forecasts in a dynamic chart. The tool makes forecasting accessible, interpretable, and exportable to Excel in secondsโideal for business planning & performance tracking.
Methodology
-
Data Input
- Users copy and paste monthly sales periods (e.g., Jan-2023, Feb-2023, etc.) and corresponding sales values from Excel.
- The number of past months to include in the average calculation is user-defined (default is 6).
-
Data Processing
- The date strings are converted to datetime format using pandas.to_datetime().
- Dates are transformed into numeric format using matplotlib.dates.date2num() to fit the regression model.
-
Forecasting
- A linear regression model is trained using scikit-learn's LinearRegression.
- Features (X): Numeric representation of past dates.
- Target (y): Monthly sales figures.
- Forecasted values for the next 12 months are predicted using the model.
- A simple average of the most recent n months is also calculated to serve as a baseline comparator.
-
Visualization
- Historical sales, regression line, forecast points, and average line are plotted using matplotlib.
- Sales values are annotated on the graph to enhance interpretability.
- The graph is embedded into a pop-up window within the Tkinter GUI.
-
Output
- A result table displays past sales, forecasted sales, and the average benchmark in a horizontally scrollable table.
- The output can be exported to Excel for further analysis.
Results
- The application has been tested on sample datasets and demonstrates:
- Clear Forecast Trends: Users can observe the direction and slope of future projections.
- Visual Validation: Overlays of historical and forecasted data support intuitive validation.
- Export Capability: The Excel output allows integration with other business reports or dashboards.
Potential Applications
- Monthly revenue forecasting
- Demand planning and procurement
- Retail inventory predictions
- Finance/Operations KPI tracking
- Budget projection comparisons
Limitations
- Only linear models: Non-linear trends (seasonality, abrupt change) may not be well captured.