@ralph-yoan/product-predictor
v1.0.0
Published
A modular library to predict store stocks using nostra-data.
Downloads
95
Maintainers
Readme
Product Predictor
A TypeScript library for predicting store stock levels using the nostra-data prediction algorithm.
Description
product-predictor is a specialized TypeScript module designed to interface with store inventory data and advanced prediction algorithms. It bridges the gap between raw historical stock data and future inventory requirements by leveraging the nostra-data algorithm to analyze trends, sales velocity, and seasonal patterns.
Goal
The primary goal of this library is to empower store managers and automated systems to transition from reactive to proactive inventory management. By predicting stock levels across various time horizons (days, months, or years), the library helps in:
- Minimizing Stockouts: Anticipting when a product will fall below its minimum threshold.
- Optimizing Reorders: Providing data-driven insights for timely procurement.
- Reducing Costs: Avoiding overstocking by accurately forecasting long-term demand.
Installation
npm installUsage
Basic Example
import { createPredictor, StockData } from 'product-predictor';
import stockData from './data/stock-data.json';
// Initialize the predictor with your stock data
const predictor = createPredictor(stockData as StockData);
// Predict stock for a product in 30 days
const prediction = predictor.predictProductStock('PRD-0001', '30d');
console.log(`Product: ${prediction.productName}`);
console.log(`Current Stock: ${prediction.currentStock}`);
console.log(`Predicted Stock (30 days): ${prediction.predictedStock}`);
if (prediction.isBelowMinimum) {
console.warn('Warning: Stock predicted to fall below minimum level!');
}Getting Alerts
You can easily get a list of all products that are predicted to fall below their minimum stock levels within a specific timeframe:
const alerts = predictor.getAlerts('7d');
alerts.forEach(alert => {
console.log(`Alert: ${alert.productName} will reach ${alert.predictedStock} in 7 days.`);
});API Reference
createPredictor(jsonData: StockData)
Factory function to create a new StockPredictor instance.
StockPredictor Class
predictProductStock(productId: string, horizon: string): PredictionResultgetAlerts(horizon: string): PredictionResult[]
Types
StockData: The structure of the input JSON data.PredictionResult: The object returned by prediction methods.
Data Structure
The library expects a JSON structure containing:
produits: Array of product details includingstock_actuelandstock_minimum.mouvements_stock: Historical movements (entrées/sorties) used for the prediction algorithm.
License
ISC
