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.
For this quick walk-through we will pick a simple classification problem. The breast cancer dataset which is bundled with sklearn
.
This will show you the core concepts in building a graph to execute predictions, that you can deploy to your application.
Connect to your QLattice
from feyn import QLattice
qlattice = QLattice(url = "<URL to your qlattice>")
qlattice
Add registers
Read the example dataset and add a register
for each column in the dataset.
The registers describes your problem. Which features goes in, and which feature do you want to predict. Often the same as the columns in your dataset.
import sklearn.datasets
import pandas as pd
breast_cancer = sklearn.datasets.load_breast_cancer()
# Convert to a pandas dataframe
df = pd.DataFrame(breast_cancer.data,columns=breast_cancer.feature_names)
df['target'] = pd.Series(breast_cancer.target)
df.head()
in_registers = []
# Create an input register for each input feature
for feature in breast_cancer.feature_names:
in_registers.append(qlattice.add_register(label=feature, register_type="cont"))
# Turn the target column into an output register
out_reg = qlattice.add_register(label='target')
Now the QLattice
is prepared for your problem.
Train locally and update learnings remotely
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 new QGraph
will fit your problem better.
Notice, that the QLattice
lives remotely on the Abzu cluster, but it never sees your local data. The dataset stays on your premise. So, you train locally, and just transmit your learnings to the QLattice
. That is the way the QLattice
gets better at producing QGraphs
that fits your problem.
from sklearn.model_selection import train_test_split
X = df[breast_cancer.feature_names]
y = df["target"]
X_test, X_train, y_test, y_train = train_test_split(X, y, test_size=0.33)
for _ in range(10):
# Get a QGraph full of graphs between your inputs and output from the remote QLattice.
# This QGraph will be biased towards what was learned from the previous `update` calls.
qgraph = qlattice.get_qgraph(in_registers, out_reg)
# Now tune the local QGraph with your local data
qgraph.tune(X_train, y_train, epochs=10)
# Select the graph with lowest loss as the best solution.
# You could consider other attributes as your "best" (accuracy, complexity, etc.).
best_graph = qgraph.graphs[0]
# Teach the QLattice about this solution, so that it gets biased towards solutions similar to this.
qlattice.update(best_graph)
Evaluate
Finally, evaluate the results in the test dataset.
This is also how you utilize the tuned graph
for predictions in your application.
from feyn import tools
# Use the graph to produce predictions. This graph is similar your model in other framework.
# It is the thing you can save to a file, and deploy to your application or production environment.
predictions = best_graph.predict(X_test)
# This is a classification problem, but we are using a regression model to solve it.
# There are many ways to do this. In this example we will round to nearest integer (the class).
predictions = predictions.round()
tools.plot_confusion_matrix(y_true=y_test,
y_pred=predictions,
title="Evaluation Results")
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.1.0b1-cp38-cp38-manylinux2014_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.0b1-cp38-cp38-manylinux2014_x86_64.whl
- Upload date:
- Size: 137.2 kB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98c21d30e19b7fa320450d43271ccbd8a7a9cf1f0ac7531f486bc219dc2ad838 |
|
MD5 | fce10d41bddd21dad4230d0f8cc4f581 |
|
BLAKE2b-256 | 5766e5c6b32fa00a26fafac5c1efdd076cb3fd5e10aece3f667bb1783d0bfd9b |
File details
Details for the file feyn-1.1.0b1-cp38-cp38-manylinux1_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.0b1-cp38-cp38-manylinux1_x86_64.whl
- Upload date:
- Size: 137.2 kB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edf2a8e7d479836506681678d4c17e951398f90385181c528bf4d56289ab5809 |
|
MD5 | 1e4438489bc92ff348b68df0e94d5b66 |
|
BLAKE2b-256 | 6356596aa1048c2dd9bc5e5fdd3f1430c74edeb640d1f7b324541534201d7a11 |
File details
Details for the file feyn-1.1.0b1-cp38-cp38-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.0b1-cp38-cp38-macosx_10_15_x86_64.whl
- Upload date:
- Size: 50.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 | 0c9175e9849518ee0a9d242d2228b03fefaad109a03d9e1d4587bdee83d84453 |
|
MD5 | a72ffe0b3a7b5111e9e4c1c5bf469d80 |
|
BLAKE2b-256 | 46973b91168f8ddfeba47f1b1d5c708a1ca657e2d822f6855f14fb70f3babd34 |
File details
Details for the file feyn-1.1.0b1-cp38-cp38-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.0b1-cp38-cp38-macosx_10_14_x86_64.whl
- Upload date:
- Size: 50.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 | ce40e3cd942fd7a86af7ae6af91955f0221effa935dc00a5f27e4d84e4d0b6e9 |
|
MD5 | 79bc53c640201ad868ab7d7010d6c2fa |
|
BLAKE2b-256 | cb1c5b7249cc4fd6a85dff954d17dda6db4ee7bc4cdeef2e314189d21d387f7d |
File details
Details for the file feyn-1.1.0b1-cp37-cp37m-manylinux2014_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.0b1-cp37-cp37m-manylinux2014_x86_64.whl
- Upload date:
- Size: 138.4 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 505048a57f27f5fb4f4f453e8b7333ea1a325db32ca6b958af73d59aaaa48ff3 |
|
MD5 | 90b9ba0cfbfc36e0e7a01418c2f69bee |
|
BLAKE2b-256 | cb822fc844479ad20f93b269525a1b9e719a07cfec53d0bc04c6f111d0c75a50 |
File details
Details for the file feyn-1.1.0b1-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.0b1-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 138.4 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22bf0c8b4d9348afebb9099fe2991b565720e4f379b4d5e9e9f8c2c9aa9dfe86 |
|
MD5 | 1c7dd3441883b52e5a100828b8c666c2 |
|
BLAKE2b-256 | e6c716d57d4cb0e0e7e736dd33034c09ae737acfb85a20abe8e23c6422ce6336 |
File details
Details for the file feyn-1.1.0b1-cp37-cp37m-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.0b1-cp37-cp37m-macosx_10_15_x86_64.whl
- Upload date:
- Size: 50.1 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a538c2c0dec0ffcc7dcd8e9c39e42d78783d9a41e045b14d9af8ef58d2225cb |
|
MD5 | fac3114aa71339bfe23ea7313612e96d |
|
BLAKE2b-256 | 4f2ee207c3acd538a2fd9e8c0ae6e687b622f7b20fd28bb6073f367a6502ccc5 |
File details
Details for the file feyn-1.1.0b1-cp37-cp37m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.0b1-cp37-cp37m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 50.1 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 | d6c3b65075d1fb835c5ca6e3e47733d614cfedd0b9b2fdef915eade174a699d7 |
|
MD5 | cb0cd0d04a5dddf3003d5d4c8d6f5ebd |
|
BLAKE2b-256 | 75291037cbbc6dc689099eaee8fe5794c93517065633ee001367e9357b8113d9 |
File details
Details for the file feyn-1.1.0b1-cp36-cp36m-manylinux2014_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.0b1-cp36-cp36m-manylinux2014_x86_64.whl
- Upload date:
- Size: 133.6 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 126c915524bf226de7f814804811bef5906d40c2ef3940e0ac5bf72e5a05c20f |
|
MD5 | b502415992b698e75d20089e7ae9a4e5 |
|
BLAKE2b-256 | efaa078372a00edafa151bf24fe80befbdb0b25784d6666f73c9640718e0078f |
File details
Details for the file feyn-1.1.0b1-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.0b1-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 133.6 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d34cc4d966f96f889a8b230c1522b4ae295092a86e39d7eceea39e6c162d24c |
|
MD5 | b032e31b9c893c56d5428bcdedb944de |
|
BLAKE2b-256 | f9569f9ba55787ebcfafcd1537b4243bd5e291b9a3a619085f4f93e8e141a03a |
File details
Details for the file feyn-1.1.0b1-cp36-cp36m-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.0b1-cp36-cp36m-macosx_10_15_x86_64.whl
- Upload date:
- Size: 50.1 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 | f0b8339cb36042bf40ce41a3ffab7778515e9875ff49a2392d2225a261b8ca91 |
|
MD5 | ac5f3a68cc97ee59dc4a8333ccee41c3 |
|
BLAKE2b-256 | bf189a4930521a630f764b50c240c223ac360a7744b4858373fd7db728d8c355 |
File details
Details for the file feyn-1.1.0b1-cp36-cp36m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.0b1-cp36-cp36m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 50.1 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 | 92c4129a5c5c698cd29ab898442b79741cb1beff95a9157b70d1e24a13fec6ea |
|
MD5 | 6788c80d8474bf479f845c64d5e9d53f |
|
BLAKE2b-256 | 211ff2cf21f7ec30dbb8959aa65c1536b6ebff01a3bb6f5d302aa69224b112a3 |