https://github.com/the-aerospace-corporation/brainblocks

Practical Tool for Building ML Applications with HTM-Like Algorithms

https://github.com/the-aerospace-corporation/brainblocks

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
Last synced: 10 months ago · JSON representation

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
Created about 6 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License

README.md

BrainBlocks

BrainBlocks Logo

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

Multivariate Abnormalities

Comparison with Scikit-learn Classifiers

Data Classification

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.6
  • pip

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

The Aerospace Corporation

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

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

All Time
  • Total Commits: 96
  • Total Committers: 4
  • Avg Commits per committer: 24.0
  • Development Distribution Score (DDS): 0.396
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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
dependencies (2)

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

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 105 Last month
Rankings
Stargazers count: 8.7%
Dependent packages count: 10.0%
Forks count: 10.2%
Average: 14.6%
Dependent repos count: 21.7%
Downloads: 22.2%
Maintainers (1)
Last synced: 11 months ago

Dependencies

examples/python/experiments/BBClassifier/requirements.txt pypi
  • brainblocks *
  • hypertools *
  • matplotlib *
  • numpy *
  • sklearn *
examples/python/experiments/datasets/requirements.txt pypi
  • brainblocks *
  • matplotlib *
  • pandas *
examples/python/experiments/hypergrid_transform/requirements.txt pypi
  • brainblocks *
  • matplotlib *
  • numpy *
  • scipy *
  • seaborn *
  • shapely *
examples/python/experiments/image_classification/requirements.txt pypi
  • brainblocks *
  • matplotlib *
  • scikit-image *
  • tensorflow *
examples/python/experiments/scalability/requirements.txt pypi
  • brainblocks *
  • matplotlib *
  • psutil *
.github/workflows/build-test.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/pypi-publish.yml actions
  • 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
.github/workflows/test-pypi-publish.yml actions
  • 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
pyproject.toml pypi
setup.py pypi