Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

feyn-1.1.1-cp38-cp38-manylinux2014_x86_64.whl (150.2 kB view details)

Uploaded CPython 3.8

feyn-1.1.1-cp38-cp38-manylinux1_x86_64.whl (150.2 kB view details)

Uploaded CPython 3.8

feyn-1.1.1-cp38-cp38-macosx_10_15_x86_64.whl (55.7 kB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

feyn-1.1.1-cp38-cp38-macosx_10_14_x86_64.whl (55.6 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

feyn-1.1.1-cp37-cp37m-manylinux2014_x86_64.whl (150.9 kB view details)

Uploaded CPython 3.7m

feyn-1.1.1-cp37-cp37m-manylinux1_x86_64.whl (150.9 kB view details)

Uploaded CPython 3.7m

feyn-1.1.1-cp37-cp37m-macosx_10_15_x86_64.whl (55.5 kB view details)

Uploaded CPython 3.7m macOS 10.15+ x86-64

feyn-1.1.1-cp37-cp37m-macosx_10_14_x86_64.whl (55.5 kB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

feyn-1.1.1-cp36-cp36m-manylinux2014_x86_64.whl (145.6 kB view details)

Uploaded CPython 3.6m

feyn-1.1.1-cp36-cp36m-manylinux1_x86_64.whl (145.6 kB view details)

Uploaded CPython 3.6m

feyn-1.1.1-cp36-cp36m-macosx_10_15_x86_64.whl (55.5 kB view details)

Uploaded CPython 3.6m macOS 10.15+ x86-64

feyn-1.1.1-cp36-cp36m-macosx_10_14_x86_64.whl (55.5 kB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

File details

Details for the file feyn-1.1.1-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.1-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 150.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

Hashes for feyn-1.1.1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b07c8af10c190ebc5c706443f9b5224c85f852d27bd2b520d866d86f7c426947
MD5 15d1908337e4b1b915a8e67ef5d3b468
BLAKE2b-256 7be0f69396e2f25f3968cd1f1c4e9ecb5507757457fe27b56dbcebd35eba78c5

See more details on using hashes here.

File details

Details for the file feyn-1.1.1-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.1-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 150.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

Hashes for feyn-1.1.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ab8ec526ca504f5f5f92fd15fbb7028f7b4aea30bd681c2c269fc61fcfa68bcc
MD5 229d1803d948e491e9b85933e834f683
BLAKE2b-256 e3da5c98c12389709b97b2c3ef0b7d274c92b2cf64fd10f16130b82dc4c11b79

See more details on using hashes here.

File details

Details for the file feyn-1.1.1-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.1-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 55.7 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

Hashes for feyn-1.1.1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 8cf612ce9a832b86c258edb6d7ce8e42f0942ca332f6630de2a86abd6ab334b5
MD5 6cef214adbad69da75531fc573b4bd7f
BLAKE2b-256 dbda88abf4c8a45b9158f4b31bbcd3ecea70fb6e6e36b79ac4431fe3e94c8330

See more details on using hashes here.

File details

Details for the file feyn-1.1.1-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.1-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 55.6 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

Hashes for feyn-1.1.1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 cc1226fa61b2f196a0cfe4d3776dc5524ba7b4251412bdc06f01a6bf7165bed0
MD5 8eb0ba0d62416221203b3b6be7d6973a
BLAKE2b-256 2b0dae7dab510b8d5f808504c1523d9abb615668d2f33cfad1ab8fa40fa23e9b

See more details on using hashes here.

File details

Details for the file feyn-1.1.1-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.1-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 150.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.45.0 CPython/3.7.6

File hashes

Hashes for feyn-1.1.1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b48cfa5e0fcc708aab10641562afb9ad7039db5ec7b9550a58e3ed61d28a3f19
MD5 b376efd37952a39866e402473295e59c
BLAKE2b-256 73dc749bcdba0cc60d3198798e967f78063f1112459fe4a793d14caa26f3d1d5

See more details on using hashes here.

File details

Details for the file feyn-1.1.1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 150.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.45.0 CPython/3.7.6

File hashes

Hashes for feyn-1.1.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 19eb6af90e1063ea61624e3fa9189421290201f194bac4894fe7c877cb4bade6
MD5 0a3190ce4984764d2b7b04db8fffcb6b
BLAKE2b-256 92a0207b0bb1980535310b4cd438320cfbfdd46f95981aa7e287bfb925a20485

See more details on using hashes here.

File details

Details for the file feyn-1.1.1-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.1-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 55.5 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

Hashes for feyn-1.1.1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 fd56848c3cc740111a701e8749c626e3a473121b469a98846c5a10172e4ed8aa
MD5 3ac1321c38881c9f67f44cc9367ff227
BLAKE2b-256 2b5e98915f56624f4b651425c76c9da0ac2a108b733c936f2799e48c52cdf26f

See more details on using hashes here.

File details

Details for the file feyn-1.1.1-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.1-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 55.5 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

Hashes for feyn-1.1.1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 1bd5a75fca627b2d2dc09d4c1eec9eea67a2fa0d14f27d33504a726e141ac0fa
MD5 7d607b7e012b3175a15a29c4a25663f2
BLAKE2b-256 bde65f8cd69a4cb1efa25327ac07c5e61d8270259a41088ef214d45a9bce48f5

See more details on using hashes here.

File details

Details for the file feyn-1.1.1-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.1-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 145.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

Hashes for feyn-1.1.1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8f4da130c3eefc5d942dc0172009651163a70d7f8d8f9d34ec69ca255c476bc7
MD5 84c3c7aef950f06555648fc35b8c63a3
BLAKE2b-256 2470b55bef317b0e3f5b191546cf34f6522f45809da175d979c5e7340a32d0ba

See more details on using hashes here.

File details

Details for the file feyn-1.1.1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 145.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

Hashes for feyn-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e9f3d0d51067bed27a09106f6c1bddc8272d00f60b146202a7a3638536220a40
MD5 46fd5659546124263c118160258137a4
BLAKE2b-256 0b14d4bb7e583b12e991d9661585a255b7888ea3b703e88534b67bb77e92399f

See more details on using hashes here.

File details

Details for the file feyn-1.1.1-cp36-cp36m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.1-cp36-cp36m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 55.5 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

Hashes for feyn-1.1.1-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e283bc49dc9abd932247297dd8388cabc7b777297d2ab58d57358b77571829ca
MD5 1c01997aa630a70957aa5cd3c2f238c1
BLAKE2b-256 b64c5bda96e51f860d23cb6c8a66d2f8207f44693b0a66b03b3716d4288bf37d

See more details on using hashes here.

File details

Details for the file feyn-1.1.1-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.1-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 55.5 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

Hashes for feyn-1.1.1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 094db1464efdbd2ca7a3d210401429255b38c6202869e01434d5906dfde21308
MD5 f29bb42a9ab25c02c11af22b4246cfcd
BLAKE2b-256 5f04452ae40737f9d50479eabe8225317e64548cccb1684306b9a435b86a58f7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page