Home » No-Code Machine Learning » Sales Forecasting

How to Forecast Sales With Machine Learning

Machine learning sales forecasting uses a regression model trained on your historical sales data to predict future revenue. Instead of guessing based on gut feeling or extrapolating from a simple trend line, ML models consider multiple factors at once, including seasonality, marketing spend, customer counts, product mix, and external variables. The result is a data-driven forecast you can use for budgeting, inventory planning, and staffing decisions.

What Data You Need

The core of a sales forecast is historical revenue data broken into regular time periods (daily, weekly, or monthly). Each row represents one time period, and the target column is the revenue amount. The more time periods you have, the better the model can learn patterns, especially seasonal ones.

Beyond raw revenue, include features that influence sales:

For monthly forecasting, aim for at least 24 months of history to capture annual seasonality. For daily forecasting, at least 6-12 months. See How Much Data Do You Need for more guidance.

Building the Forecast Model

Step 1: Prepare your historical data.
Export revenue by time period along with the features above. Each row is one time period (one month, one week, or one day). Create time-based features from your dates: month number, day of week, quarter, and any lag features. See How to Prepare Your Data.
Step 2: Upload and configure.
Upload the CSV to the Data Aggregator app. Set the revenue column as your target. Select all other columns as input features. The platform will handle the training process from here.
Step 3: Train with gradient boosting.
For sales forecasting, gradient boosting regression typically performs best because it captures non-linear relationships and interactions between features. It handles the complex interplay of seasonality, marketing effects, and customer behavior better than linear models.
Step 4: Validate accuracy.
Check the model's error metrics after training. For revenue forecasting, look at mean absolute error (how many dollars the predictions are off on average) and mean absolute percentage error (what percentage the predictions are off). A model that predicts monthly revenue within 10-15% is quite useful for planning. See How to Test Model Accuracy.
Step 5: Generate forecasts.
Create rows for future time periods with your planned or expected feature values (planned marketing spend, expected customer count, known events). Send these through the model to get revenue predictions. Predictions cost zero credits, so you can run multiple scenarios quickly.

Scenario Planning

The zero prediction cost enables powerful scenario planning. Create multiple versions of future data with different assumptions and compare the forecasts:

Each scenario takes seconds to score, giving you a range of possible outcomes to plan around instead of a single number.

Improving Forecast Accuracy

Add More Relevant Features

The biggest accuracy gains come from adding features that genuinely influence sales. If email campaigns drive purchases, include email volume and open rates. If weather affects foot traffic, include temperature data. Every relevant signal you add helps the model make better predictions.

Use Lag Features

Lag features (last month's revenue, same month last year, rolling averages) are often the single most predictive input for time series forecasting. They capture momentum and seasonality directly. Always include at least "revenue last period" and "revenue same period last year" as features.

Retrain Periodically

Markets change, businesses evolve, and customer behavior shifts. Retrain your forecast model quarterly to incorporate the most recent data. A model that includes the last quarter's actuals will make better predictions for the next quarter. See How to Retrain Models With New Data.

Forecasting limitations: ML models predict based on patterns in historical data. They cannot predict truly unprecedented events (a new competitor entering the market, a viral social media moment, a pandemic). Use ML forecasts as a strong baseline and adjust for known upcoming changes that have no historical precedent.

Build a sales forecast model on your own revenue data. Get data-driven predictions for better business planning.

Get Started Free