Skip to main content

High level Python interface to 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-model is 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.

Create a blank QLattice.

from feyn import QLattice
ql = QLattice()
ql

Read the example dataset and add a register for each column in the dataset.

import sklearn.datasets
import pandas as pd

X, y = sklearn.datasets.load_breast_cancer(return_X_y=True)

in_registers = []
_data = {}

for i in range(X.shape[1]):
    label = 'inp_%i' % i
    _data[label] = X[:, i]
    in_registers.append(ql.add_register(label=label, register_type="cont"))

X = pd.DataFrame(_data)
out_reg = ql.add_register(label='out')

Now the QLattice is prepared for your problem.

Next, run for some epochs, where you retrieve a new QGraph, tune it, 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 QGraph will fit your problem better.

from sklearn.model_selection import train_test_split

X_test, X_train, y_test, y_train = train_test_split(X, y, test_size=0.33)

for _ in range(10):
    qgraph = ql.get_qgraph(in_registers, out_reg)
    qgraph.tune(X_train, y_train, epochs=10)
    best_graph = qgraph.graphs[0]
    ql.update(best_graph)

Finally, evaluate the results in the test dataset.

from feyn import tools

prediction = best_graph.predict(X_test)
tools.plot_confusion_matrix(y_true=y_test,
                                y_pred=prediction.round(),
                                title="Evaluation Results")

For a detailed tutorial about Feyn continue with:

  • Getting Started with Feyn
  • Building complex trainers

Installation

Feyn is available as python package distributed from PyPi server.

Requirements:

  • OS: Linux
  • Python 3.6, 3.7 or 3.8
  • Graphviz is used to draw charts (optional):
foo@bar:~$ sudo apt install graphviz

You can install it with the following command

foo@bar:~$ pip3 install feyn

Alternatively or if you don't have Linux OS you can use the jupyterlab Docker image.

foo@bar:~$ docker run -it --net=host abzu/jupyterlab:latest

adding the current folder as /data to the working directory.

foo@bar:~$ docker run -it --net=host -v $(pwd):/data abzu/jupyterlab:latest

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.0.1-cp38-cp38-manylinux2014_x86_64.whl (96.6 kB view details)

Uploaded CPython 3.8

feyn-1.0.1-cp38-cp38-manylinux1_x86_64.whl (96.6 kB view details)

Uploaded CPython 3.8

feyn-1.0.1-cp37-cp37m-manylinux2014_x86_64.whl (95.7 kB view details)

Uploaded CPython 3.7m

feyn-1.0.1-cp37-cp37m-manylinux1_x86_64.whl (95.7 kB view details)

Uploaded CPython 3.7m

feyn-1.0.1-cp36-cp36m-manylinux2014_x86_64.whl (93.1 kB view details)

Uploaded CPython 3.6m

feyn-1.0.1-cp36-cp36m-manylinux1_x86_64.whl (93.1 kB view details)

Uploaded CPython 3.6m

File details

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

File metadata

  • Download URL: feyn-1.0.1-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 96.6 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/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for feyn-1.0.1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e3292cd27d645f925f25b29eefe4ec4a53fa4420e16da3321c00d2dba2d25534
MD5 e0125a0c2d65175a4dfeb1d13dca1f29
BLAKE2b-256 750ce04a0d362c63cc98c8397c7e71d53477384ba057c2fdb0a41e6755b6bbda

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.0.1-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 96.6 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/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for feyn-1.0.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f081fbba9e7ea928f0ee9920a69ec0082f3327459937ff0248281ad6be967c4c
MD5 708ac7aac68036b80a3b0e79fc240713
BLAKE2b-256 6c13f2ef990a615822feafa92f0d45fff18f842189934068eb86d7363c8de3da

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.0.1-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 95.7 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/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for feyn-1.0.1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9bb10bc5dc115d29ad5f3f635fa64228019db7f17e731614fb67e4b439a8aa6
MD5 7ccc843237a2f6bc040b41b330d265b0
BLAKE2b-256 b8d92846236a8f806421a224035843e2e5ed7cef5aab28cfc67bc82c5f2c9a0f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.0.1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 95.7 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/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for feyn-1.0.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bc6fab62b97f7a1caada05667ca44a6d24b33b7e6cc0a5d426ee3628b808b983
MD5 a0cff31cde6fd840b7131c10d27a9723
BLAKE2b-256 fb5794d6a0f4aca2f9131cee979931d05f567566ba09726515d8139943cda4e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.0.1-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 93.1 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/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for feyn-1.0.1-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 839354b6cc449d034d1ab6e30641132fd8a5df778c15c72f69a3879cb8892569
MD5 8e463c9c4f21120355d976477cd912e7
BLAKE2b-256 b780a7b097136a93f95c08431ccbb8fbbc6ec276d4e4ea96ca1ac73d13bbf53e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.0.1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 93.1 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/42.0.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for feyn-1.0.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b570259d54360c03ebf27f5a685b8af5709c470db37117b4a63791ab110cb4db
MD5 6d257f764d5113f450694e2bc53096e0
BLAKE2b-256 20d316bd851ce942f1fa7d151a86dc650b1561f64e334f7a0352622e06b5c107

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