https://github.com/the-aerospace-corporation/brainblocks
Practical Tool for Building ML Applications with HTM-Like Algorithms
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.4%) to scientific vocabulary
Repository
Practical Tool for Building ML Applications with HTM-Like Algorithms
Basic Info
- Host: GitHub
- Owner: the-aerospace-corporation
- License: agpl-3.0
- Language: C++
- Default Branch: master
- Size: 1.17 MB
Statistics
- Stars: 60
- Watchers: 13
- Forks: 13
- Open Issues: 3
- Releases: 2
Metadata Files
README.md
BrainBlocks

Introduction
BrainBlocks is a framework developed by The Aerospace Corporation for building scalable Machine Learning (ML) applications using principles derived from computational neuroscience. It models neuron activations with binary patterns (vectors of 1s and 0s) which form a kind of "cortical language". Assemblages of computational blocks transmit these binary patterns between each other to create computational workflows that exploit these neuroscience principles.
BrainBlocks is a Python 3 library wrapped around a single-thread C++ backend. The design of BrainBlocks represents the practical experience gained from solving machine learning problems using a Hierarchical Temporal Memory (HTM) like approach.
Design
BrainBlocks is designed to be:
- Usable: solve practical ML applications
- Scalable: quick and easy to build block hierarchies of any size
- Extensible: improve existing or develop entirely new blocks
- Fast: leverages low-level bitwise operations
- Low Memory: maintain as low memory footprint as possible
- Lightweight: small project size
The current computational blocks provided are: - Transformers: Encodes symbols, scalars, or vectors into binary patterns for processing by BrainBlocks. - PatternClassifier: Supervised learning classifier for binary patterns. - PatternPooler: Learns mapping from one representation to a pooled representation. - ContextLearner: Learn inputs in provided contexts. Flags anomaly if inputs are out-of-context. - SequenceLearner: Learns input sequences. Flags anomaly if previously unseen sequences are detected.
Theory
Further discussion on the theory of BrainBlocks can be found here.
Machine Learning
Multivariate Time-Series Anomaly Detection

Comparison with Scikit-learn Classifiers

Getting Started
System Requirements
BrainBlocks is known to run on the following platforms:
- Windows (7,8,10,11)
- MacOS (10.14 or higher)
- Linux (Ubuntu 16+, CentOS 7+)
To install and run, you need at least the following
python>=3.6pip
If you want to develop BrainBlocks on your system, you need at least the following additional dependencies:
- git
- C/C++ compiler (clang, visual studio, gcc, etc.)
Install
The easiest way to install BrainBlocks is using pip.
bash
pip install brainblocks
Run
Begin by running any of the examples found in the examples directory. Here we show converting scalar values into binary patterns using the ScalarTransformer.
bash
python examples/python/transformers/scalar_transformer.py
An abridged version of the script is shown below: ```python from brainblocks.blocks import ScalarTransformer
Scalar value sequence
values = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
Configure ScalarTransformer
st = ScalarTransformer( minval=0.0, # minimum input value maxval=1.0, # maximum input value nums=128, # number of statelets numas=16) # number of active statelets
Convert scalars to distributed binary representation
for i in range(len(values)):
# Set scalar value and compute
st.set_value(values[i])
st.feedforward()
# print scalar value and its binary representation
print(values[i], st.output.bits)
```
Development
Build
Alternatively, you can build BrainBlocks on your system following these steps.
Clone the repository
bash
git clone https://github.com/the-aerospace-corporation/brainblocks
Change to the project directory
bash
cd brainblocks
Build and install
bash
pip install .
Build Alternatives
You can build the python packages separately and find them in dist/ if the build package is installed in your environment.
bash
pip install build
python -m build
We also provide a helper script to build and reinstall BrainBlocks if you are making changes to the core code and want to experiment. This will clean up previous BrainBlocks installations and install fresh from the local code.
bash
python helper.py --install
Tests
Run Python unit tests:
bash
pytest
Build core C++ unit tests
bash
python helper.py --cpptests
cd build/tests/cpp
ls test_*
More Helper Script Options
Clean project directory of build artifacts:
bash
python helper.py --clean
Python unit tests
bash
python helper.py --test
Uninstall from Python environment
bash
python helper.py --uninstall
Just build Python packages
bash
python helper.py --build
Project Layout
bash
.
├── .github # Workflow scripts for build, testing, and packaging
├── build # Temporary build workspace
├── dist # Temporary location of built python packages
├── docs # Extra Documentation
├── examples # Examples of BrainBlocks usage
│ └── python
│ └── classification # PatternClassifier examples
│ └── context_learner # ContextLearner examples
│ └── pooling # PatternPooler example
│ └── experiments # Experiments and visualizations
│ └── sequence_learner # SequenceLearner examples
│ └── transformers # Transformer examples
├── src
│ ├── cpp # Core C++ code
│ │ └── blocks # Core C++ block algorithms
│ ├── python # Python package code
│ │ ├── blocks # Interface to block primitives
│ │ ├── datasets # Dataset generation tools
│ │ ├── metrics # Metrics for binary representations
│ │ ├── templates # Common architecture templates
│ │ └── tools # High-level package tools
│ └── wrappers # Python bindings
├── tests # Unit tests
│ ├── cpp # C++ core unit tests
│ └── python # Python nit tests
├── .gitignore # files to exclude from version control
├── CMakeLists.txt # CMake configuration for core C++ build
├── helper.py # Helper script
├── LICENSE # AGPLv3 license
├── MANIFEST.in # Manifest file for python package
├── pyproject.toml # Modern build system configuration file
├── README.md # README file
└── setup.cfg # setuptools config values
└── setup.py # setuptools build script
About Us

