Skip to content
Back to skills

Htm Algorithms

ASecurity

"Direct NuPIC legacy HTM encoders, SpatialPooler, TemporalMemory,

  • 247 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
toolspythongobashdebuggingapi

Works with

  • api

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill htm-algorithms --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Htm Algorithms?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Htm Algorithms
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-htm-algorithms/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-htm-algorithms)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: htm-algorithms
description: "Direct NuPIC legacy HTM encoders, SpatialPooler, TemporalMemory,
  SDRClassifier, anomaly score, and anomaly likelihood workflows."
disable-model-invocation: true
metadata:
  disco-role: operating
license: MIT
---

# HTM Algorithms

Use this sub-skill when a task asks for direct NuPIC legacy HTM algorithm APIs: encoders, `SpatialPooler`, `TemporalMemory`, `SDRClassifier`, raw anomaly score, or anomaly likelihood for a small streaming scalar/temporal example.

NuPIC legacy is a Python 2.7 package. Direct algorithm workflows normally require installed `nupic`, `nupic.bindings`, `numpy` in the legacy-compatible range, and `pycapnp`/Cap'n Proto only when serialization is needed.

## Route first

- Stay here for: `ScalarEncoder`, `RandomDistributedScalarEncoder`, `DateEncoder`, `CategoryEncoder`, `MultiEncoder`, `SpatialPooler.compute`, `TemporalMemory.compute`, `SDRClassifier.compute`, `computeRawAnomalyScore`, and `AnomalyLikelihood.anomalyProbability`.
- Read [references/api-reference.md](references/api-reference.md) when you need constructor signatures, input/output shapes, classifier result keys, or anomaly helper semantics.
- Read [references/workflows.md](references/workflows.md) when you need a direct encoders -> SP -> TM -> classifier/anomaly recipe or a debugging checklist for algorithm pipelines.
- Read [references/troubleshooting.md](references/troubleshooting.md) when an algorithm example fails with encoder parameter, active-array shape, TM state/reset, classifier dict, Python 2, bindings, or serialization errors.
- Run [scripts/algorithm_smoke.py](scripts/algorithm_smoke.py) when you need a deterministic installed-package smoke check for tiny encoders, SP/TM, classifier, and anomaly helpers.
- Route CSV stream headers, field metadata, OPF model parameter files, and config validation to [../data-and-configuration/](../data-and-configuration/).
- Route high-level `ModelFactory`, OPF inference dictionaries, checkpoints, and experiment workflows to [../opf-prediction/](../opf-prediction/).
- For package-wide install/import failures before algorithm code runs, start with the root troubleshooting guide at `../../references/troubleshooting.md`; local reference files also cross-link to that guide from their own relative paths.

## Direct API checklist

1. Confirm the runtime is Python 2.7 and can import `nupic`, `nupic.bindings`, and `numpy`.
2. Encode every raw value into a one-dimensional binary SDR. Allocate one zero-filled NumPy array per encoder with `encoder.getWidth()` and call `encoder.encodeIntoArray(value, bits)`.
3. Concatenate encoder outputs. Set `SpatialPooler(inputDimensions=(encodingWidth,), columnDimensions=(columnCount,), ...)` so `encodingWidth == len(concatenatedEncoding)`.
4. Allocate `activeArray = numpy.zeros(columnCount, dtype="uint32")`, call `sp.compute(encoding, learn, activeArray)`, then pass `numpy.nonzero(activeArray)[0]` to `TemporalMemory.compute`.
5. Set `TemporalMemory(columnDimensions=(columnCount,), ...)` to the same column count used by the SP. Use `tm.getActiveCells()` for classifier `patternNZ`; use `tm.getPredictiveCells()` plus `tm.columnForCell(cell)` to build next-step predicted columns for anomaly score.
6. For scalar predictions, call `classifier.compute(recordNum, patternNZ, {"bucketIdx": bucketIdx, "actValue": rawValue}, learn=True, infer=True)`. Look for integer step keys such as `1` plus the `"actualValues"` key in the result.
7. For anomaly checks, compare current active columns with previous-step predicted columns using `computeRawAnomalyScore(activeColumns, prevPredictedColumns)`, then optionally update `AnomalyLikelihood` with the raw value, anomaly score, and timestamp.

## Minimal validation command

From this sub-skill directory in a prepared NuPIC legacy environment:

```bash
python scripts/algorithm_smoke.py --mode all --records 20 --encoder scalar
```

Expected success signal: the script prints `PASS`, encoder/SP/TM dimensions, a final one-step prediction summary, and bounded anomaly likelihood values. If it fails before imports, use root install/import troubleshooting; if it fails after imports, use the local troubleshooting reference.

## Evidence provenance

This sub-skill distills NuPIC legacy algorithm evidence from source/doc paths such as `src/nupic/algorithms/`, `src/nupic/encoders/`, `docs/source/quick-start/algorithms.rst`, `docs/examples/algo/complete-algo-example.py`, `examples/sp/hello_sp.py`, `examples/tm/hello_tm.py`, and unit tests under `tests/unit/nupic/algorithms/` and `tests/unit/nupic/encoders/`. Runtime guidance here is self-contained; future agents should not need to open the original checkout examples to use it.

Files in this skill

  • SKILL.md4.6 KB
  • references/api-reference.md9.9 KB
  • references/troubleshooting.md10.8 KB
  • references/workflows.md9.3 KB
  • scripts/algorithm_smoke.py13 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.