Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/BhaveshBytess/PREDICTIVE-MAINTENANCE/llms.txt

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

Overview

Initiates the system calibration process by generating 1,000 healthy sensor samples, building baseline profiles, and training dual anomaly detection models (legacy 1Hz + batch 100Hz). This is the required first step before monitoring or fault injection.

Endpoint

POST /system/calibrate

Query Parameters

asset_id
string
default:"Motor-01"
Asset identifier to calibrate. Defaults to Motor-01 if not specified.

Calibration Process

The calibration runs as a background task with the following phases:

Phase 1: Burst Data Generation (Instant)

Generates 1,000 healthy sensor samples with timestamps spread across the last hour:
  • Voltage: 230V ± 2V (Range: 226-234V)
  • Current: 15A ± 1A (Range: 13-17A)
  • Power Factor: 0.92 ± 0.02 (Range: 0.88-0.96)
  • Vibration: 0.15g ± 0.03g (Range: 0.09-0.21g)

Phase 2: Baseline Profile Construction

Builds statistical profiles for each sensor signal:
  • Min/Max ranges
  • Mean and standard deviation
  • 3-sigma thresholds for anomaly detection

Phase 3: Legacy Model Training

Trains 1Hz Isolation Forest on 6 features:
  • voltage_rolling_mean_1h
  • current_spike_count
  • power_factor_efficiency_score
  • vibration_intensity_rms
  • voltage_stability
  • power_vibration_ratio

Phase 4: Batch Model Training

Trains 100Hz Isolation Forest on 16 batch features (mean, std, peak-to-peak, RMS) extracted from 100-point windows. This model is primary for inference.

Phase 5: Healthy Monitoring

Transitions to MONITORING_HEALTHY state and begins generating healthy data with batch-feature ML detection.

Response

status
string
required
Always returns "started" when calibration begins successfully
message
string
required
Human-readable confirmation message
state
string
required
New system state: "CALIBRATING"

Example Request

cURL
curl -X POST "https://predictive-maintenance-uhlb.onrender.com/system/calibrate?asset_id=Motor-01"
Python
import requests

response = requests.post(
    "https://predictive-maintenance-uhlb.onrender.com/system/calibrate",
    params={"asset_id": "Motor-01"}
)

data = response.json()
print(f"Status: {data['status']}")
print(f"State: {data['state']}")
JavaScript
const response = await fetch(
  'https://predictive-maintenance-uhlb.onrender.com/system/calibrate?asset_id=Motor-01',
  { method: 'POST' }
);

const data = await response.json();
console.log(`Status: ${data.status}`);
console.log(`State: ${data.state}`);

Example Response

200 OK
{
  "status": "started",
  "message": "Calibration started. Generating healthy data...",
  "state": "CALIBRATING"
}

Error Responses

{
  "detail": "Cannot calibrate in state 'MONITORING_HEALTHY'. Must be IDLE."
}
Cause: System is not in IDLE state. Resolution:
  1. Call POST /system/stop to return to IDLE
  2. Or call POST /system/purge for a deep reset

Monitoring Progress

Poll GET /system/state to track calibration progress:
MessageDurationAction
"Generating training data... 500/1000"~1-2sBurst generation in progress
"Building baseline profile from 1,000 samples..."~1sStatistical profiling
"Training anomaly model on 1,000 samples..."~2sLegacy model training
"Training batch-feature model (16-D statistical features)..."~2sBatch model training
"Calibration complete. Trained on 1000 samples."DoneState → MONITORING_HEALTHY
Total Duration: ~5-10 seconds

Validation Metrics

After calibration completes, monitor these metrics via GET /system/state:
{
  "training_samples": 1000,
  "healthy_stability": 97.3,  // ✅ >95%
  "fault_capture_rate": 100.0
}
If healthy_stability drops below 85%, the baseline contains too much noise. Run POST /system/purge and recalibrate.

State Persistence

Calibration data is stored in:
  1. InfluxDB - 1,000 sensor samples with source=calibration tag
  2. In-Memory - Baseline profiles, trained models, degradation state (DI=0.0)
  3. Disk - Model artifacts are not persisted (retraining on restart)
Calibration state is lost on server restart. You must recalibrate after backend deployment or container restart.

Use Cases

First-Time Setup

Run calibration immediately after deployment to establish healthy baseline

After Purge

Required after POST /system/purge to rebuild models from scratch

Baseline Drift

Recalibrate weekly/monthly if operating conditions change (e.g., seasonal temperature shifts)

Model Retraining

Retrain models after hardware upgrades or sensor replacements

Performance Characteristics

  • Latency: 200ms (calibration runs in background)
  • Background Duration: 5-10 seconds
  • CPU Usage: High during training phase
  • Memory: +50MB for model storage
  • InfluxDB Writes: 100 points (every 10th sample)

Build docs developers (and LLMs) love