Feyn Documentation

Feyn Documentation

  • Learn
  • Guides
  • Tutorials
  • API Reference
  • FAQ

›Primitive Operations

Getting Started

  • Quick start
  • Using Feyn
  • Installation
  • What is the QLattice?

Essentials

  • Auto Run
  • Summary plot
  • Plot response
  • Splitting a dataset
  • Seeding a QLattice
  • Predicting with a model
  • Saving and loading models
  • Categorical features

Evaluate Regressors

  • Regression plot
  • Residuals plot

Evaluate Classifiers

  • ROC curve
  • Confusion matrix
  • Plot probability scores

Understand Your Models

  • Plot response 1D
  • Plot response 2D
  • Model signal
  • Segmented loss
  • Interactive flow

Primitive Operations

  • Using the primitives
  • Updating priors
  • Sample models
  • Fitting models
  • Pruning models
  • Visualise a model
  • Diverse models
  • Updating a QLattice
  • Validate data
  • Semantic types

Advanced

  • Converting a model to SymPy
  • Logging in Feyn
  • Setting themes
  • Saving a graph as an image
  • Using the query language
  • Estimating priors
  • Filtering models
  • Model parameters
  • Model complexity

Privacy & Commercial

  • Privacy
  • Community edition
  • Commercial use
  • Transition to Feyn 3.0

Sample models

by: Kevin Broløs & Chris Cave
(Feyn version 3.4.0 or newer)


The 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.

Example

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',
    max_complexity=10
)

This returns a list of Models from the inputs to the output that have been sampled from the QLattice. There are many of them and they are not in any specific order.


Parameters of sample_models

input_names

The parameter input_names can take an iterable of strings. For example:

  • A list of strings.
  • pd.DataFrame.columns
  • Dict.keys

This is used to define the possible inputs of a Model.

You can as a convenience pass in a Dict or pd.DataFrame, as it will iterate over the column names.

output_name

This is the name of the output as a string.

kind

The kind parameter can take one of classification, regression or auto to specify the sampled Models. The default is auto, however it relies on an stype being defined for the output column to work. If kind is auto and no stype is given, it defaults to regression.

The difference between the two is that the final mathematical transform of a classification is a logisitic function:

11+e−x\frac{1}{1 + e^{-x}}1+e−x1​

which takes any value and maps it to a value between 0 and 1.

max_complexity

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 Model.

← Updating priorsFitting models →
  • Example
  • Parameters of sample_models
    • input_names
    • output_name
    • kind
    • max_complexity

Subscribe to get news about Feyn and the QLattice.

You can opt out at any time, and you can read our privacy policy here.

Copyright © 2024 Abzu.ai - Feyn license: CC BY-NC-ND 4.0
Feyn®, QGraph®, and the QLattice® are registered trademarks of Abzu®