# What is a QLattice?

## Just a tiny bit of quantum mechanics

We typically think that when an object moves from one place to another it will move in the path of least resistance. Usually, that will be a straight line.

This intuition breaks down when we move to the world of the very small, such as the movement of photons and electrons. According to Richard Feynman, photons do not just take one path from point A to point B: they take every path. Each path contributes to the probability of the photon arriving at point B and the path with highest contribution is the one of least resistance---usually a straight line.

## So...what is a QLattice?

It is the environment that considers all possible models of a dataset and finds that 'path of least resistance' i.e. the model that fits the problem the best.

So a `QLattice`

is very much inspired by Richard Feynman's path integral formulation.

## That's pretty damn Feyn, where do I play?

If you can't contain yourself anymore you can play right here. As we are inspired by Richard Feynman, our python library, `Feyn`

, is pronounced like 'fine' as in 'so damn fine'.

Let's talk more about `QLattices`

. `QLattices`

produce `QGraphs`

. A `QGraph`

is a list of models and a model looks a little bit like a standard neural network. It is similar because:

- models take inputs from features and output a prediction;
- it has a bunch of nodes with some functions in them;
- we use backpropagation to fit each model to the data.

They are also differences to neural networks because:

- there are much fewer nodes and connections (and we also call the nodes
`interactions`

); - there are functions you wouldn't normally see in a neural network (
`Gaussian`

,`sine`

and`multiply`

); - NO ONE-HOT ENCODING NEEDED! This is because there is a cool
`categorical register`

we can use for this.

Here's a neat little model that was in a `QGraph`

from the regression example:

## Ok, but HOW do I play?

Suppose a data scientist has some data that they would like to model using `Feyn`

and a `QLattice`

. First she will extract a `QGraph`

from a `QLattice`

. Remember this is a long list of potential models for the dataset. Next she will evaluate all these suggestions and update the `QLattice`

with the best one.

This has the effect of telling the `QLattice`

that this was a good model, more of this please! The search space of the `QLattice`

narrows and focuses in this direction so it will produce `QGraphs`

that are more and more relevant for modelling the dataset.

## Can you tell me a bit more?

Of course we can! You should get to know more about:

- the
`registers`

on a`QLattice`

; - the
`interactions`

in a model;

You can also find pages about registers and interactions in the guides to the side.

### Registers

When you get your first `QLattice`

, you need to tell it what type of models you want. This sounds complicated but this just means telling the `QLattice`

that it should produce models with these inputs and this output. We do this with `registers`

!

If we imagine our data scientist again she has some features and a target variable in her dataset. We assign a `register`

to each feature and target variable.

Next time she extracts a `QGraph`

, she will tell the `QLattice`

which `registers`

should be used as inputs and which one as the output. The `QGraph`

will be a list of potential models that predict the target feature from the input features.

There are two types of `registers`

: the `numerical`

and `categorical`

Register Type | Data Type |
---|---|

Float | |

Object |

It is the `categorical register`

that does the automatic one-hot-encoding of categorical values.

### Interactions

`Interactions`

are the basic computation units of each model. They take in data, transform it and then spit it out to be used in the next `interaction`

. In the model above, there's only one `interaction`

: `tanh`

. Here are the others:

Type | Function |
---|---|

Tanh boundary | |

Gaussian | |

Multiply | |

Sinusoidal |

Each `interaction`

(except `multiply`

) has weights and biases which can be optimised using the backpropagation algorithm. This is what happens when we fit the models to our data. You can find out more about fitting in the guides to the side.

## Ok I think I've followed but what's the workflow like?

Every workflow follows the same basic pattern:

- assign
`registers`

on your`QLattice`

to inputs and an output; - extract a
`QGraph`

from your`QLattice`

; - fit each model in the
`QGraph`

; - update the
`QLattice`

with the best model so it learns; - return to 2.

Of course you can play around with this workflow as much as you like but the basic one is: Extract, Fit, Update, Repeat.

You can find out more about updating in the guides to the right.

## Great, so why do I want it?

After a job well done and you've got a good model from the above workflow, those learnings are still there in the `QLattice`

. The next time you return to it, it will pick up from where it left off. This has some awesome implications.

### Shared learnings

If you have multiple problems within the same domain, then it is likely that they are related. Therefore the QLattice can apply learnings from one problem to another and may be an improvement compared to learning the problem in isolation.

### Many independent teachers

Data is often distributed by nature and then centralized for training. With a `QLattice`

it does not have to be so. You could have a dataset and your friend could have another part of that dataset. Instead of centralising it you can just access the same `QLattice`

. If you both update the `QLattice`

with good models then the learnings are stored centrally so your data doesn't have to be.

## What other great things can it do?

Well I'm glad you asked.

### Explainability

As there are fewer `interactions`

, the models are easier to read than a neural network. The `QLattice`

tends towards finding models with fewer `interactions`

and less complex models. This is so that there is more `readability`

and `explainability`

to the models' predictions.

### Privacy

Where's yo data at? It’s wherever you decide to have it. You don’t have to upload or transfer it to us to work with the QLattice. The QLattice just stores learnings so we have no need to store your data with us. You keep your data. It doesn’t go anywhere. It stays with you.