Feyn

Feyn

  • Tutorials
  • Guides
  • API Reference
  • FAQ

›Essentials

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

Filtering models

by: Chris Cave & Meera Machado
(Feyn version 3.0 or newer)

You can filter a list of Models you've sampled from a QLattice, to only include Models that you're interested in. This can be achieved using the builtin Python filter function. Some of the more common use cases require some code, so we've included convenience functions to help.

Here's a code snippet to sample some models we can filter on:

import feyn

# sample a list of models
ql = feyn.QLattice()
models = ql.sample_models(
    input_names = ["Hello", "World"],
    output_name = "Hola!"
)

Here's a list of filters that Feyn ships with, but you can also make your own:


Complexity
Contains Inputs
Contains Functions
Exclude Functions
Custom

Complexity

This filters Models of a certain complexity.

from feyn.filters import Complexity

# Get only models of complexity 2
f = Complexity(complexity=2)
f_models = list(filter(f, models))

ContainsInputs

This filters Models that contain the provided input(s).

from feyn.filters import ContainsInputs

# Get models that contain the "World" input
f = ContainsInputs("World")
f_models = list(filter(f, models))

# Get models that contain both "Hello" and "World" inputs
f = ContainsInputs(["Hello", "World"])
f_models = list(filter(f, models))

ContainsFunctions

This filters Models that only contain the provided function(s).

from feyn.filters import ContainsFunctions

# Get models that contains only the "Gaussian" function
f = ContainsFunctions("gaussian")
f_models = list(filter(f, models))

# Get models that contain only the "Gaussian" and "log" function
f = ContainsFunctions(["gaussian", "log"])
f_models = list(filter(f, models))

ExcludeFunctions

This filters Models that exclude the provided function(s).

from feyn.filters import ExcludeFunctions

# Get models that does not contains the "Gaussian" function
f = ExcludeFunctions("gaussian")
f_models = list(filter(f, models))

# Get models that do not contain either a "Gaussian" or a "log" function
f = ExcludeFunctions(["gaussian", "log"])
f_models = list(filter(f, models))

Custom filter

You can supply any function with the following signature to create your own filter:

def my_custom_filter(model):
return "World" in model.inputs

# Get models that contains the "World" input
f_models = list(filter(my_custom_filter, models))
← Saving and loading modelsSeeding a QLattice →
  • Complexity
  • ContainsInputs
  • ContainsFunctions
  • ExcludeFunctions
  • Custom filter
Copyright © 2023 Abzu.ai
Feyn®, QGraph®, and the QLattice® are registered trademarks of Abzu®