by: Kevin Broløs & Chris Cave
(Feyn version 3.0 or newer)
QLattice is a statistical source of models. We can sample models from the
QLattice by using the
QLattice.sample_models() function. Here we go through a small example using it.
import feyn from feyn.datasets import make_classification train, test = make_classification() ql = feyn.QLattice() models = ql.sample_models( input_names=train.columns, output_name='y', kind='classification', max_complexity=10 )
This returns a list of
Models from the inputs to the output that have been sampled from the
There are many of them and they are not in any specific order.
input_names can take an iterable of strings. For example:
- A list of strings.
This is used to define the possible inputs of a
You can as a convenience pass in a
pd.DataFrame, as it will iterate over the column names.
This is the name of the output as a string.
The kind parameter can take one of classification or regression to specify the sampled
Models. The default is a regression.
The difference between the two is that the final mathematical transform of a classification is a logisitic function:
which takes any value and maps it to a value between 0 and 1.
The max_complexity parameter controls the complexity of the model. Low values of 4 or 5 will yield very simple models while values above 10 yield highly complex models. This is the number of edges in the graph representation of the