Getting started¶
Installation¶
Qiskit Machine Learning depends on Qiskit, which has its own installation instructions detailing installation options and its supported environments/platforms. You should refer to that first. Then the information here can be followed which focuses on the additional installation specific to Qiskit Machine Learning.
Qiskit Machine Learning has some functions that have been made optional where the dependent code and/or support program(s) are not (or cannot be) installed by default. Those are PyTorch, Sparse and NLopt. See Optional installs for more information.
The simplest way to get started is to follow the installation guide for Qiskit here
In your virtual environment, where you installed Qiskit, install qiskit-machine-learning as follows:
pip install qiskit-machine-learning
Note
As Qiskit Machine Learning depends on Qiskit, you can though simply install it into your environment, as above, and pip will automatically install a compatible version of Qiskit if one is not already installed.
Installing Qiskit Machine Learning from source allows you to access the most recently updated version under development instead of using the version in the Python Package Index (PyPI) repository. This will give you the ability to inspect and extend the latest version of the Qiskit Machine Learning code more efficiently.
Since Qiskit Machine Learning depends on Qiskit, and its latest changes may require new or changed features of Qiskit, you should first follow Qiskit’s “Install from source” instructions here
Installing Qiskit Machine Learning from Source
Using the same development environment that you installed Qiskit in you are ready to install Qiskit Machine Learning.
Clone the Qiskit Machine Learning repository.
git clone https://github.com/qiskit-community/qiskit-machine-learning.git
Cloning the repository creates a local folder called
qiskit-machine-learning.cd qiskit-machine-learning
If you want to run tests or linting checks, install the developer requirements.
pip install -r requirements-dev.txt
Install
qiskit-machine-learning.pip install .
If you want to install it in editable mode, meaning that code changes to the project don’t require a reinstall to be applied, you can do this with:
pip install -e .
Optional installs¶
PyTorch, may be installed either using command
pip install 'qiskit-machine-learning[torch]'to install the package or refer to PyTorch getting started. When PyTorch is installed, the TorchConnector facilitates its use of quantum computed networks.Sparse, may be installed using command
pip install 'qiskit-machine-learning[sparse]'to install the package. Sparse being installed will enable the usage of sparse arrays/tensors.NLopt is required for the global optimizers. NLOpt can be installed manually with
pip install nlopton Windows and Linux platforms, or withbrew install nlopton MacOS using the Homebrew package manager. For more information, refer to the installation guide.
How can I contribute?¶
If you’d like to contribute to Qiskit, please take a look at our contribution guidelines. This project adheres to the Qiskit code of conduct. By participating, you are expected to uphold this code.
We use GitHub issues for tracking requests and bugs. Please join the Qiskit Slack community and use the #qiskit-machine-learning channel for discussions and short questions. For questions that are more suited for a forum, you can use the Qiskit tag in Stack Overflow.
How can I cite Qiskit Machine Learning?¶
If you use Qiskit Machine Learning in your work, please cite the “overview” ArXiv paper to support the continued development and visibility of the library.