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

feyn-1.0.2-cp38-cp38-manylinux2014_x86_64.whl (95.3 kB view details)

Uploaded CPython 3.8

feyn-1.0.2-cp38-cp38-manylinux1_x86_64.whl (95.3 kB view details)

Uploaded CPython 3.8

feyn-1.0.2-cp37-cp37m-manylinux2014_x86_64.whl (94.5 kB view details)

Uploaded CPython 3.7m

feyn-1.0.2-cp37-cp37m-manylinux1_x86_64.whl (94.5 kB view details)

Uploaded CPython 3.7m

feyn-1.0.2-cp36-cp36m-manylinux2014_x86_64.whl (91.7 kB view details)

Uploaded CPython 3.6m

feyn-1.0.2-cp36-cp36m-manylinux1_x86_64.whl (91.7 kB view details)

Uploaded CPython 3.6m

File details

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

File metadata

  • Download URL: feyn-1.0.2-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 95.3 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.43.0 CPython/3.7.6

File hashes

Hashes for feyn-1.0.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c5e04599bd2d6bf15b76524d2f34cecb12c4cdc1fa46f692d657f3aef81fead
MD5 437e132793e1eff165f191a6d6a3bf95
BLAKE2b-256 6c6a5e77faf5f020a14edbd3e9a9533bdf73a532e2173f21610aeed13ea63430

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.0.2-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 95.3 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.43.0 CPython/3.7.6

File hashes

Hashes for feyn-1.0.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 345939bcd55ce345601897a59e5fde8dc26b69b2c4150805f2bef73261d76e25
MD5 282a1567ba0d443dbe2cd8705622a23f
BLAKE2b-256 ca7506fbd29d982ac3ffbc7bda26dd4948a5f61ab6687fb7f29fa87beb92d8f5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for feyn-1.0.2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0868a326c34bd584a888894fabdd47eedda4cacd35caeb762be1bea9d5ab3b86
MD5 292cac7a5c4896bb35b05093a3c9af28
BLAKE2b-256 1278ef062380a1ae42e896383d2cc63db465649a6cdc8d6e6ecc236d0731181e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for feyn-1.0.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bcfbf3f7a900a58b354fb8ebf50c42b718b420f5432961bd30f71e0879b8dc55
MD5 5066877011589768b903c02561426af0
BLAKE2b-256 c6817d67a53b0f5e70425100cd8096a766a42afac3c8ea581c69e21291c5aae5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.0.2-cp36-cp36m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 91.7 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.43.0 CPython/3.7.6

File hashes

Hashes for feyn-1.0.2-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6db7c56a55fb9f6fed66b10cbaf7093b473866cb8799bea861941051877e39b9
MD5 5eb9b8956cfdc4530d96aa85efedf5d4
BLAKE2b-256 1306c8fc9115c58551561d9cdd0674f863e66ff076104aac396b79b0a7782ee5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: feyn-1.0.2-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 91.7 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.43.0 CPython/3.7.6

File hashes

Hashes for feyn-1.0.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6ed9931760ab5c2ad7de80f367cdd7b2216ac00b1dc2a8eef9400c98bfee577d
MD5 9c1ab74a0744ca43040f1118d5f4298f
BLAKE2b-256 0fb178b413791f12f3efda994ab1c44c201feac3f13cfbcedf5c78de437c6406

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