This projected was developed internally at The Aerospace Corporation by:
License
This project is licensed under AGPLv3.
© The Aerospace Corporation 2022
Owner
- Name: The Aerospace Corporation
- Login: the-aerospace-corporation
- Kind: organization
- Location: El Segundo, California
- Website: https://aerospace.org/
- Repositories: 8
- Profile: https://github.com/the-aerospace-corporation
We are THE Aerospace Corporation. A trusted partner. A national resource. A leader in national security space.
GitHub Events
Total
- Watch event: 3
- Fork event: 1
Last Year
- Watch event: 3
- Fork event: 1
Committers
Last synced: 12 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Jacob Everist | j****t@g****m | 58 |
| David Di Giorgio | E****4@a****g | 30 |
| ddigiorg | d****g@g****m | 7 |
| Henrik Kubitza | h****a@x****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 15
- Total pull requests: 5
- Average time to close issues: 7 months
- Average time to close pull requests: 8 months
- Total issue authors: 9
- Total pull request authors: 4
- Average comments per issue: 4.53
- Average comments per pull request: 0.4
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 1
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 1
Top Authors
Issue Authors
- Thanh-Binh (4)
- klokare (2)
- marty1885 (2)
- HMaker (2)
- rphilip-sonasoft (1)
- vaibhavch (1)
- dee-corr (1)
- Codie-Petersen (1)
- AlexSteveChungAlvarez (1)
Pull Request Authors
- Qubitza (2)
- dependabot[bot] (2)
- msethi-sonasoft (1)
- jacobeverist (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 105 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 1
- Total maintainers: 1
pypi.org: brainblocks
BrainBlocks Toolkit
- Homepage: https://github.com/the-aerospace-corporation/brainblocks
- Documentation: https://brainblocks.readthedocs.io/
- License: GNU Affero General Public License v3.0 only
-
Latest release: 0.7.1
published about 4 years ago
Rankings
Maintainers (1)
Dependencies
- brainblocks *
- hypertools *
- matplotlib *
- numpy *
- sklearn *
- brainblocks *
- matplotlib *
- pandas *
- brainblocks *
- matplotlib *
- numpy *
- scipy *
- seaborn *
- shapely *
- brainblocks *
- matplotlib *
- scikit-image *
- tensorflow *
- brainblocks *
- matplotlib *
- psutil *
- actions/checkout v2 composite
- actions/setup-python v2 composite
- RalfG/python-wheels-manylinux-build v0.4.2-manylinux2014_x86_64 composite
- actions/checkout v2 composite
- actions/download-artifact v3 composite
- actions/setup-python v2 composite
- actions/upload-artifact v3 composite
- pypa/gh-action-pypi-publish v1.5.0 composite
- RalfG/python-wheels-manylinux-build v0.4.2-manylinux2014_x86_64 composite
- actions/checkout v2 composite
- actions/download-artifact v3 composite
- actions/setup-python v2 composite
- actions/upload-artifact v3 composite
- pypa/gh-action-pypi-publish v1.5.0 composite