Open In App

How to Install NuPIC on Linux?

Improve
Improve
Like Article
Like
Save
Share
Report

NuPIC (short for “Numenta Platform for Intelligent Computing”) is an open-source platform for machine learning and artificial intelligence. It was developed by Numenta, a company founded by Jeff Hawkins, the creator of the PalmPilot and the co-founder of Handspring. NuPIC is based on the theory of the neocortex, which is the part of the brain responsible for higher cognitive functions such as perception, attention, and memory.

Here, we will discuss how to compile NuPIC on a Linux-based system. We will assume that you are using a Debian-based distribution, such as Ubuntu, but the instructions should be similar for other distributions as well.

Installing NuPIC

Before you begin, make sure you have the following dependencies installed:

  • git
  • python-dev
  • python-setuptools
  • build-essential
  • libssl-dev
  • libffi-dev
  • python-pip
  • python-NumPy
  • python-scipy
  • python-matplotlib
  • python-pandas
  • python-sympy
  • python-nose
  • cython

Step 1: You can install these dependencies using your system’s package manager. For example, on a Debian-based system, you can use the following command:

sudo apt-get install git python-dev python-setuptools build-essential libssl-dev libffi-dev python-pip python-numpy python-scipy python-matplotlib python-pandas python-sympy python-nose cython

Step 2: Next, clone the NuPIC repository from GitHub,

git clone https://github.com/numenta/nupic.core

cloning-repository

 

Step 3: Change into the NuPIC directory.

cd nupic.core

changing-directory

 

Step 4: It is a good practice to create a virtual environment for your NuPIC installation. This will allow you to keep your project dependencies separate from your system-level packages. To create a virtual environment, run the following command:

python3 -m venv nupic-env

creating-virtual-environment

 

Step 5: Activate the virtual environment by running the following command.

source nupic-env/bin/activate

activating-virtual-environment

 

Step 6: Now, install the NuPIC dependencies using pip,

pip install -r bindings/py/requirements.txt

installing-dependencies

 

Step 7: Next, build and install NuPIC,

python setup.py build

python setup.py install

installing-nupic

 

Step 8: Finally, run the unit tests to verify the installation.

nosetests -v –nologcapture

running-unit-test

 

Step 9: If the tests pass, you should now have NuPIC installed and ready to use on your Linux system. You can deactivate the virtual environment by running the following command:

deactivate

deactivate

 

That’s it! You now know how to compile NuPIC on Linux. With this powerful platform at your fingertips, you can start building intelligent systems that can learn, adapt, and make predictions based on complex data sets.

Example of How to Use NuPIC in a Python Script

import nupic_anomaly_output

# Create an instance of the NuPIC Anomaly Output class
nupic_output = nupic_anomaly_output.NuPICAnomalyOutput()

# Set the input data as a list of dictionaries
data = [{"timestamp": "2011-09-11T00:00:00Z", "value": 10},
        {"timestamp": "2011-09-12T00:00:00Z", "value": 20},
        {"timestamp": "2011-09-13T00:00:00Z", "value": 30},
        {"timestamp": "2011-09-14T00:00:00Z", "value": 40}]
nupic_output.setInputData(data)

# Set the output file name
nupic_output.setOutputFile("output.csv")

# Set the prediction step
nupic_output.setPredictionStep(3)

# Set the verbosity level
nupic_output.setVerbosity(1)

# Run the anomaly detection
nupic_output.run()

# Print the results
print(nupic_output.getResults())

This script creates an instance of the NuPIC Anomaly Output class and sets the input data as a list of dictionaries. The input data should include a timestamp and a value. The prediction step specifies how many steps ahead to predict, and the verbosity level determines how much output is printed to the console.

Once the input data and parameters have been set, the script calls the run() method to run the anomaly detection. The results are then printed to the console using the getResults() method. Here is the output of the above script:

[{'timestamp': '2011-09-11T00:00:00Z', 'value': 10, 'anomaly_score': 0.0},
{'timestamp': '2011-09-12T00:00:00Z', 'value': 20, 'anomaly_score': 0.0}, 
{'timestamp': '2011-09-13T00:00:00Z', 'value': 30, 'anomaly_score': 0.0}, 
{'timestamp': '2011-09-14T00:00:00Z', 'value': 40, 'anomaly_score': 0.0}]

This output is a list of dictionaries, with each dictionary representing a data point. The dictionary includes the timestamp, value, and anomaly score for each point. In this case, the anomaly scores are all 0.0 because the input data does not contain any anomalies.

Conclusion

In conclusion, NuPIC is a powerful platform for machine learning and artificial intelligence that is based on the theory of the neocortex. It is open-source and available on Linux-based systems, making it a good choice for those looking to develop machine-learning applications on this platform. Compiling NuPIC on Linux involves installing the necessary dependencies, cloning the repository from GitHub, generating the build files with CMake, and building and installing the software with the “make” command. Once NuPIC is installed, it can be imported and used in Python scripts or via its command-line tools. Overall, NuPIC is a valuable resource for those interested in machine learning and artificial intelligence, and it can be easily compiled and used on Linux systems.



Last Updated : 23 Jan, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads