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

If you're not sure about the file name format, learn more about wheel file names.

feyn-1.1.0-cp38-cp38-manylinux2014_x86_64.whl (139.1 kB view details)

Uploaded CPython 3.8

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

Uploaded CPython 3.8

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

Uploaded CPython 3.8macOS 10.15+ x86-64

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

Uploaded CPython 3.8macOS 10.14+ x86-64

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.7mmacOS 10.15+ x86-64

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

Uploaded CPython 3.7mmacOS 10.14+ x86-64

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

Uploaded CPython 3.6m

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

Uploaded CPython 3.6m

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

Uploaded CPython 3.6mmacOS 10.15+ x86-64

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

Uploaded CPython 3.6mmacOS 10.14+ x86-64

File details

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

File metadata

  • Download URL: feyn-1.1.0-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 139.1 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.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f30b8041242051ac43fb6332560a7953efc9dade9c1f2e63a899e9f103476907
MD5 759d857bc26dce85c988fcd2f1e894f4
BLAKE2b-256 63e480778c4f43a26c917a1b5e9c29b4255c2b0f70b289452efa4665ce73093e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 139.1 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.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 26afee19481466b3df311f70b2d2bc030976601a318744e2f89753efb4d81cbd
MD5 46da1051ed068cf2c22c9606fdcb4c5a
BLAKE2b-256 3df926ae98b6c7b48c632b03ea7d3a472cd8e89aeb5e9b0927ef24f103199725

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0-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.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 192373322d18f67a77d869b9b2d3e014742966235b2a9490b3733b952306aa58
MD5 fe8919037fd026aa38e6df5780571186
BLAKE2b-256 83a8e28889956011bb7cb3725114631536bd677ecd0e7ad4b9fd7945ae332722

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0-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.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 eab315c27d7e8fc29298af106d0ee27935f6c973ce801dc7ffeee1fccbbe372e
MD5 4782670ffb1666562342ec9aff5e23ca
BLAKE2b-256 f3349e8a93125813293d5da1e30ca5a8354a4f78a9cd03101319e03d46c5ffa4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0-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.0-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 650efa36c60355a3fb67cde0b827cf9df1d5b7550674f0f71256b033bbf1075e
MD5 e2ef6dec4019a25f066b09941fd96dcb
BLAKE2b-256 3a6d5944e6342c2615dc8f87bd0d0bbbd5e0d9408900f0bb386686f72f50ef54

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 140.3 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.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 40ecb3b572db231b1cc8532727a6cf77eafa1eb647a4af31512b19e89e8498db
MD5 1a5b7e7dc1b96c2f1241aaaa7a100141
BLAKE2b-256 8de9d9cc1dc172ff4345f29ff0d9b91119a6252c6867de701a3306e0bca72e6c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0-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.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 090afb2b4fdf0c77e76062242d0cb2d1378a7a18964c8fe58f9af47760641b94
MD5 e886a8dab7f3a3f87a3ee2a1f28954cf
BLAKE2b-256 fbb69664be05645f06062081754b64e274876d2cb752b3e8b7e60d72d612c9fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0-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.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 cae5eb88c46a98e8c45b1f949fbdf8d47acf36825267b9f98edae8194abc0862
MD5 545df9da0098b0a89880c95ab203fb07
BLAKE2b-256 5dbb77c4c538f1482c2430daa4dc51924cb65dee936ab7d0210a0e4cdab92f1e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0-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.0-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f248d6fd0445d19ae7a2a7b1c51fb42237c1007a99159257543fba053b0ee64d
MD5 ca897feb53897f310b910d45945847d1
BLAKE2b-256 9d0c8d9acdf3ebd640090f6203434aa24abc35137cc4c06288bab14338b93790

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0-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.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 86cd900e63aa68401b349c095227ad0b7a3475bcb91ed36417d9e036cc49cc08
MD5 49ed4b3fbc30afdc1ef4ebe8e891daab
BLAKE2b-256 9dc2c368e822daf4e1bced2a7ded7afafae0de655b0acca287043a7c934f622e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0-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.0-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 1a52331cb81164147982e9be82d2b4e3640f6313f3cb11f4e3d687653503b8bf
MD5 bc662fa33cbf51fd66d7d7de36047e6a
BLAKE2b-256 d4c49c24da298a3264496d48e6abd26d4784bcbde96a8f3f7e252320d9ace469

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.1.0-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.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 99f04965053cdd2c0354b88b3da7f897018a8895fd2f56b82fed64dd174a6f2b
MD5 99cd49b5c14aa4812cc66cd4a6b389b4
BLAKE2b-256 8e88d383233b7e6d057be93089f7c4a1c5beb90e639ce2834b3d67a52fd59e67

See more details on using hashes here.

Supported by

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