Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JoseOlivares19/Proyecto-PC3-JavaScript-Avanzado/llms.txt

Use this file to discover all available pages before exploring further.

Smart Stock 360 helps inventory managers decide when to reorder by classifying each product into one of three demand tiers. The model combines sales velocity, active discounts, seasonal context, product rating, and current coverage to produce an actionable label along with concrete replenishment recommendations.

Model Details

PropertyValue
Model keysmart-stock
EndpointPOST /predict/smart-stock
Training samples300 synthetic samples
ClassifierRandomForestClassifier(n_estimators=180, max_depth=7, random_state=42, class_weight="balanced_subsample")

Output Labels

LabelMeaning
DEMANDA_ALTA_REABASTECERHigh demand, low coverage — restock urgently
DEMANDA_MEDIA_MONITOREARModerate demand — monitor and prepare a moderate order
DEMANDA_BAJA_OPTIMIZARLow demand — reduce immediate purchase, avoid overstock

Label Decision Logic

The labelling function computes two intermediate values before assigning a class:
def label_stock(row):
    precio, stock, ventas, desc, temp, dias, rating = row
    demand = (
        ventas * 0.09
        + desc  * 0.7
        + temp  * 18
        + rating * 8
        - precio * 0.006
        + dias  * 0.22
    )
    cobertura = stock / max(ventas, 1)   # days of coverage

    if demand >= 70 and cobertura < 3:
        return "DEMANDA_ALTA_REABASTECER"
    if demand >= 45:
        return "DEMANDA_MEDIA_MONITOREAR"
    return "DEMANDA_BAJA_OPTIMIZAR"
A product scores DEMANDA_ALTA_REABASTECER only when the demand signal is strong and current stock covers fewer than 3 days of sales.

Input Fields

precio
float
required
Current product price in local currency. Range: 1 – 5 000. Higher prices slightly decrease the demand score.
stock_actual
integer
required
Units currently in stock. Range: 0 – 10 000. Used to calculate stock coverage relative to recent sales.
ventas_7d
integer
required
Units sold in the last 7 days. Range: 0 – 5 000. Primary driver of the demand score.
descuento_pct
float
required
Active discount percentage on the product. Range: 0 – 90. A higher discount amplifies perceived demand.
temporada
integer
required
Current season context. Range: 0 – 2.
  • 0 = normal period
  • 1 = campaign / promotional period
  • 2 = holiday / peak demand
dias_sin_reabastecer
integer
required
Number of days since the last restock event. Range: 0 – 120. Longer gaps increase the demand score.
rating_producto
float
required
Product rating on a 1–5 scale. Range: 1 – 5. Higher ratings increase the demand score.

Recommendations by Label

LabelRecommendations
DEMANDA_ALTA_REABASTECERRestock within 48 hours · Maintain promotion if margin allows · Display a red alert on the dashboard
DEMANDA_MEDIA_MONITOREARMonitor daily sales · Prepare a moderate order if the season continues · Compare against substitute products
DEMANDA_BAJA_OPTIMIZARReduce immediate purchase · Evaluate a promotion or bundle · Avoid overstock and review pricing

Example Request & Response

curl -X POST http://localhost:8001/predict/smart-stock \
  -H "Content-Type: application/json" \
  -d '{
    "precio": 120.0,
    "stock_actual": 40,
    "ventas_7d": 200,
    "descuento_pct": 25.0,
    "temporada": 2,
    "dias_sin_reabastecer": 14,
    "rating_producto": 4.5
  }'
{
  "caso": "SmartStock360",
  "prediccion": "DEMANDA_ALTA_REABASTECER",
  "confianza": 0.9211,
  "ranking": [
    { "clase": "DEMANDA_ALTA_REABASTECER", "probabilidad": 0.9211 },
    { "clase": "DEMANDA_MEDIA_MONITOREAR", "probabilidad": 0.0612 },
    { "clase": "DEMANDA_BAJA_OPTIMIZAR",   "probabilidad": 0.0177 }
  ],
  "recomendaciones": [
    "Reabastecer en las próximas 48 horas.",
    "Mantener promoción si el margen lo permite.",
    "Mostrar alerta roja en el dashboard."
  ],
  "entrada": {
    "precio": 120.0,
    "stock_actual": 40,
    "ventas_7d": 200,
    "descuento_pct": 25.0,
    "temporada": 2,
    "dias_sin_reabastecer": 14,
    "rating_producto": 4.5
  }
}

Response Fields

caso
string
Always "SmartStock360" for this endpoint.
prediccion
string
Predicted demand label: DEMANDA_ALTA_REABASTECER, DEMANDA_MEDIA_MONITOREAR, or DEMANDA_BAJA_OPTIMIZAR.
confianza
float
Probability of the top prediction, rounded to 4 decimal places.
ranking
array
All three demand classes sorted by probability descending. Each element contains clase (string) and probabilidad (float).
recomendaciones
array
List of actionable replenishment recommendations for the predicted label.
entrada
object
Echo of the exact request payload that was received by the server.
The cobertura (coverage) calculation is stock_actual / max(ventas_7d, 1). Sending ventas_7d = 0 will not cause a division-by-zero error — the denominator is clamped to 1.

Build docs developers (and LLMs) love