saftig.evaluation.metrics ========================= .. py:module:: saftig.evaluation.metrics .. autoapi-nested-parse:: Methods of evaluation noise cancellation performance. Attributes ---------- .. autoapisummary:: saftig.evaluation.metrics.Self Classes ------- .. autoapisummary:: saftig.evaluation.metrics.EvaluationMetric saftig.evaluation.metrics.EvaluationMetricScalar saftig.evaluation.metrics.EvaluationMetricPlottable saftig.evaluation.metrics.RMSMetric saftig.evaluation.metrics.MSEMetric saftig.evaluation.metrics.BandwidthPowerMetric saftig.evaluation.metrics.PSDMetric Functions --------- .. autoapisummary:: saftig.evaluation.metrics.welch_multiple_sequences Module Contents --------------- .. py:data:: Self .. py:function:: welch_multiple_sequences(arrays, nperseg, *args, **kwargs) Apply scipy.signal.welch to a sequence of arrays Additional arguments are passed to the scipy Welch implementation. Spectra are combined with an average weighted by the array lengths. If sequences :param arrays: Sequence of arrays :param nperseg: Length of FFT segments .. py:class:: EvaluationMetric(**kwargs) Bases: :py:obj:`abc.ABC` Parent class for evaluation metrics .. py:attribute:: applied :value: False .. py:attribute:: prediction :type: collections.abc.Sequence[numpy.typing.NDArray] .. py:attribute:: dataset :type: saftig.evaluation.dataset.EvaluationDataset .. py:attribute:: residual :type: collections.abc.Sequence[numpy.typing.NDArray] .. py:attribute:: parameters :type: dict .. py:attribute:: name :type: str .. py:attribute:: method_hash_value :type: bytes .. py:method:: init_wrapper(func) :staticmethod: A decorator for the __init__function Saves a hash value for the configuration .. py:method:: apply(prediction, dataset) Apply this filter .. py:property:: result_full :type: tuple :abstractmethod: The raw data of the result .. py:property:: result :type: Any The result of the metric evaluation .. py:method:: result_to_text(result_full) :classmethod: String indicating the evaluation result .. py:property:: text The text representation of the evaluation result .. py:method:: _file_hash() :classmethod: Calculates a hash value based on the file in which this method was defined. .. py:property:: method_hash :type: bytes A hash representing the configured metric as a bytes object .. py:property:: method_hash_str :type: str A hash representing the configured metric as a base64 like string .. py:method:: result_full_wrapper(func) :staticmethod: A decorator for the result_full member function. Raises an exception if result is accessed on an object that was not applied to data. Caches the result to prevent double calculation. .. py:class:: EvaluationMetricScalar(**kwargs) Bases: :py:obj:`EvaluationMetric` Parent class for evaluation metrics that yield a scalar value .. py:property:: result :type: float The raw data of the result .. py:method:: result_to_text(result_full) :classmethod: String indicating the evaluation result .. py:class:: EvaluationMetricPlottable(**kwargs) Bases: :py:obj:`EvaluationMetric` Parent class for evaluation metrics that provide a plotting feature .. py:method:: plot(ax) :abstractmethod: Generate a result plot on the given axes object .. py:method:: save_plot(fname, figsize = (6, 3), tight_layout = True) Save the plot to a file .. py:class:: RMSMetric(**kwargs) Bases: :py:obj:`EvaluationMetricScalar` The RMS of the residual signal .. py:attribute:: name :value: 'Residual RMS' .. py:property:: result_full :type: tuple[numpy.floating | float] The raw data of the result .. py:method:: result_to_text(result_full) :staticmethod: String indicating the evaluation result .. py:class:: MSEMetric(**kwargs) Bases: :py:obj:`EvaluationMetricScalar` The MSE of the residual signal .. py:attribute:: name :value: 'Residual MSE' .. py:property:: result_full :type: tuple[numpy.floating | float] The raw data of the result .. py:class:: BandwidthPowerMetric(f_start, f_stop, n_fft = 1024, window='hann') Bases: :py:obj:`EvaluationMetricScalar` The signal power on a given frequency range The spectrum is calculated with welch on each sequence. An average weighted by the sequence length is used to combine spectra from the sequences. The closes bins to f_start and f_stop is chosen as the integration borders. :param f_start: The frequency at which the power integration starts :param f_stop: The frequency at which the power integration stops :param n_fft: Sample count per FFT block used by welch :param window: The FFT window type .. py:attribute:: name :value: 'Residual power on frequency range' .. py:attribute:: f_start .. py:attribute:: f_stop .. py:attribute:: n_fft :value: 1024 .. py:attribute:: window :value: 'hann' .. py:property:: result_full The raw data of the result .. py:class:: PSDMetric(n_fft = 1024, window = 'hann', logx = True, logy = True, show_target = True) Bases: :py:obj:`EvaluationMetricPlottable` Plots the PSD of the given signal The spectrum is calculated with Welch on each sequence. An average weighted by the sequence length is used to combine spectra from the sequences. The closes bins to f_start and f_stop is chosen as the integration borders. :param n_fft: Sample count per FFT block used by Welch's method :param window: fft window type :param logx: Logarithmic x scale :param logy: Logarithmic y scale .. py:attribute:: name :value: 'Power spectral density' .. py:attribute:: n_fft :value: 1024 .. py:attribute:: window :value: 'hann' .. py:attribute:: logx :value: True .. py:attribute:: logy :value: True .. py:attribute:: show_target :value: True .. py:method:: _welch_multiple_sequences(signal) apply welch_multiple_sequences() with correct settings .. py:property:: result_full :type: tuple[numpy.typing.NDArray, numpy.typing.NDArray] The raw data of the result .. py:method:: plot(ax) Plot to the given Axes object