{"id":27465110,"url":"https://github.com/Qiskit/qiskit-machine-learning","last_synced_at":"2025-04-16T00:01:54.413Z","repository":{"id":36952821,"uuid":"342885422","full_name":"qiskit-community/qiskit-machine-learning","owner":"qiskit-community","description":"Quantum Machine Learning","archived":false,"fork":false,"pushed_at":"2025-03-24T13:52:48.000Z","size":62056,"stargazers_count":748,"open_issues_count":26,"forks_count":340,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-04-13T21:34:02.703Z","etag":null,"topics":["qiskit"],"latest_commit_sha":null,"homepage":"https://qiskit-community.github.io/qiskit-machine-learning/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qiskit-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-02-27T15:10:30.000Z","updated_at":"2025-04-10T09:00:27.000Z","dependencies_parsed_at":"2023-10-05T14:17:42.202Z","dependency_job_id":"6591ed28-613d-4e72-9b69-8d6d9a7b7440","html_url":"https://github.com/qiskit-community/qiskit-machine-learning","commit_stats":null,"previous_names":["qiskit-community/qiskit-machine-learning","qiskit/qiskit-machine-learning"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiskit-community%2Fqiskit-machine-learning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiskit-community%2Fqiskit-machine-learning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiskit-community%2Fqiskit-machine-learning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qiskit-community%2Fqiskit-machine-learning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qiskit-community","download_url":"https://codeload.github.com/qiskit-community/qiskit-machine-learning/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249173071,"owners_count":21224483,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["qiskit"],"created_at":"2025-04-16T00:01:22.405Z","updated_at":"2025-04-16T00:01:54.382Z","avatar_url":"https://github.com/qiskit-community.png","language":"Python","funding_links":[],"categories":["Quantum Software Packages","Python"],"sub_categories":[],"readme":"# Qiskit Machine Learning\n\n[![License](https://img.shields.io/github/license/qiskit-community/qiskit-machine-learning.svg?)](https://opensource.org/licenses/Apache-2.0) \u003c!--- long-description-skip-begin --\u003e\n[![Current Release](https://img.shields.io/github/release/qiskit-community/qiskit-machine-learning.svg?logo=Qiskit)](https://github.com/qiskit-community/qiskit-machine-learning/releases)\n[![Build Status](https://github.com/qiskit-community/qiskit-machine-learning/actions/workflows/main.yml/badge.svg)](https://github.com/qiskit-community/qiskit-machine-learning/actions?query=workflow%3A\"Machine%20Learning%20Unit%20Tests\"+branch%3Amain+event%3Apush)\n[![Monthly downloads](https://img.shields.io/pypi/dm/qiskit-machine-learning.svg)](https://pypi.org/project/qiskit-machine-learning/)\n[![Coverage Status](https://coveralls.io/repos/github/qiskit-community/qiskit-machine-learning/badge.svg?branch=main)](https://coveralls.io/github/qiskit-community/qiskit-machine-learning?branch=main)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/qiskit-machine-learning)\n[![Total downloads](https://static.pepy.tech/badge/qiskit-machine-learning)](https://pepy.tech/project/qiskit-machine-learning)\n[![Slack Organisation](https://img.shields.io/badge/slack-chat-blueviolet.svg?label=Qiskit%20Slack\u0026logo=slack)](https://slack.qiskit.org)\n\u003c!--- long-description-skip-end --\u003e\n\n## What is Qiskit Machine Learning?\n\nQiskit Machine Learning introduces fundamental computational building blocks, such as Quantum \nKernels and Quantum Neural Networks, used in various applications including classification \nand regression.\n\nThis library is part of the Qiskit Community ecosystem, a collection of high-level codes that are based\non the Qiskit software development kit. As of version `0.7`, Qiskit Machine Learning is co-maintained\nby IBM and the [Hartree Center](https://www.hartree.stfc.ac.uk/), part of the UK Science and \nTechnologies Facilities Council (STFC).\n\nThe Qiskit Machine Learning framework aims to be:\n\n* **User-friendly**, allowing users to quickly and easily prototype quantum machine learning models without \n    the need of extensive quantum computing knowledge.\n* **Flexible**, providing tools and functionalities to conduct proof-of-concepts and innovative research \n    in quantum machine learning for both beginners and experts.\n* **Extensible**, facilitating the integration of new cutting-edge features leveraging Qiskit's \n    architectures, patterns and related services.\n\n\n## What are the main features of Qiskit Machine Learning?\n\n### Kernel-based methods\n\nThe [`FidelityQuantumKernel`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.kernels.QuantumKernel.html#qiskit_machine_learning.kernels.FidelityQuantumKernel) \nclass uses the [`Fidelity`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.state_fidelities.BaseStateFidelity.html)) \nalgorithm. It computes kernel matrices for datasets and can be combined with a Quantum Support Vector Classifier ([`QSVC`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.QSVC.html#qiskit_machine_learning.algorithms.QSVC)) \nor a Quantum Support Vector Regressor ([`QSVR`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.QSVR.html#qiskit_machine_learning.algorithms.QSVR)) \nto solve classification or regression problems respectively. It is also compatible with classical kernel-based machine learning algorithms.\n\n\n### Quantum Neural Networks (QNNs)\n\nQiskit Machine Learning defines a generic interface for neural networks, implemented by two core (derived) primitives:\n\n- **[`EstimatorQNN`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.neural_networks.EstimatorQNN.html):** Leverages the [`Estimator`](https://docs.quantum.ibm.com/api/qiskit/qiskit.primitives.BaseEstimator) primitive, combining parametrized quantum circuits with quantum mechanical observables. The output is the expected value of the observable.\n  \n- **[`SamplerQNN`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.neural_networks.SamplerQNN.html):** Leverages the [`Sampler`](https://docs.quantum.ibm.com/api/qiskit/qiskit.primitives.BaseSampler) primitive, translating bit-string counts into the desired outputs.\n\nTo train and use neural networks, Qiskit Machine Learning provides learning algorithms such as the [`NeuralNetworkClassifier`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.NeuralNetworkClassifier.html#qiskit_machine_learning.algorithms.NeuralNetworkClassifier) \nand [`NeuralNetworkRegressor`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.NeuralNetworkRegressor.html#qiskit_machine_learning.algorithms.NeuralNetworkRegressor). \nFinally, built on these, the Variational Quantum Classifier ([`VQC`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.VQC.html#qiskit_machine_learning.algorithms.VQC))\nand the Variational Quantum Regressor ([`VQR`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.VQR.html#qiskit_machine_learning.algorithms.VQR))\ntake a _feature map_ and an _ansatz_ to construct the underlying QNN automatically using high-level syntax.\n\n### Integration with PyTorch\n\nThe [`TorchConnector`](https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.connectors.TorchConnector.html#qiskit_machine_learning.connectors.TorchConnector) \nintegrates QNNs with [PyTorch](https://pytorch.org). \nThanks to the gradient algorithms in Qiskit Machine Learning, this includes automatic differentiation. \nThe overall gradients computed by PyTorch during the backpropagation take into account quantum neural \nnetworks, too. The flexible design also allows the building of connectors to other packages in the future.\n\n## Installation and documentation\n\nWe encourage installing Qiskit Machine Learning via the `pip` tool, a `Python` package manager.\n\n```bash\npip install qiskit-machine-learning\n```\n\n`pip` will install all dependencies automatically, so that you will always have the most recent\nstable version.\n\nIf you want to work instead on the very latest _work-in-progress_ versions of Qiskit Machine Learning, \neither to try features ahead of\ntheir official release or if you want to contribute to the library, then you can install from source.\nFor more details on how to do so and much more, follow the instructions in the\n [documentation](https://qiskit-community.github.io/qiskit-machine-learning/getting_started.html#installation).\n\n### Optional Installs\n\n* **PyTorch** may be installed either using command `pip install 'qiskit-machine-learning[torch]'` to install the\n  package or refer to PyTorch [getting started](https://pytorch.org/get-started/locally/). When PyTorch\n  is installed, the `TorchConnector` facilitates its use of quantum computed networks.\n\n* **Sparse** may be installed using command `pip install 'qiskit-machine-learning[sparse]'` to install the\n  package. Sparse being installed will enable the usage of sparse arrays and tensors.\n\n* **NLopt** is required for the global optimizers. [`NLopt`](https://nlopt.readthedocs.io/en/latest/) \n  can be installed manually with `pip install nlopt` on Windows and Linux platforms, or with `brew \n  install nlopt` on MacOS using the Homebrew package manager. For more information, \n  refer to the [installation guide](https://nlopt.readthedocs.io/en/latest/NLopt_Installation/).\n\n## Migration to Qiskit 1.x\n\u003e [!NOTE]\n\u003e Qiskit Machine Learning depends on Qiskit, which will be automatically installed as a \n\u003e dependency when you install Qiskit Machine Learning. From version `0.8` of Qiskit Machine \n\u003e Learning, Qiskit `1.0` or above will be required. If you have a pre-`1.0` version of Qiskit \n\u003e installed in your environment (however it was installed), you should upgrade to `1.x` to \n\u003e continue using the latest features. You may refer to the \n\u003e official [Qiskit 1.0 Migration Guide](https://docs.quantum.ibm.com/api/migration-guides/qiskit-1.0) \n\u003e for detailed instructions and examples on how to upgrade Qiskit.\n\n----------------------------------------------------------------------------------------------------\n\n### Creating Your First Machine Learning Programming Experiment in Qiskit\n\nNow that Qiskit Machine Learning is installed, it's time to begin working with the Machine \nLearning module. Let's try an experiment using VQC (Variational Quantum Classifier) algorithm to\ntrain and test samples from a data set to see how accurately the test set can be classified.\n\n```python\nfrom qiskit.circuit.library import TwoLocal, ZZFeatureMap\nfrom qiskit_machine_learning.optimizers import COBYLA\nfrom qiskit_machine_learning.utils import algorithm_globals\n\nfrom qiskit_machine_learning.algorithms import VQC\nfrom qiskit_machine_learning.datasets import ad_hoc_data\n\nseed = 1376\nalgorithm_globals.random_seed = seed\n\n# Use ad hoc data set for training and test data\nfeature_dim = 2  # dimension of each data point\ntraining_size = 20\ntest_size = 10\n\n# training features, training labels, test features, test labels as np.ndarray,\n# one hot encoding for labels\ntraining_features, training_labels, test_features, test_labels = ad_hoc_data(\n    training_size=training_size, test_size=test_size, n=feature_dim, gap=0.3\n)\n\nfeature_map = ZZFeatureMap(feature_dimension=feature_dim, reps=2, entanglement=\"linear\")\nansatz = TwoLocal(feature_map.num_qubits, [\"ry\", \"rz\"], \"cz\", reps=3)\nvqc = VQC(\n    feature_map=feature_map,\n    ansatz=ansatz,\n    optimizer=COBYLA(maxiter=100),\n)\nvqc.fit(training_features, training_labels)\n\nscore = vqc.score(test_features, test_labels)\nprint(f\"Testing accuracy: {score:0.2f}\")\n```\n\n### More examples\n\nLearning path notebooks may be found in the\n[Machine Learning tutorials](https://qiskit-community.github.io/qiskit-machine-learning/tutorials/index.html) section\nof the documentation and are a great place to start. \n\nAnother good place to learn the fundamentals of quantum machine learning is the\n[Quantum Machine Learning](https://github.com/Qiskit/textbook/tree/main/notebooks/quantum-machine-learning#) notebooks from the original Qiskit Textbook. The notebooks are convenient for beginners who are eager to learn \nquantum machine learning from scratch, as well as understand the background and theory behind algorithms in\nQiskit Machine Learning. The notebooks cover a variety of topics to build understanding of parameterized\ncircuits, data encoding, variational algorithms etc., and in the end the ultimate goal of machine\nlearning - how to build and train quantum ML models for supervised and unsupervised learning. \nThe Textbook notebooks are complementary to the tutorials of this module; whereas these tutorials focus\non actual Qiskit Machine Learning algorithms, the Textbook notebooks more explain and detail underlying fundamentals\nof quantum machine learning.\n\n----------------------------------------------------------------------------------------------------\n\n## How can I contribute?\n\nIf you'd like to contribute to Qiskit, please take a look at our\n[contribution guidelines](https://github.com/qiskit-community/qiskit-machine-learning/blob/main/CONTRIBUTING.md).\nThis project adheres to the Qiskit [code of conduct](https://github.com/qiskit-community/qiskit-machine-learning/blob/main/CODE_OF_CONDUCT.md).\nBy participating, you are expected to uphold this code.\n\nWe use [GitHub issues](https://github.com/qiskit-community/qiskit-machine-learning/issues) for tracking requests and bugs. Please\n[join the Qiskit Slack community](https://qisk.it/join-slack)\nand use the [`#qiskit-machine-learning`](https://qiskit.enterprise.slack.com/archives/C07JE3V55C1) \nchannel for discussions and short questions.\nFor questions that are more suited for a forum, you can use the **Qiskit** tag in [Stack Overflow](https://stackoverflow.com/questions/tagged/qiskit).\n\n## Humans behind Qiskit Machine Learning\n\nQiskit Machine Learning was inspired, authored and brought about by the collective work of a \nteam of researchers  and software engineers. This library continues to grow with the help and \nwork of \n[many people](https://github.com/qiskit-community/qiskit-machine-learning/graphs/contributors), \nwho contribute to the project at different levels.\n\n## How can I cite Qiskit Machine Learning?\nIf you use Qiskit, please cite as per the provided\n[BibTeX file](https://github.com/Qiskit/qiskit/blob/main/CITATION.bib).\n\n## License\n\nThis project uses the [Apache License 2.0](https://github.com/qiskit-community/qiskit-machine-learning/blob/main/LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FQiskit%2Fqiskit-machine-learning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FQiskit%2Fqiskit-machine-learning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FQiskit%2Fqiskit-machine-learning/lists"}