{
  "method": "INPARFORMER_BLOCK",
  "slug": "inparformer-block",
  "title": "InParformer block: smooth, group, repeat",
  "summary": "A centered moving average estimates the prefix trend and the final trend level is held constant afterward. The next step uses phase-wise means of the detrended prefix. The frames expose those buckets, their cumulative averages and the repeated seasonal output. The computation shown contains smoothing and phase averaging. It does not execute evolutionary search or interactive parallel attention.",
  "steps": [
    {
      "title": "Smooth the prefix",
      "text": "A centered moving average estimates the prefix trend and the final trend level is held constant afterward."
    },
    {
      "title": "Average equal seasonal phases",
      "text": "Subtract the trend on the fitting prefix. Group samples by index modulo the specified period and average each phase bucket."
    },
    {
      "title": "Repeat the phase template",
      "text": "Tile the fitted phase means over the record. The suffix does not update the template in this prefix configuration."
    },
    {
      "title": "Inspect the derived residual",
      "text": "Compute input minus the implemented trend and seasonal estimate. This residual is part of a retrospective decomposition, not a forecast score."
    }
  ],
  "parameters": [
    {
      "name": "trend_window",
      "effect": "Sets the centered moving-average support on the prefix; its endpoint is extended as a constant."
    },
    {
      "name": "primary_period",
      "effect": "Defines phase buckets in samples; the fitting prefix must contain enough cycles for an interpretable average."
    },
    {
      "name": "fit_scope / train_fraction",
      "effect": "Explicitly selects a two-thirds prefix in this example; it does not create a rolling forecasting evaluation."
    }
  ],
  "cautions": [
    "The computation shown contains smoothing and phase averaging. It does not execute evolutionary search or interactive parallel attention.",
    "Prefix fitting is a fixed fitting convention. It does not certify rolling causality or an out-of-sample prediction experiment.",
    "A repeated phase template assumes that the fitted seasonal shape remains useful over the displayed suffix.",
    "The residual is derived by subtraction; exact reconstruction does not validate the scientific interpretation of either component."
  ],
  "references": [
    {
      "title": "Implemented DeTime operator",
      "url": "https://github.com/systems-mechanobiology/DeTime/blob/main/src/detime/methods/neural_blocks/neural_block_portfolio.py"
    },
    {
      "title": "Cao et al. (2023), InParformer: Evolutionary Decomposition Transformers with Interactive Parallel Attention for Long-Term Time Series Forecasting",
      "url": "https://ojs.aaai.org/index.php/AAAI/article/view/25845"
    }
  ],
  "trace_kind": "computed_operator_trace",
  "trace_note": "Intermediate arrays are computed with the implemented operator helpers. The final trend, season and residual are checked against public decompose(). The animation explains this standalone experimental block; its source architecture is cited for provenance.",
  "input_note": "Deterministic synthetic teaching signal; not a benchmark.",
  "example_config": {
    "method": "INPARFORMER_BLOCK",
    "params": {
      "primary_period": 24,
      "fit_scope": "prefix",
      "train_fraction": 0.6666666666666666,
      "trend_window": 49
    },
    "backend": "python"
  },
  "checks": {
    "public_method_executed": true,
    "method_output_max_abs_errors": {
      "trend": 0.0,
      "season": 0.0,
      "residual": 0.0
    },
    "reconstruction_max_abs_error": 2.220446049250313e-16,
    "validation_scope": "One deterministic teaching input; no benchmark claim.",
    "fit_end": 96
  },
  "source_files": [
    "src/detime/methods/neural_blocks/neural_block_portfolio.py"
  ],
  "frames": 32,
  "duration_ms": 12050,
  "poster_frame": 15,
  "width": 1280,
  "height": 820,
  "artifacts": {
    "gif": {
      "file": "inparformer-block.gif",
      "bytes": 330623,
      "sha256": "8d695c1ca71ce2e1f9b18429c04abccee947debf098b14647b596a543518e4b6"
    },
    "poster": {
      "file": "inparformer-block.png",
      "bytes": 125995,
      "sha256": "5a2a4c88053367e42071535b07d608631af1441fbc46c7d7bc4fca1f931bb265"
    },
    "data": {
      "file": "inparformer-block.npz",
      "bytes": 8059,
      "sha256": "a239a4ed76ac20789b09dfdba126a66fa19d50092f6bcb70feb8c581422034bc"
    }
  },
  "source_arrays": {
    "observed": [
      144
    ],
    "trend_candidates": [
      1,
      144
    ],
    "trend": [
      144
    ],
    "detrended": [
      144
    ],
    "prefix_phase_matrix": [
      4,
      24
    ],
    "raw_template": [
      144
    ],
    "season": [
      144
    ],
    "residual": [
      144
    ],
    "fit_end": []
  },
  "render_provenance": {
    "python_version": "3.12.14",
    "dependencies": {
      "numpy": "2.3.5",
      "scipy": "1.17.0",
      "statsmodels": "0.15.0",
      "matplotlib": "3.10.8",
      "Pillow": "12.3.0",
      "PyWavelets": "1.10.0",
      "EMD-signal": "1.10.0",
      "vmdpy": "0.2",
      "PySDKit": "0.5.0"
    },
    "source_hashes": {
      "scripts/generate_method_animations.py": "f62989af55a7e48495c24afcfee31751d3785e5f78bb4b900bef23a429deaa84",
      "scripts/method_animations/common.py": "73ad7e8b4e5b67f87d13e59adab2c93e983fe1aaf06ee627d22cb7c7e696016a",
      "scripts/method_animations/neural.py": "fc1c2a73490391f0f863ede52e38f12924cc1fec572b7188356a2308216716e6",
      "src/detime/backends.py": "7432dcf59e382580dfb32f1f57e61ff71a30567c049b35243e24e3644523eda6",
      "src/detime/core.py": "d95b348cd8b16b56d18840965579c947a11628d969dd6c32c4af7723f5a027f4",
      "src/detime/methods/neural_blocks/neural_block_portfolio.py": "2aab635b9927d1d42bbcd8e0b4f37cb9fcdcf85cbd0331b5011621b495c4acfa",
      "src/detime/registry.py": "e934ffca17880cefe5add728aa497e63ea811d7ae43abec1ea498de718094066"
    }
  }
}
