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.

Fraud Shield evaluates individual financial transactions in real time and classifies them into one of three risk levels. The model weighs transaction amount, time of day, previous failed attempts, customer history, device familiarity, country risk, and recent purchase frequency to generate an actionable risk label along with recommended next steps.

Model Details

PropertyValue
Model keyfraud-shield
EndpointPOST /predict/fraud-shield
Training samples320 synthetic samples
ClassifierRandomForestClassifier(n_estimators=180, max_depth=7, random_state=42, class_weight="balanced_subsample")

Output Labels

LabelMeaning
FRAUDE_PROBABLEHigh-risk transaction — likely fraudulent, block immediately
REVISION_MANUALModerate risk — request additional customer verification
TRANSACCION_SEGURALow risk — authorize and continue passive monitoring

Label Decision Logic

The labelling function accumulates risk points from multiple signals before assigning a class:
def label_fraud(row):
    monto, hora, intentos, antig, disp, pais, compras = row
    risk = 0
    risk += 35 if monto > 5000 else 12 if monto > 1500 else 0
    risk += 18 if hora <= 5 else 0
    risk += intentos * 8
    risk += 18 if antig < 3 else 8 if antig < 12 else 0
    risk += 20 if disp == 1 else 0
    risk += 18 if pais == 1 else 0
    risk += 12 if compras > 5 else 0

    if risk >= 70:
        return "FRAUDE_PROBABLE"
    if risk >= 40:
        return "REVISION_MANUAL"
    return "TRANSACCION_SEGURA"
ConditionPoints added
monto > 5 000+35
monto > 1 500+12
hora_24 <= 5 (late night)+18
Each intentos_previos+8 each
antiguedad_cliente_meses < 3+18
antiguedad_cliente_meses < 12+8
dispositivo_nuevo == 1+20
pais_riesgo == 1+18
compras_ultima_hora > 5+12

Input Fields

monto
float
required
Transaction amount in local currency. Range: 1 – 20 000. Amounts above 5 000 add 35 risk points; amounts above 1 500 add 12.
hora_24
integer
required
Hour of day the transaction was initiated (24-hour clock). Range: 0 – 23. Transactions between midnight and 05:00 add 18 risk points.
intentos_previos
integer
required
Number of previous failed authentication attempts for this transaction session. Range: 0 – 10. Each attempt adds 8 risk points.
antiguedad_cliente_meses
integer
required
Customer account age in months. Range: 0 – 120. Accounts younger than 3 months add 18 points; younger than 12 months add 8 points.
dispositivo_nuevo
integer
required
Whether the transaction originates from a device not previously seen for this account. Range: 0 – 1.
  • 0 = known device
  • 1 = new / unrecognised device (+20 risk points)
pais_riesgo
integer
required
Country risk classification for the transaction origin. Range: 0 – 1.
  • 0 = low-risk country
  • 1 = high-risk country (+18 risk points)
compras_ultima_hora
integer
required
Number of purchases made by this account in the last hour. Range: 0 – 20. More than 5 purchases add 12 risk points.

Recommendations by Label

LabelRecommendations
FRAUDE_PROBABLEBlock the operation temporarily · Request reinforced authentication · Log an alert for analyst review
REVISION_MANUALRequest additional customer confirmation · Compare against purchase history · Authorise only if verification succeeds
TRANSACCION_SEGURAAuthorise the operation and continue passive monitoring

Example Request & Response

curl -X POST http://localhost:8001/predict/fraud-shield \
  -H "Content-Type: application/json" \
  -d '{
    "monto": 7500.0,
    "hora_24": 3,
    "intentos_previos": 2,
    "antiguedad_cliente_meses": 2,
    "dispositivo_nuevo": 1,
    "pais_riesgo": 1,
    "compras_ultima_hora": 7
  }'
{
  "caso": "FraudShield",
  "prediccion": "FRAUDE_PROBABLE",
  "confianza": 0.9444,
  "ranking": [
    { "clase": "FRAUDE_PROBABLE",    "probabilidad": 0.9444 },
    { "clase": "REVISION_MANUAL",    "probabilidad": 0.0389 },
    { "clase": "TRANSACCION_SEGURA", "probabilidad": 0.0167 }
  ],
  "recomendaciones": [
    "Bloquear temporalmente la operación.",
    "Solicitar autenticación reforzada.",
    "Registrar alerta para revisión del analista."
  ],
  "entrada": {
    "monto": 7500.0,
    "hora_24": 3,
    "intentos_previos": 2,
    "antiguedad_cliente_meses": 2,
    "dispositivo_nuevo": 1,
    "pais_riesgo": 1,
    "compras_ultima_hora": 7
  }
}

Response Fields

caso
string
Always "FraudShield" for this endpoint.
prediccion
string
Predicted risk label: FRAUDE_PROBABLE, REVISION_MANUAL, or TRANSACCION_SEGURA.
confianza
float
Probability of the top prediction, rounded to 4 decimal places.
ranking
array
All three risk classes sorted by probability descending. Each element contains clase (string) and probabilidad (float).
recomendaciones
array
List of recommended actions for the fraud analyst or automated system based on the predicted label.
entrada
object
Echo of the exact request payload received by the server.
A transaction with intentos_previos=5, dispositivo_nuevo=1, pais_riesgo=1, and monto > 5 000 will accumulate at least 113 risk points, making FRAUDE_PROBABLE nearly certain. Use this combination to smoke-test the endpoint after startup.

Build docs developers (and LLMs) love