specparam.metrics.Metric

class specparam.metrics.Metric(category, measure, description, func, kwargs=None)[source]

Define a metric to apply to a power spectrum model.

Parameters:
categorystr

The category of measure, e.g. ‘error’ or ‘gof’.

measurestr

The specific measure, e.g. ‘r_squared’.

descriptionstr

Description of the metric.

funccallable

The function that computes the metric.

kwargsdictionary

Additional keyword argument to compute the metric. Each key should be the name of the additional argument. Each value should be a lambda function that takes ‘data’ & ‘results’ and returns the desired parameter / computed value.

__init__(category, measure, description, func, kwargs=None)[source]

Initialize metric.

Methods

__init__(category, measure, description, func)

Initialize metric.

compute_metric(data, results)

Compute metric.

print([description, concise])

Print out current metric.

reset()

Reset metric result.

Attributes

flabel

Define formatted label property.

label

Define label property.

compute_metric(data, results)[source]

Compute metric.

Parameters:
dataData

Model data.

resultsResults

Model results.

property flabel

Define formatted label property.

property label

Define label property.

print(description=False, concise=False)[source]

Print out current metric.

Parameters:
descriptionbool, optional, default: False

Whether to print out a description with current metric.

concisebool, optional, default: False

Whether to print a concise version of the report.

reset()[source]

Reset metric result.

Examples using specparam.metrics.Metric

Custom Metrics

Custom Metrics