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.

The /predict/smart-stock endpoint runs a product’s current sales and inventory signals through the SmartStock360 RandomForest classifier to produce one of three demand tier labels. The model weighs discount level, seasonal context, recent sales velocity, days without replenishment, and customer rating against current stock coverage. The response includes a confidence score, a full probability ranking across all three labels, and actionable replenishment recommendations ready to display in your inventory dashboard.

Endpoint

POST http://localhost:8001/predict/smart-stock
Content-Type: application/json

Request Body

precio
float
required
Unit price of the product in local currency. Must be between 1 and 5000.
stock_actual
integer
required
Current units available in warehouse. Must be between 0 and 10000.
ventas_7d
integer
required
Total units sold in the last 7 days. Must be between 0 and 5000.
descuento_pct
float
required
Active discount percentage applied to the product. Must be between 0 and 90.
temporada
integer
required
Current season or sales context. Accepted values:
  • 0 — Normal period
  • 1 — Campaign / promotional period
  • 2 — Holiday / peak demand period
dias_sin_reabastecer
integer
required
Number of days since the last stock replenishment. Must be between 0 and 120.
rating_producto
float
required
Average customer rating for the product. Must be between 1.0 and 5.0.

Example Request

curl -X POST http://localhost:8001/predict/smart-stock \
  -H "Content-Type: application/json" \
  -d '{
    "precio": 129.99,
    "stock_actual": 45,
    "ventas_7d": 320,
    "descuento_pct": 25.0,
    "temporada": 1,
    "dias_sin_reabastecer": 18,
    "rating_producto": 4.6
  }'

Example Response

{
  "caso": "SmartStock360",
  "prediccion": "DEMANDA_ALTA_REABASTECER",
  "confianza": 0.9124,
  "ranking": [
    { "clase": "DEMANDA_ALTA_REABASTECER", "probabilidad": 0.9124 },
    { "clase": "DEMANDA_MEDIA_MONITOREAR", "probabilidad": 0.0712 },
    { "clase": "DEMANDA_BAJA_OPTIMIZAR",   "probabilidad": 0.0164 }
  ],
  "recomendaciones": [
    "Reabastecer en las próximas 48 horas.",
    "Mantener promoción si el margen lo permite.",
    "Mostrar alerta roja en el dashboard."
  ],
  "entrada": {
    "precio": 129.99,
    "stock_actual": 45,
    "ventas_7d": 320,
    "descuento_pct": 25.0,
    "temporada": 1,
    "dias_sin_reabastecer": 18,
    "rating_producto": 4.6
  }
}

Response Fields

caso
string
Human-readable model identifier. Always "SmartStock360" for this endpoint.
prediccion
string
The top predicted demand label. One of:
LabelMeaning
DEMANDA_ALTA_REABASTECERHigh demand — immediate replenishment required
DEMANDA_MEDIA_MONITOREARMedium demand — monitor daily and prepare moderate order
DEMANDA_BAJA_OPTIMIZARLow demand — avoid overstock, review pricing or bundling
confianza
float
Probability assigned to the top predicted class, in the range 0.0 to 1.0. Higher values indicate a more decisive classification.
ranking
array of objects
Probability distribution over all three demand labels, sorted in descending order of probability.
recomendaciones
array of strings
Contextual replenishment actions generated from the predicted label and input field values. Typically 1–3 actionable strings ready to surface in a UI notification or alert.
entrada
object
Echo of the validated request payload as parsed by Pydantic. Useful for logging and audit trails without re-serialising the original request.
temporada must be an integer 0, 1, or 2. Passing a string such as "campaña" will return a 422 Unprocessable Entity error.

Build docs developers (and LLMs) love