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.3.dev432-cp38-cp38-macosx_10_15_x86_64.whl (40.4 kB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

feyn-1.0.3.dev432-cp37-cp37m-macosx_10_15_x86_64.whl (40.3 kB view details)

Uploaded CPython 3.7m macOS 10.15+ x86-64

feyn-1.0.3.dev432-cp36-cp36m-macosx_10_15_x86_64.whl (40.3 kB view details)

Uploaded CPython 3.6m macOS 10.15+ x86-64

File details

Details for the file feyn-1.0.3.dev432-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: feyn-1.0.3.dev432-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 40.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.21.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for feyn-1.0.3.dev432-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 7fe44412d216b4457a1ba7537860e31ac849046bf05c1a953b5140470d9167e5
MD5 025625463655f60925b3e022975dc8d6
BLAKE2b-256 b3db04bb7da9dd5bfb934da03f1318d17cedca994c99c18bffacd93c05a4e815

See more details on using hashes here.

File details

Details for the file feyn-1.0.3.dev432-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: feyn-1.0.3.dev432-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 40.3 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.21.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for feyn-1.0.3.dev432-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 73053528a75d4f1cebfda1cb74e3250d3c085936bf8c8408c2e443a0e3fb675e
MD5 538085d3105b25facbbbd3c107ba6299
BLAKE2b-256 d0cce99358f54f073d8dc5ffbae9c8c64c285437dc21ca4b7c9245f0a1b26d50

See more details on using hashes here.

File details

Details for the file feyn-1.0.3.dev432-cp36-cp36m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: feyn-1.0.3.dev432-cp36-cp36m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 40.3 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.21.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for feyn-1.0.3.dev432-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 f76a95ed7e563054b4bb9f0bbbeeb804ed521da041060c33d85e84227d6621b7
MD5 d9281bd901c88b266a1eefe914459087
BLAKE2b-256 0721e2fc7fb45a5ba097d65dae51d933e01c031eac31fd5e9529b99c603dd8f4

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