viewof pipe_rawValue = Inputs.range([-50, 600], {value: 23.5, step: 0.1, label: "Raw sensor reading (C)"})
viewof pipe_minValid = Inputs.range([-50, 50], {value: -10, step: 1, label: "Valid range minimum (C)"})
viewof pipe_maxValid = Inputs.range([10, 100], {value: 60, step: 1, label: "Valid range maximum (C)"})
viewof pipe_lastReading = Inputs.range([-20, 80], {value: 22.8, step: 0.1, label: "Previous reading (C)"})
viewof pipe_maxRatePerMin = Inputs.range([0.1, 20], {value: 2.0, step: 0.1, label: "Max rate of change (C/min)"})
viewof pipe_emaAlpha = Inputs.range([0.05, 1.0], {value: 0.3, step: 0.05, label: "EMA smoothing alpha"})
viewof pipe_zoneMin = Inputs.range([0, 30], {value: 18, step: 1, label: "Zone min for normalization (C)"})
viewof pipe_zoneMax = Inputs.range([20, 60], {value: 28, step: 1, label: "Zone max for normalization (C)"})Try It: Three-Stage Pipeline Simulator
Try It: Three-Stage Pipeline Simulator
animation
analytics-ml
data-quality
Try Change Raw sensor reading (C) to 500.
Observe Watch Stage 1: Validate, Stage 2: Clean, and Stage 3: Transform.
Explain Explain why Stage 2: Clean is skipped when validation rejects the reading.
Technical boundaries. Validation compares the raw reading with range limits and the previous reading. Cleaning uses EMA smoothing; normalization requires a positive zone range and can produce values outside [0,1].
Try It: Three-Stage Pipeline Simulator
Note
Enter a raw sensor reading and configure validation rules to see how data flows through the validate-clean-transform pipeline. Introduce noise, outliers, or missing values to observe how each stage responds.
{
const raw = pipe_rawValue;
const rangeOk = raw >= pipe_minValid && raw <= pipe_maxValid;
const rateChange = Math.abs(raw - pipe_lastReading);
const rateOk = rateChange <= pipe_maxRatePerMin;
const validationPassed = rangeOk && rateOk;
const validationStatus = !rangeOk
? `REJECTED -- ${raw}C is outside [${pipe_minValid}, ${pipe_maxValid}]`
: !rateOk
? `REJECTED -- rate of change ${rateChange.toFixed(1)}C/min exceeds limit of ${pipe_maxRatePerMin}C/min`
: `PASSED -- ${raw}C is within range and rate of change is ${rateChange.toFixed(1)}C/min`;
const cleaned = validationPassed
? (pipe_emaAlpha * raw + (1 - pipe_emaAlpha) * pipe_lastReading)
: null;
const zoneRange = pipe_zoneMax - pipe_zoneMin;
const normalized = cleaned !== null && zoneRange > 0
? ((cleaned - pipe_zoneMin) / zoneRange)
: null;
const valColor = validationPassed ? "#16A085" : "#E74C3C";
const normColor = normalized !== null && normalized >= 0 && normalized <= 1 ? "#3498DB" : "#E67E22";
const viewportWidth = typeof width !== "undefined" ? width : window.innerWidth;
const compact = viewportWidth < 640;
const stageGrid = compact ? "1fr" : "repeat(3, minmax(0, 1fr))";
return html`<div style="background: var(--bs-light, #f8f9fa); padding: 1.2rem; border-radius: 8px; border-left: 4px solid #2C3E50; color: var(--bs-body-color); margin-top: 0.5rem;">
<div style="display: grid; grid-template-columns: ${stageGrid}; gap: 1rem;">
<div style="background: var(--bs-body-bg, #fff); padding: 1rem; border-radius: 6px; border-top: 3px solid ${valColor}; min-width: 0;">
<h4 style="margin: 0 0 0.5rem 0; font-size: 0.95rem; color: #2C3E50;">Stage 1: Validate</h4>
<p style="margin: 0.3rem 0; font-size: 0.85rem;"><strong>Range check:</strong> <span style="color: ${rangeOk ? '#16A085' : '#E74C3C'};">${rangeOk ? 'PASS' : 'FAIL'}</span></p>
<p style="margin: 0.3rem 0; font-size: 0.85rem;"><strong>Rate check:</strong> <span style="color: ${rateOk ? '#16A085' : '#E74C3C'};">${rateOk ? 'PASS' : 'FAIL'}</span></p>
<p style="margin: 0.5rem 0 0 0; font-size: 0.8rem; color: ${valColor}; font-weight: bold; line-height: 1.45;">${validationStatus}</p>
</div>
<div style="background: var(--bs-body-bg, #fff); padding: 1rem; border-radius: 6px; border-top: 3px solid ${validationPassed ? '#E67E22' : '#7F8C8D'}; min-width: 0;">
<h4 style="margin: 0 0 0.5rem 0; font-size: 0.95rem; color: #2C3E50;">Stage 2: Clean</h4>
${validationPassed
? html`<p style="margin: 0.3rem 0; font-size: 0.85rem;"><strong>EMA filter</strong> (alpha=${pipe_emaAlpha}):</p>
<p style="margin: 0.3rem 0; font-size: 0.85rem; line-height: 1.45; word-break: break-word;">${pipe_emaAlpha} x ${raw} + ${(1-pipe_emaAlpha).toFixed(2)} x ${pipe_lastReading}</p>
<p style="margin: 0.5rem 0 0 0; font-size: 1.1rem; font-weight: bold; color: #E67E22;">${cleaned.toFixed(2)}C</p>`
: html`<p style="margin: 0.3rem 0; font-size: 0.85rem; color: #7F8C8D;">Skipped -- invalid reading rejected in Stage 1</p>`}
</div>
<div style="background: var(--bs-body-bg, #fff); padding: 1rem; border-radius: 6px; border-top: 3px solid ${normalized !== null ? normColor : '#7F8C8D'}; min-width: 0;">
<h4 style="margin: 0 0 0.5rem 0; font-size: 0.95rem; color: #2C3E50;">Stage 3: Transform</h4>
${normalized !== null
? html`<p style="margin: 0.3rem 0; font-size: 0.85rem;"><strong>Min-max normalization:</strong></p>
<p style="margin: 0.3rem 0; font-size: 0.85rem; line-height: 1.45; word-break: break-word;">(${cleaned.toFixed(2)} - ${pipe_zoneMin}) / (${pipe_zoneMax} - ${pipe_zoneMin})</p>
<p style="margin: 0.5rem 0 0 0; font-size: 1.1rem; font-weight: bold; color: ${normColor};">${normalized.toFixed(4)}</p>
${normalized < 0 || normalized > 1 ? html`<p style="margin: 0.3rem 0; font-size: 0.75rem; color: #E67E22;">Value outside [0,1] -- review zone bounds</p>` : html``}`
: html`<p style="margin: 0.3rem 0; font-size: 0.85rem; color: #7F8C8D;">Skipped -- no valid data to normalize</p>`}
</div>
</div>
<p style="margin: 0.8rem 0 0 0; font-size: 0.85rem; text-align: center; color: var(--bs-body-color); opacity: 0.8;"><strong>Experiment:</strong> Try setting the raw reading to 500C (fails range check), or to 30C with previous reading 22C and max rate 2C/min (fails rate check). Then adjust the EMA alpha to see how smoothing changes the cleaned value.</p>
</div>`;
}