by: Kevin Broløs & Chris Cave
(Feyn version 3.2 or newer)
auto_run method on the
QLattice is a convenience function for running the
This enables you to get receive
Models fitted to your data with a single line of code.
First, load a data set and initialise a
from feyn.datasets import make_classification
train, test = make_classification()
ql = feyn.QLattice()
Then we use only one line of code to obtain models fitted to the data.
models = ql.auto_run(
One epoch of
auto_run is roughly equivalent to:
Models from a
- fit the
Models to the data.
- prune the list of
- update the
QLatticewith the remaining models.
If you are running this in a
Jupyter environment then it will display the best model at the current epoch. Underneath the model it displays the current epoch, the amount of
Models that have been sampled from the
QLattice and the loss of the
Model's predictions of the data.
Data preparation and types
Feyn requires very little data preparation since the models have inputs that do automatic scaling and treatment of certain types. The
QLattice does require knowing what type you intend an input to be, and we call those
semantic types, or
auto_run aims to be fully automatic, so it tries to guess those types when you train, meaning you can get started with most data sets without making decisions on the types.
You can specify the types manually, and we refer to the guide on semantic types (
stypes) for more on that.
QLattice is a stochastic algorithm, but like many other machine learning techniques, you can supply a random seed in order to obtain reproducible results between runs. You can read more about that on Seeding a QLattice.
auto_run is a convenience function that wraps the Primitive Operations, and you should read through each of those guides if you want a more customised workflow or would just like to dive deeper into the options.
Most of the parameters for the Primitive Operations also exist on
We didn't tackle all the options of
auto_run. Here's a list of some additional options you can read into:
Go to the API Reference to see the full list of parameters to
auto_run. Here are descriptions of the ones we've used in this example.
This is the data that the
Models will be fitted to. This needs to be a
pandas.DataFrame object where a sample is represented by a single row and the variable names are the names of the columns.
This is the name of the target variable as a string.
The kind parameter can take one of "classification" or "regression" and this specifies whether the Models will be binary classifiers or regressors. The default is a regression. The loss function the
Models will be fitted to is
squared_loss for regressors or
binary_cross_entropy for classifiers.