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.0b5-cp38-cp38-manylinux2014_x86_64.whl (139.2 kB view details)

Uploaded CPython 3.8

feyn-1.1.0b5-cp38-cp38-manylinux1_x86_64.whl (139.2 kB view details)

Uploaded CPython 3.8

feyn-1.1.0b5-cp38-cp38-macosx_10_15_x86_64.whl (52.4 kB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

feyn-1.1.0b5-cp38-cp38-macosx_10_14_x86_64.whl (52.3 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

feyn-1.1.0b5-cp37-cp37m-manylinux2014_x86_64.whl (140.4 kB view details)

Uploaded CPython 3.7m

feyn-1.1.0b5-cp37-cp37m-manylinux1_x86_64.whl (140.4 kB view details)

Uploaded CPython 3.7m

feyn-1.1.0b5-cp37-cp37m-macosx_10_15_x86_64.whl (52.2 kB view details)

Uploaded CPython 3.7m macOS 10.15+ x86-64

feyn-1.1.0b5-cp37-cp37m-macosx_10_14_x86_64.whl (52.2 kB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

feyn-1.1.0b5-cp36-cp36m-manylinux2014_x86_64.whl (135.6 kB view details)

Uploaded CPython 3.6m

feyn-1.1.0b5-cp36-cp36m-manylinux1_x86_64.whl (135.6 kB view details)

Uploaded CPython 3.6m

feyn-1.1.0b5-cp36-cp36m-macosx_10_15_x86_64.whl (52.2 kB view details)

Uploaded CPython 3.6m macOS 10.15+ x86-64

feyn-1.1.0b5-cp36-cp36m-macosx_10_14_x86_64.whl (52.2 kB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

File details

Details for the file feyn-1.1.0b5-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.0b5-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 139.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.0b5-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 99db1bdaa60fea4574d5ae3f886839fddef7f4839ea5f46aa4e0c3812509ae57
MD5 17e1a1aca0fcd0f741131f08ed5fe325
BLAKE2b-256 4cdb4c9fd9aeb97831898236c6eb7aeada3ff9a2adce468092afe32f38b9405c

See more details on using hashes here.

File details

Details for the file feyn-1.1.0b5-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.0b5-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 139.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.0b5-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ae9d0852235cf32ff49b36e339474572d95924d2bac48a6437ce613d91757270
MD5 6818ae0cbeebbad1f7054a879226b088
BLAKE2b-256 dac01db5343f069de0a03573108a8610d9e5054a73d93d22cb1b3427eadf00bb

See more details on using hashes here.

File details

Details for the file feyn-1.1.0b5-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.0b5-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 52.4 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.0b5-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 671c850e670ae66d917ba47dc99499dec381aa63bae8e290c9f41443fe269050
MD5 1b0438f608cdfe521182b9627c89eb78
BLAKE2b-256 8e0fde89a97b4ae918f533930d8cdb1202d6b64ec855cc634d0988c43e4cc060

See more details on using hashes here.

File details

Details for the file feyn-1.1.0b5-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.0b5-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 52.3 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.0b5-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 988b18c396dec78f26f51edf373c85d7a8eedf8dcc3b12818783a25d7b75fd3c
MD5 ba1619f309a47cc662250d372f41cb9a
BLAKE2b-256 b90a34a824e83dedeb2c38453a787264b8c33144a8ba95c63c71c487df727cf0

See more details on using hashes here.

File details

Details for the file feyn-1.1.0b5-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.0b5-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 140.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

Hashes for feyn-1.1.0b5-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 05b2dbdad217e016f55bcf023f1607d54a3238321110c5814a55870c669e80ac
MD5 1d14764090d6c599f00358bd92ddc59f
BLAKE2b-256 95f1e1234963f15ffd93b5bcf9f4be554764dcf526baba1d3d268f47c0dc93d3

See more details on using hashes here.

File details

Details for the file feyn-1.1.0b5-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.0b5-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 140.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

Hashes for feyn-1.1.0b5-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e8afb917229bcd6e54ff7b1d4eac3d2e31355d6c81cdd7ab11d8978f94971a6b
MD5 cdd853adc6f912fd3ccc31ed2cfbdb00
BLAKE2b-256 8200da2dc057b4ed3abb3a3a80ff0edf09937371e157e96338d9eec1cdcc8712

See more details on using hashes here.

File details

Details for the file feyn-1.1.0b5-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.0b5-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 52.2 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.0b5-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 14250206eb6538f085f40c70ac453f9136aa399a0bcd888d1be6d1276a5632a8
MD5 efb46badda54ffb66d0cdbd32426368d
BLAKE2b-256 3e2773f053a1ca515de2dce5b08494c46b8d4843a81c140828f32934a3377572

See more details on using hashes here.

File details

Details for the file feyn-1.1.0b5-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

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

Hashes for feyn-1.1.0b5-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 396b61647714e685883bc75cf5d3700bb1c317a1f219a1189aaee23cb518df14
MD5 99256ec2e1d19c3c8d975816eaa06bf0
BLAKE2b-256 0baf197595911b33e9cc237cd4abb86e6de92c2f7f92329822fd36f6062d51e9

See more details on using hashes here.

File details

Details for the file feyn-1.1.0b5-cp36-cp36m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.0b5-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 135.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.0b5-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ada8ba079f49687c60815850744c1abab344cd4cc3275ec51f59ffe74ba36cbf
MD5 cc9d3fbba1a9df107fadc76d45b01deb
BLAKE2b-256 50f6ebe78b0689b5fa854cf7f0babda6a61a5063a034846e3c4c3bb0160a543c

See more details on using hashes here.

File details

Details for the file feyn-1.1.0b5-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.0b5-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 135.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.0b5-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ac354a8ef8fa9f542a66868b93f47a88a41662bc1845c283554bfe0c0567ebc5
MD5 8d6a1422deb08791d594eb49ed78b876
BLAKE2b-256 e1a87a1ce9fded4ba73ff188fc27b729b4159d509ecea473523a7e04b950c5b5

See more details on using hashes here.

File details

Details for the file feyn-1.1.0b5-cp36-cp36m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: feyn-1.1.0b5-cp36-cp36m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 52.2 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.0b5-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 5115b522db5d6b1be66050298a8011e4f5e4a4d6e48f611a54f9d4693e027bff
MD5 e7de253855d51693f05ffad51467271c
BLAKE2b-256 a38f5997283b6b238cc055f2052ae23fea4772be9056036ab10de01572f0c3ce

See more details on using hashes here.

File details

Details for the file feyn-1.1.0b5-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

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

Hashes for feyn-1.1.0b5-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 965da92bcbff4f87a4bbef2f6fca639e0410cc59f2636c0cc7f9771b2aea91db
MD5 5ed0b1881001062873185939ba3d4eb5
BLAKE2b-256 5ca763e1b0f2e0cdb5d93e35f03f7e578777e611a0ab977642c142425af02e8f

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