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

Fitting models

by: Chris Cave & Jaan Kasak
(Feyn version 3.0 or newer)


Each Model is a mathematical function that can be optimised to a loss function in order to fit to a dataset.

Example

Building on from the previous section, here's an example of how to sample and fit models.

import feyn
from feyn.datasets import make_classification

train, test = make_classification()

ql = feyn.QLattice()

models = ql.sample_models(train.columns, 'y', 'classification', max_complexity=10)

models = feyn.fit_models(
    models=models,
    data=train,
    loss_function='binary_cross_entropy',
    criterion='bic',
    threads=4
)

Parameters of fit_models

models

This is the list of Models you want to fit the data to. This will return the same list but sorted by ascending loss.

data

This is the data that the Models will be fitted to. This needs to be a pandas.DataFrame object where a sample is represented by a single row and the variable names are the names of the columns.

loss_function

This is the loss function that the Models are optimised for. If no criterion is given, the returned list of Models is sorted by this loss function in ascending order. It takes any loss function in the feyn.losses module. Popular choices of loss functions are:

  • binary_cross_entropy
  • squared_error

criterion

The criterion takes into account the complexity of the Model when comparing losses. Higher complexity is penalized. Choices of criterion are:

  • bic (Bayesion Information Criterion)
  • aic (Akaike Information Criterion)

bic penalises complex models more than aic.

If a criterion is given, the returned list of Models are sorted by that instead of the loss.

threads

Determines how many concurrent threads to use during fitting. For best effect, set the threads parameter to match the number of threads available on your computer.

← Sample modelsPruning models →
  • Example
  • Parameters of fit_models
    • models
    • data
    • loss_function
    • criterion
    • threads

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®