Feyn Documentation

Feyn Documentation

  • Learn
  • Guides
  • Tutorials
  • API Reference
  • FAQ

›Advanced

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

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.

Example

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!"
)

Use the selector to navigate some examples for filter functions that Feyn ships with, but you can also make your own custom function:


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))
← Estimating priorsModel parameters →
  • Example
    • Complexity
    • ContainsInputs
    • ContainsFunctions
    • ExcludeFunctions
    • Custom filter

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®