Feyn

Feyn

  • Tutorials
  • Guides
  • API Reference
  • FAQ

›Primitive Operations

Getting Started

  • Quick start
  • Using Feyn
  • Installation
  • Transition to Feyn 3.0
  • What is a QLattice?
  • Community edition
  • Commercial use

Essentials

  • Auto Run
  • Visualise a model
  • Summary plot
  • Semantic types
  • Categorical features
  • Estimating priors
  • Model parameters
  • Predicting with a model
  • Saving and loading models
  • Filtering models
  • Seeding a QLattice
  • Privacy

Evaluate Regressors

  • Regression plot
  • Residuals plot

Evaluate Classifiers

  • ROC curve
  • Confusion matrix
  • Plot probability scores

Understand Your Models

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

Primitive Operations

  • Using the primitives
  • Updating priors
  • Sample models
  • Fitting models
  • Pruning models
  • Diverse models
  • Updating a QLattice
  • Validate data

Advanced

  • Converting a model to SymPy
  • Setting themes
  • Saving a graph as an image
  • Using the query language
  • Model complexity

Sample models

by: Kevin Broløs & Chris Cave
(Feyn version 3.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.

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 QLattice. There are many of them and they are not in any specific order.

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 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:

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 →
  • input_names
  • output_name
  • kind
  • max_complexity
Copyright © 2023 Abzu.ai
Feyn®, QGraph®, and the QLattice® are registered trademarks of Abzu®