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.name

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. 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.get_register(feature))

# Turn the target column into 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.0b4-cp38-cp38-manylinux2014_x86_64.whl (138.9 kB view details)

Uploaded CPython 3.8

feyn-1.1.0b4-cp38-cp38-manylinux1_x86_64.whl (138.9 kB view details)

Uploaded CPython 3.8

feyn-1.1.0b4-cp38-cp38-macosx_10_15_x86_64.whl (52.1 kB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

feyn-1.1.0b4-cp38-cp38-macosx_10_14_x86_64.whl (52.0 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

feyn-1.1.0b4-cp37-cp37m-manylinux2014_x86_64.whl (140.1 kB view details)

Uploaded CPython 3.7m

feyn-1.1.0b4-cp37-cp37m-manylinux1_x86_64.whl (140.1 kB view details)

Uploaded CPython 3.7m

feyn-1.1.0b4-cp37-cp37m-macosx_10_15_x86_64.whl (51.9 kB view details)

Uploaded CPython 3.7m macOS 10.15+ x86-64

feyn-1.1.0b4-cp37-cp37m-macosx_10_14_x86_64.whl (51.9 kB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

feyn-1.1.0b4-cp36-cp36m-manylinux2014_x86_64.whl (135.3 kB view details)

Uploaded CPython 3.6m

feyn-1.1.0b4-cp36-cp36m-manylinux1_x86_64.whl (135.3 kB view details)

Uploaded CPython 3.6m

feyn-1.1.0b4-cp36-cp36m-macosx_10_15_x86_64.whl (51.9 kB view details)

Uploaded CPython 3.6m macOS 10.15+ x86-64

feyn-1.1.0b4-cp36-cp36m-macosx_10_14_x86_64.whl (51.9 kB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

File details

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

File metadata

  • Download URL: feyn-1.1.0b4-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 138.9 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.0b4-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 12c1f6193deb4128fb2f04bfc79e117044b7414c4f49ccb446da5652c28c36db
MD5 085908068e886a82a3bd06a7c1771988
BLAKE2b-256 3dfd175c451edfe9559855a2d8b0914519a9a52270f36352b0223e1b9ba4a623

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0b4-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 138.9 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.0b4-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 29a20cb279d28a766cd95f85cfe66f76a4f16dbeb40ba50370c48dd8bd57b1c7
MD5 07d599ca42c8a40354a16c88cb938dfd
BLAKE2b-256 3d5ae8f8cd23d18c12a64588785382c8915fc46c1b09962c40109101c094618f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0b4-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 52.1 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.0b4-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 caf20b46bbf5aef205c2741943d15cf05866f211fbaa28e0f8997f2de7b954d5
MD5 4aa000b2389d178d47a5566b8a99a0ef
BLAKE2b-256 ad851451e30c585dbed7c6136982c067a3ee16c2ce4d3cd43a20a61cad30408a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0b4-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 52.0 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.0b4-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 2e55f73b1faae7a0e3e4a3b81733b360f69b0e67f8d3396c3332794fac507a11
MD5 26008334c1164cb88f06eef565f44fed
BLAKE2b-256 5cebe0ad035699176d062f13322ab951b823fcc8d562873ee572231aa264306f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0b4-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 140.1 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.0b4-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 30413d01b4017392409efeb80cf31ef31b854fead1ffaa229cd822d7ea113fab
MD5 c0ce2f029cd05de9e7d0c7a4fdd75d73
BLAKE2b-256 f2903691aa70993897ee31fdfa92c96717dd303cfdb04c978ba98f874da35d8f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0b4-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 140.1 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.0b4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3b99ae831eddc19876d2a55cc0b3203b5fbceec0ea21c320809e6e533fbe3728
MD5 5d46240b12c8cbbd8f1a7c4e82df6ed2
BLAKE2b-256 a04002c0606b474bd468fa0da18f47134702564bc7a98d05bec985f4be6f2062

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0b4-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 51.9 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.0b4-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 3002e68e8d4b898c4d0c784314ed8149c1aebae21c1ee7aaeed7365a50132d2e
MD5 66051627b9f7e8aa7d7039e71cac8ac9
BLAKE2b-256 a73355de7a1ea4b3b6a4d3760a11785097cad271effe4a062044520079a8e943

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0b4-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 51.9 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.0b4-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 45ed8d064f5edb4507d6f42f1a5aeaad205391346e4f09e29b9bce61ec77d8be
MD5 8c708e7a9d9c9bd6707ba1e32f4ac9ce
BLAKE2b-256 7610896802fa6a17adc3dc066c12b7f2f053c90c15353b321217fcf54f59786e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0b4-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 135.3 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.0b4-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5d741e5ec5fdb4dc631a2b22d290c054e387de6baf27fc972f6fe70ad3f7b897
MD5 95434340f79804199b14b743dd73c10b
BLAKE2b-256 616c90bb35d6219f99103aefcf7a5bca6927eff6070797d856cea0c008a4fdfb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0b4-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 135.3 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.0b4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8485b4aa9cc993d043dca3592363e6a9ef6d39537edf544659300903cc6dc7ff
MD5 dd68407babe9ac71fe9eb81cbf7a2c40
BLAKE2b-256 a76fef8be2a0dc7695fd5ea732eef67559421ddeb0107d2d4f0d6e9af593bf3f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0b4-cp36-cp36m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 51.9 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.0b4-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 35ff9453d932a99b1c529d614634922e352f9a805e8b0bd161494841636270aa
MD5 3b333159096731fd01f4094d4114fce6
BLAKE2b-256 86572622cb4d759bfe09f9244dc5b06d7b7c89303787fbfa77495ae40229e2e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0b4-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 51.9 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.0b4-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 11c131a3e689f42d61da7de983f70145dc684aa7022864715ceb48054ba9a018
MD5 d5583e554b069abb0c1920b4a5c7ee6b
BLAKE2b-256 ac33434127a8c30981a31636f78b7ba8c997f730b09f9c9b3ad7854ea3dfbdde

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