Users have transactions and spending history. But classic filters like "last month" don't show whether they'll have enough money until payday. Result: overdrafts, fees, stress. We develop a predictive model that integrates into a mobile app and closes this gap. The model analyzes spending patterns, accounts for seasonality (e.g., increased spending during holidays), and warns 5–7 days before a potential deficit. For forecasting, we use a hybrid architecture: a lightweight on-device model via CoreML or TFLite for fast predictions, and a server-side model for periodic retraining. Feature engineering includes moving averages, recurring payment detection, and calendar features. We'll assess your project in 1–2 days — contact us to discuss details.
Architecture: Hybrid Approach
Choosing where to run predictions is a key architectural decision. For budget forecasting, a hybrid approach is optimal: a lightweight quantized model on-device for fast inline predictions, and a full model on the server for periodic retraining.
| Feature | On-device (CoreML/TFLite) | Server-side (Python/MLflow) |
|---|---|---|
| Inference time | < 5 ms for 30-day forecast | 50–200 ms including network |
| Network dependency | No | Yes |
| Personalization | Only loaded model | Full fine-tuning |
| Privacy | Data never leaves device | Data sent to server |
On-device we deploy a quantized model via CoreML (iOS) or TensorFlow Lite (Android). INT8 quantization reduces model size by 4x without significant accuracy loss. CoreML accepts .mlmodel, TFLite — .tflite. Conversion from PyTorch or Keras is a standard task.
More on model quantization
Quantization converts 32-bit weights to 8-bit integers. For financial forecasts, MAE drop does not exceed 2-5%. We use post-training quantization: a few hundred calibration examples from user history suffice.// iOS: loading CoreML model and prediction
import CoreML
class BudgetForecaster {
private let model: BudgetForecastModel
init() throws {
let config = MLModelConfiguration()
config.computeUnits = .cpuAndNeuralEngine
model = try BudgetForecastModel(configuration: config)
}
func predictBalance(features: BudgetForecastModelInput) throws -> Double {
let output = try model.prediction(input: features)
return output.predictedBalance
}
}
computeUnits = .cpuAndNeuralEngine — the model uses Neural Engine on A12+ chips. Inference of a 30-day forecast on iPhone 14 takes less than 5 ms.
Data Preparation and Features
Forecast quality depends on features, not the model. From transaction history we derive:
- moving average of spending over 7/30/90 days by category
- day of week and day of month (within-month seasonality is real: spending on the 25th systematically differs from the 10th)
- recurring flag: payments at regular intervals (Netflix, rent, loan)
- deviation of current period from average — z-score of spending
Recurring payments are a special case. They need separate detection: clustering by amount ± 5% + periodicity. A simple algorithm works well: group transactions of the same merchant, compute median interval between them, if stdDev < 3 days — it's recurring.
How to Choose a Forecasting Model?
For financial time series with 3–24 months of history, three approaches work well:
| Model | When suitable | Implementation complexity |
|---|---|---|
| ARIMA/SARIMA | Little data, no nonlinearity | Low |
| LightGBM/XGBoost | Mixed features, tabular | Medium |
| LSTM/Transformer | Complex patterns, lots of history | High |
In practice, LightGBM outperforms LSTM for history less than 2 years. In tests, LightGBM is 3x faster than LSTM on typical datasets with up to 2 years of history, with comparable accuracy. Comparison by key parameters:
| Parameter | LightGBM | LSTM |
|---|---|---|
| Training time on 12 months of data | 25 minutes | 150 minutes |
| Number of hyperparameters | ~20 | ~50 |
| Interpretability | High (feature importance) | Low (black box) |
| On-device memory footprint | 20 MB | 200 MB |
LightGBM can be converted to TFLite via ONNX intermediate format.
How to Implement Forecasting: Step-by-Step Plan
- Data audit — collect at least 3 months of transactions, check quality and completeness.
- Feature engineering — compute moving averages, detect recurring payments, add calendar features.
- Model selection and training — compare LightGBM and LSTM on your data, choose the best by MAE.
- Conversion and optimization — quantize the model and convert to CoreML/TFLite.
- Integration and UI — embed the model in the app, add forecast chart with confidence interval.
- Monitoring and retraining — set up background model update once a week.
Why Federated Learning Enhances Privacy?
Once a week (or when N new transactions are added), the server retrains a personal model on the user's data. Scheme: base global model + fine-tuning on personal history.
Federated Learning is an option for privacy-sensitive apps. Google FL via TensorFlow Federated, Apple Private Federated Learning (iOS 17+). User data never leaves the device; only gradient updates are sent to the server. TensorFlow Federated
The personalized model is delivered to the device via a background task — BGProcessingTask on iOS, WorkManager on Android. Load new .mlmodel / .tflite over Wi-Fi, replace the old one without restarting the app.
UI: Displaying the Forecast
A forecast without context is useless. We show:
- Expected balance at month-end with a confidence interval (not a single number — a range)
- Breakdown: where the model "sees" major planned expenses
- Alert: if the forecast shows a deficit — notification 5+ days in advance, not on day X
We implement the confidence interval via quantile regression: train three models (q10, q50, q90) — pessimistic, median, optimistic forecast. Display as a range on the chart.
To implement such an interface in your app, contact us — we'll prepare a prototype in 2–3 days. According to our estimates, savings on overdrafts and fees range from 10 to 50 thousand rubles per month for a user. Our clients save an average of 100 thousand rubles per year.
What is Included in the Work
- Audit of transaction data structure and quality
- Development of cleaning and feature engineering pipeline
- Training and validation of the model on historical data
- Conversion to CoreML/TFLite, device optimization
- Integration into the mobile app, forecast UI component
- Setup of server-side retraining pipeline
- Documentation, team training, and support during implementation
Timeline Estimates
MVP with baseline ARIMA/LightGBM model and UI — 1–2 weeks. Full personalized system with federated learning and background model updates — 4–8 weeks.
Contact us for a project assessment. Order an MVP development — we guarantee forecast accuracy and full integration. Get a consultation on AI forecasting implementation.







