High level Python interface to abzu qlattice
Project description
Feyn: AI by Abzu
Feyn is a Python library that pushes machine learning to a new level by taking strong inspiration from quantum physics. A Feyn-model is based on the path integral formulation of quantum physics originally proposed by the American physicist Richard P. Feynman.
Feyn-model is in many ways similar to Neural Network (or Deep Learning) models, so some of the concepts may be familiar to you already. But at it's core, the Feyn-model introduces a new way to work with your data together with a revolutionary way to accumulate and transfer learnings.
But let's start with the basics.
To generate a Feyn-model you need access to a Qlattice, short for Quantum Lattice. A QLattice is a high-performance quantum simulator that runs on dedicated hardware. To learn more about getting access to a QLattice, visit www.abzu.ai
The other needed component is this Python package (feyn) that runs on your computer and accumulate learnings from your data. These learnings are communicated to your QLattice over the network.
A QLattice is the heart of a Feyn-model. The QLattice is divided into 2 different parts: the registers and the interactions.
The registers are what we use to interact with the QLattice. They are the input and output interface of a Feyn-model. There are different register types, but the basics are continuous
and categorical
. The output register is always continuous
. More on this later.
The interactions layer is where the learnings are stored and is what we use to extract the QGraphs.
The QGraph represents all possible graphs, from the input registers to the output register. In human words that means all possible explanations for the given output with the given inputs, suggested by the qlattice.
Getting started: Feyn in 1 min
Ok, all this sounds good! But in practice how does this work?
Let us walk through a simple classification problem, step by step.
Create a blank QLattice
.
from feyn import QLattice
ql = QLattice()
ql
Read the example dataset and add a register
for each column in the dataset.
import sklearn.datasets
import pandas as pd
X, y = sklearn.datasets.load_breast_cancer(return_X_y=True)
in_registers = []
_data = {}
for i in range(X.shape[1]):
label = 'inp_%i' % i
_data[label] = X[:, i]
in_registers.append(ql.add_register(label=label, register_type="cont"))
X = pd.DataFrame(_data)
out_reg = ql.add_register(label='out')
Now the QLattice
is prepared for your problem.
Next, run for some epochs, where you retrieve a new QGraph
, tune it, and update the QLattice
with the learnings from the best graph.
The update calls will bias the QLattice
from your learnings. Meaning that next time you call QLattice.get_qgraph
, the QGraph
will fit your problem better.
from sklearn.model_selection import train_test_split
X_test, X_train, y_test, y_train = train_test_split(X, y, test_size=0.33)
for _ in range(10):
qgraph = ql.get_qgraph(in_registers, out_reg)
qgraph.tune(X_train, y_train, epochs=10)
best_graph = qgraph.graphs[0]
ql.update(best_graph)
Finally, evaluate the results in the test dataset.
from feyn import tools
prediction = best_graph.predict(X_test)
tools.plot_confusion_matrix(y_true=y_test,
y_pred=prediction.round(),
title="Evaluation Results")
For a detailed tutorial about Feyn continue with:
- Getting Started with Feyn
- Building complex trainers
Installation
Feyn is available as python package distributed from PyPi server.
Requirements:
- OS: Linux
- Python 3.6, 3.7 or 3.8
- Graphviz is used to draw charts (optional):
foo@bar:~$ sudo apt install graphviz
You can install it with the following command
foo@bar:~$ pip3 install feyn
Alternatively or if you don't have Linux OS you can use the jupyterlab Docker image.
foo@bar:~$ docker run -it --net=host abzu/jupyterlab:latest
adding the current folder as /data to the working directory.
foo@bar:~$ docker run -it --net=host -v $(pwd):/data abzu/jupyterlab:latest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file feyn-1.0.3.dev0-cp38-cp38-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: feyn-1.0.3.dev0-cp38-cp38-macosx_10_15_x86_64.whl
- Upload date:
- Size: 40.3 kB
- Tags: CPython 3.8, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 788c4dc4c0d19f0f74e53d34dfc19cb158c2d22a8a4c981bded5edab790c0a9b |
|
MD5 | b922fb78b4c73a8dd0e1a3a0588758f0 |
|
BLAKE2b-256 | 7a9aea8d4a143509a1790a3362380733d9f316976ed17de6e554eedd2548b504 |
File details
Details for the file feyn-1.0.3.dev0-cp38-cp38-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: feyn-1.0.3.dev0-cp38-cp38-macosx_10_14_x86_64.whl
- Upload date:
- Size: 40.2 kB
- Tags: CPython 3.8, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f6acf81943ff4edc9278a22dfddc43a09673024e55203bcd7b09c77a2d85186 |
|
MD5 | d4e49a90a40fb2b30929bc1d7f6cd906 |
|
BLAKE2b-256 | 427a6fa4b4c23f4ad06cb0e7ccc67362e4b421fd21c67015b3099c30bece3e31 |
File details
Details for the file feyn-1.0.3.dev0-cp37-cp37m-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: feyn-1.0.3.dev0-cp37-cp37m-macosx_10_15_x86_64.whl
- Upload date:
- Size: 40.3 kB
- Tags: CPython 3.7m, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e9912094d0360acb020d7f5ab8f879dd0d69c65fba33daf67778ca45e6a6fa9 |
|
MD5 | 6495e0e9e77111665535f430e687f17e |
|
BLAKE2b-256 | 10ac936a458fef5910c93f2ef95908b41ef5c612835b53ba4a8deb1271ffb425 |
File details
Details for the file feyn-1.0.3.dev0-cp37-cp37m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: feyn-1.0.3.dev0-cp37-cp37m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 40.2 kB
- Tags: CPython 3.7m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3fc8669e8f4b0ebcb027b91523fa28c317b16d3c7cef2f63abf7eac6ea70a6d |
|
MD5 | 561db87346140c16dd2bb74d66182b76 |
|
BLAKE2b-256 | 7ad3ac343d15c17aeddda1113d67eb2a760583f1fb2cb3455e9aed36d4bf516f |
File details
Details for the file feyn-1.0.3.dev0-cp36-cp36m-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: feyn-1.0.3.dev0-cp36-cp36m-macosx_10_15_x86_64.whl
- Upload date:
- Size: 40.3 kB
- Tags: CPython 3.6m, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1ab350fd6a629c6bd6f1d7a71904db27f5e615236e24b46e35852f3a39debaa |
|
MD5 | 66d0b5c33109c22f035f480ace06aca4 |
|
BLAKE2b-256 | 63d15d359fe9af7e7f606e769cadb1a98f3aa83c5bee4b5b8b03dbe66d3877fd |
File details
Details for the file feyn-1.0.3.dev0-cp36-cp36m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: feyn-1.0.3.dev0-cp36-cp36m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 40.2 kB
- Tags: CPython 3.6m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 214a92fc47fead274d4e1e8119bae0b3f0b709796b62ac2e17f82befba61da0e |
|
MD5 | 538230f3f57253877a383795692752c5 |
|
BLAKE2b-256 | 70cb18e3a992de1da527979fa072c291921afff7b709784982d22812ca7cf597 |