Feyn is the high level Python interface to interact with an 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 models are 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. 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.
The QLattice is a high-performance quantum simulator that runs on dedicated hardware, hosted on a cluster. It is based on the path integral formulation, which is an approach to quantum mechanics that was originally proposed by the American physicist Richard P. Feynman. For all the curious individuals, the path integral formulation, in very simple words, evaluates the relations between two points by considering and summing all the different possibilities of trajectories between those points.
The QLattice can be divided into 2 parts: Registers and Interactions.
The registers are what we use to interact with the QLattice. They are the input and output interface of a Feyn model. Often they are the features of your data set.
The interactions are the basic computation units of the QLattice. They hold their own state and transform input data into output. It is how learnings are stored and what is used to extract the QGraphs.
The QGraph, short for Quantum Graph, represents all possible combinations connecting the input registers to the output register. That means all possible explanations for the given output with the given inputs, generated by the QLattice.
If you are interested in learning more about what a QLattice is, and how it works, then you should definately take a look at the in-depth documentation here.
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>", api_token="<Your API token>")
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.get_register(feature))
# Use the target column as an output register
out_reg = qlattice.get_register('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
, fit it to the training data, 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
train, test = train_test_split(df, 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 fit the local QGraph with your local data
qgraph.fit(train, epochs=10)
# Select the graph with lowest loss on the training dataset as the best solution.
# You could consider other attributes as your "best" (accuracy, complexity, etc.).
best_graph = qgraph.select(test)[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 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=test["target"],
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.2-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 61.2 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7da5d71783f493c4603fbe67de445a109a91c3005310370033424e37a536c13a |
|
MD5 | 71da2323e7e6c77986dbadc927b895ab |
|
BLAKE2b-256 | 3defc0475ac2a4dde959601327a5c1a236c7dffdfa9474d39573bf390f668320 |
File details
Details for the file feyn-1.1.2-cp38-cp38-win32.whl
.
File metadata
- Download URL: feyn-1.1.2-cp38-cp38-win32.whl
- Upload date:
- Size: 56.7 kB
- Tags: CPython 3.8, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c229f556ddf0b2b8a328c2f986e00127a8aecdb2034828579cea26d1aeede804 |
|
MD5 | c55986699aa4c5e3ff18568ec40cf2a9 |
|
BLAKE2b-256 | 876f866aefe7e8432cf2f5ac9d1a5390a4b3b03a326950c00dd5eda4bcf47c08 |
File details
Details for the file feyn-1.1.2-cp38-cp38-manylinux2014_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp38-cp38-manylinux2014_x86_64.whl
- Upload date:
- Size: 155.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.46.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66247ae4519b2a638e49a3c38c3653ec739f53ae6503ac69b54f172678afbe48 |
|
MD5 | 44ca99d3f4ebb58c8af48449c21c90d7 |
|
BLAKE2b-256 | 3e833aede6417eea2b92fb008917e8577892eb2c6def319a3258a532a4c034a3 |
File details
Details for the file feyn-1.1.2-cp38-cp38-manylinux1_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp38-cp38-manylinux1_x86_64.whl
- Upload date:
- Size: 155.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.46.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | afb23c07b47f3ab0c18f25c6c1f796bc5e83efec6b1d49cd65b1d96eafc044b2 |
|
MD5 | 994498e4891d11c19075072476867d1d |
|
BLAKE2b-256 | 2eea9f9b4986ee97229bb928379725da6bf34a84221e477df2308f0e0f9a01a9 |
File details
Details for the file feyn-1.1.2-cp38-cp38-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp38-cp38-macosx_10_15_x86_64.whl
- Upload date:
- Size: 58.5 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.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 576918ef8ac03bf7e478bbc025af7abc0d9e80f8d87572ab6bb0d423b03d6938 |
|
MD5 | 69a3d42e021241f4db83fc8a71579f39 |
|
BLAKE2b-256 | 5ec7deeaef4724d6ad9b8635920cd6863ebae1400bb54567812958d7ae5f8081 |
File details
Details for the file feyn-1.1.2-cp38-cp38-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp38-cp38-macosx_10_14_x86_64.whl
- Upload date:
- Size: 58.5 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.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fde5a09f1ae7fc34e547fffa132c564e9c18bad3d0ecfe24ff4fc02acda64c5 |
|
MD5 | 1854d6d42148a24c7f56013f611732e7 |
|
BLAKE2b-256 | c9acb8c15f92928a6f6a834089be1b3e987b5b602878b97ab895be3c6fd525f1 |
File details
Details for the file feyn-1.1.2-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 60.9 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d893215231f5befc2e316ff4569f4497cc3ae1a9d3db0128f532adcad9222390 |
|
MD5 | db456d21fd9a4ee74e11ee78d2fdeb17 |
|
BLAKE2b-256 | 7f7241e5bd53c335c4228f4883dcc0963316ab73a46929a5dafb38583331dd82 |
File details
Details for the file feyn-1.1.2-cp37-cp37m-win32.whl
.
File metadata
- Download URL: feyn-1.1.2-cp37-cp37m-win32.whl
- Upload date:
- Size: 56.6 kB
- Tags: CPython 3.7m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7c25524c09e511b6632c672d1e0675ef6a5b3d40ba35086578b9dcdec90c5fc |
|
MD5 | 8cfa73c9f4d980d2db56597b6bdbab96 |
|
BLAKE2b-256 | c20c771fdf3f44e9527d3a1f606c07bbac816cb6541080d6f149efa751146a45 |
File details
Details for the file feyn-1.1.2-cp37-cp37m-manylinux2014_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp37-cp37m-manylinux2014_x86_64.whl
- Upload date:
- Size: 155.9 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.46.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d28310e7f7f89e6466bedd1ad6ff0a69bd2f002c6b1bf4cc39d4bb1be6ff0961 |
|
MD5 | 633759220c9cf4ca67b1e9e36a44018e |
|
BLAKE2b-256 | 84714287ec2b9a61fd06e3c6efdf5c189a26140a02fd148a730b709b90e9618b |
File details
Details for the file feyn-1.1.2-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 155.9 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.46.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c7f93c31c3aa3a8ed8ff1f5dcd60b24c8380e11b35713f0205146d8f7222dc0 |
|
MD5 | 7ad648a861bfa0cacc6e5e5c237840ae |
|
BLAKE2b-256 | 945cc16382dac362c3ce0ad3d9487b10c2760a252b0a7ee11652524b234fe51c |
File details
Details for the file feyn-1.1.2-cp37-cp37m-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp37-cp37m-macosx_10_15_x86_64.whl
- Upload date:
- Size: 58.4 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.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcc6c2406e77017bc7fba0606182a0c64b56b4fd9ed145672d910f4ed8e06423 |
|
MD5 | 00a88bbaca82f2a4731a111def42cdee |
|
BLAKE2b-256 | bf35f79cb4c7cc9f831588cbf9e538855cdbbeb8ab6c9cbd9747469ce4625d2d |
File details
Details for the file feyn-1.1.2-cp37-cp37m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp37-cp37m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 58.3 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.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | beb2bba0a9e0b5831ed57b18cc6e5bc558272d8a934997eb5a2ac769e4204b10 |
|
MD5 | 8c574fdaf46206b9d2d333c90adb6b0e |
|
BLAKE2b-256 | 1917f729330a5d516fdf3e41254ff86edfc480a9fbd7557ec4bad1c0e7a7679d |
File details
Details for the file feyn-1.1.2-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 65.3 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03cc52a0720fdc65b338f3128c04d53f30dc8597f98ebc9b0607d6aefb5a594c |
|
MD5 | 5bee3d553adbb8b54b8f8faf88f44f75 |
|
BLAKE2b-256 | afbe4fec2b043ec2a3457f499e052db79df6c36602962d952fd5684385e00b32 |
File details
Details for the file feyn-1.1.2-cp36-cp36m-win32.whl
.
File metadata
- Download URL: feyn-1.1.2-cp36-cp36m-win32.whl
- Upload date:
- Size: 61.1 kB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edff132a1f8f5cb0d7c11f8e4e9c66915bf4e82a884005412bbc3212af073153 |
|
MD5 | abef32fae2365a8d93ba899fc0b2d92b |
|
BLAKE2b-256 | 81c0cf4e430457a3daf448e2464e36437179c6241d1d7674e243cc6d3c410c77 |
File details
Details for the file feyn-1.1.2-cp36-cp36m-manylinux2014_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp36-cp36m-manylinux2014_x86_64.whl
- Upload date:
- Size: 150.4 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.46.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5098b010c90d666d526f4862383b27d0a2fb99bd5342c9231a5deb52c5a3072e |
|
MD5 | d23b13a45df5942e99cbc2b4083f5546 |
|
BLAKE2b-256 | faadae0c288ef00cc2b98c76ae3250929ded156999d97afbea8fe1558b98bd2f |
File details
Details for the file feyn-1.1.2-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 150.4 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.46.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfe670b5f4107b22acb65322603f03c5e29f3dcdcbd411ac85d9f506a0189dcc |
|
MD5 | 7c87f3284bc99bae0f9c70af2f6a4278 |
|
BLAKE2b-256 | 03c8859bed082fbdb547454ec2b95d9930b6b868e69f72bd98385520a0776638 |
File details
Details for the file feyn-1.1.2-cp36-cp36m-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp36-cp36m-macosx_10_15_x86_64.whl
- Upload date:
- Size: 58.4 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.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b764837a1f85e95fb0320ad88b444580e09c3b6d5df96fcbe357aa4f16cd91a |
|
MD5 | 04ed00cda659574b6859859407faebff |
|
BLAKE2b-256 | aa900f85ad3a9d96af2959f034dcf0b3132b1b51e1e477bce5cc319f7e17c2bc |
File details
Details for the file feyn-1.1.2-cp36-cp36m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: feyn-1.1.2-cp36-cp36m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 58.3 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.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7a42f3bbe343a84cda79ddb33fe212159cda59d6cb354b9199f4cce6978b933 |
|
MD5 | 6d2ed00e32ed4fdcc557a12746c614d7 |
|
BLAKE2b-256 | d2fd980618935a934831d83c1d0b3c3ac50432ce9c78f3d2fe89b62774184610 |