specparam.results.results.Results

class specparam.results.results.Results(modes=None, metrics=None, bands=None)[source]

Object for managing results - base / 1D version.

Parameters:
modesModes

Modes object with fit mode definitions.

metricsMetrics

Metrics object with metric definitions.

bandsBands or dict or int or None

Bands object with band definitions, or definition that can be turned into a Bands object.

Attributes:
modesModes

Modes object with fit mode definitions.

bandsBands

Bands object with band definitions.

modelModelComponents

Manages the model fit and components.

paramsModelParameters

Manages the model fit parameters.

metricsMetrics

Metrics object with metric definitions.

__init__(modes=None, metrics=None, bands=None)[source]

Initialize Results object.

Methods

__init__([modes, metrics, bands])

Initialize Results object.

add_bands(bands)

Add bands definition to object.

add_metrics(metrics)

Add metrics definition to object.

add_results(results)

Add results data into object from a FitResults object.

get_metrics(category[, measure])

Get requested metric(s) from the object.

get_params(component[, field, version])

Return model fit parameters for specified feature(s).

get_results()

Return model fit parameters and metrics.

Attributes

has_model

Indicator for if the object contains a model fit.

n_params

The total number of parameters fit in the model.

n_peaks

How many peaks were fit in the model.

add_bands(bands)[source]

Add bands definition to object.

Parameters:
bandsBands or dict or int or None

How to organize peaks into bands. If Bands, defines band ranges, if int, specifies a number of bands to consider. If dict, should be a set of band definitions to be converted into a Bands object. If None, sets bands as an empty Bands object.

add_metrics(metrics)[source]

Add metrics definition to object.

Parameters:
metricsMetrics or list of Metric or list of str or None

Metrics definition(s) to add to object. If None, initialized with default metrics.

add_results(results)[source]

Add results data into object from a FitResults object.

Parameters:
resultsFitResults

A data object containing the results from fitting a power spectrum model.

get_metrics(category, measure=None)[source]

Get requested metric(s) from the object.

Parameters:
If ‘all’, returns all available metrics.
measurestr, optional

Name of the specific measure(s) to return.

Returns:
metricsdict

Dictionary of requested metrics.

get_params(component, field=None, version=None)[source]

Return model fit parameters for specified feature(s).

Parameters:
component{‘aperiodic’, ‘periodic’}

Name of the component to extract parameters for.

fieldstr or int, optional

Column name / index to extract from selected data, if requested. If str, should align with a parameter label for the component fit mode.

version{‘fit’, ‘converted’}

Which version of the parameters to extract.

Returns:
outfloat or 1d array

Requested data.

Raises:
NoModelError

If there are no model fit parameters available to return.

Notes

If there are no fit peaks (no periodic parameters), this method will return NaN.

get_results()[source]

Return model fit parameters and metrics.

Returns:
FitResults

Object containing the model fit results from the current object.

property has_model

Indicator for if the object contains a model fit.

Notes

This checks the aperiodic params, which are necessarily defined if a model has been fit.

property n_params

The total number of parameters fit in the model.

property n_peaks

How many peaks were fit in the model.