Feyn

Feyn

  • Tutorials
  • Guides
  • API Reference
  • FAQ

›Essentials

Getting Started

  • Quick Start

Using Feyn

  • Introduction to the basic workflow
  • Asking the right questions
  • Formulate hypotheses
  • Analysing and selecting hypotheses
  • What comes next?

Essentials

  • Defining input features
  • Classifiers and Regressors
  • Filtering a QGraph
  • Predicting with a graph
  • Inspection plots
  • Saving and loading graphs
  • Updating your QLattice

Setting up the QLattice

  • Installation
  • Accessing your QLattice
  • Firewalls and proxies
  • QLattice dashboard

Advanced

  • Converting a graph to SymPy
  • Setting themes
  • Saving a graph as an image
  • Tuning the fitting process
  • Causal estimation

Future

  • Future package
  • Diagnostics
  • Inspection
  • Reference

Updating your QLattice

by: Kevin Broløs
(Feyn version 1.4 or newer)

How to use the QLattice

This page is about some of the basic functions that live on the QLattice instance itself.

A few prerequisites and assumptions:

For a quick introduction, check out our Quick Start. Also consider visiting our Feyn Workflow for a good introduction on how to use Feyn best.

We also assume you already know how to access your QLattice, and this code assumes you use a configuration file.

Update your QLattice

Initially, your QLattice will be a blank slate, and you'll be using your results to point it in the direction that's useful to your problem as you go along.

Once you've selected a good graph you can update your QLattice with the learnings.

For the sake of example, let's generate a classification dataset using sklearn:

from sklearn.datasets import make_classification
import pandas as pd

from feyn.tools import split
# Generate a dataset and put it into a dataframe
X, y = make_classification()
data = pd.DataFrame(X, columns=[str(i) for i in range(X.shape[1])])
data['target'] = y

# Split into a train and test set
train, test = split(data, ratio=(0.75, 0.25))

Let's get a classifier for this and do a single fit:

from feyn import QLattice
qlattice = QLattice()

# This will extract a QGraph containing classifiers
qgraph = qlattice.get_classifier(data.columns, 'target')

Now that we have a qgraph, we can choose to update the QLattice. You can update the QLattice with either a single graph, or a list of graphs, like so:

best_graph = qgraph[0]
qlattice.update(best_graph)

best_graphs = list(qgraph[0:10])
qlattice.update(best_graphs)

You can also use QGraph.best(), which returns all the top graphs in your QGraph that are guaranteed to have evolved separately.

best_graphs = qgraph.best()
qlattice.update(best_graphs)

This is essential to how you can tap into the full potential of your QLattice. Updating the QLattice means restructuring the knowledge in a way that takes into account the structure of the graph you have just fitted with your dataset. This narrows the search field for new graphs and allows you to get new and different graphs to fit, and converge faster on solutions that work for your specific problem.

In layman's terms, you tell the QLattice what works and what you'd like to see more of, and it'll use this knowledge to make you happier, faster.

The blank slate

What happens if you've been experimenting with some different datasets, or approaches, and you want to go back to this initial state?

You can reset it using the following:

from feyn import QLattice
qlattice = QLattice()

qlattice.reset()

This will reset all knowledge in the QLattice, so take care not to use it for production systems. Except for restoring a previous version, this action cannot be undone.

Saving and restoring the QLattice state

You can take a snapshot of your QLattice at any time, as well as restore it, both programmatically, and through the dashboard.

from feyn import QLattice

qlattice = QLattice()

# Returns a snapshot object containing your note, time of snapshotting and id
snapshot = qlattice.snapshots.capture("A little note")

# List all snapshots:
for s in qlattice.snapshots:
    print(s.id, s.when, s.note)

# Restore using the id of the snapshot. The instance of the snapshot from previously also works.
qlattice.snapshots.restore(snapshot.id)
← Saving and loading graphsInstallation →
  • How to use the QLattice
    • Update your QLattice
    • The blank slate
    • Saving and restoring the QLattice state
Copyright © 2021 Abzu.ai