Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def information_gain(reference_beats, estimated_beats, bins=41): validate(reference_beats, estimated_beats) # If an even number of bins is provided, # there will be no bin centered at zero, so warn the user. if n...
[ "Get the information gain - K-L divergence of the beat error histogram\n to a uniform histogram\n\n Examples\n --------\n >>> reference_beats = mir_eval.io.load_events('reference.txt')\n >>> reference_beats = mir_eval.beat.trim_beats(reference_beats)\n >>> estimated_beats = mir_eval.io.load_events...
Please provide a description of the function:def _get_entropy(reference_beats, estimated_beats, bins): beat_error = np.zeros(estimated_beats.shape[0]) for n in range(estimated_beats.shape[0]): # Get index of closest annotation to this beat beat_distances = estimated_beats[n] - reference_bea...
[ "Helper function for information gain\n (needs to be run twice - once backwards, once forwards)\n\n Parameters\n ----------\n reference_beats : np.ndarray\n reference beat times, in seconds\n estimated_beats : np.ndarray\n query beat times, in seconds\n bins : int\n Number of ...
Please provide a description of the function:def evaluate(reference_beats, estimated_beats, **kwargs): # Trim beat times at the beginning of the annotations reference_beats = util.filter_kwargs(trim_beats, reference_beats, **kwargs) estimated_beats = util.filter_kwargs(trim_beats, estimated_beats, **k...
[ "Compute all metrics for the given reference and estimated annotations.\n\n Examples\n --------\n >>> reference_beats = mir_eval.io.load_events('reference.txt')\n >>> estimated_beats = mir_eval.io.load_events('estimated.txt')\n >>> scores = mir_eval.beat.evaluate(reference_beats, estimated_beats)\n\n...
Please provide a description of the function:def index_labels(labels, case_sensitive=False): label_to_index = {} index_to_label = {} # If we're not case-sensitive, if not case_sensitive: labels = [str(s).lower() for s in labels] # First, build the unique label mapping for index, ...
[ "Convert a list of string identifiers into numerical indices.\n\n Parameters\n ----------\n labels : list of strings, shape=(n,)\n A list of annotations, e.g., segment or chord labels from an\n annotation file.\n\n case_sensitive : bool\n Set to True to enable case-sensitive label i...
Please provide a description of the function:def generate_labels(items, prefix='__'): return ['{}{}'.format(prefix, n) for n in range(len(items))]
[ "Given an array of items (e.g. events, intervals), create a synthetic label\n for each event of the form '(label prefix)(item number)'\n\n Parameters\n ----------\n items : list-like\n A list or array of events or intervals\n prefix : str\n This prefix will be prepended to all synthetic...
Please provide a description of the function:def intervals_to_samples(intervals, labels, offset=0, sample_size=0.1, fill_value=None): # Round intervals to the sample size num_samples = int(np.floor(intervals.max() / sample_size)) sample_indices = np.arange(num_samples, dtype=n...
[ "Convert an array of labeled time intervals to annotated samples.\n\n Parameters\n ----------\n intervals : np.ndarray, shape=(n, d)\n An array of time intervals, as returned by\n :func:`mir_eval.io.load_intervals()` or\n :func:`mir_eval.io.load_labeled_intervals()`.\n The ``i``...
Please provide a description of the function:def interpolate_intervals(intervals, labels, time_points, fill_value=None): # Verify that time_points is sorted time_points = np.asarray(time_points) if np.any(time_points[1:] < time_points[:-1]): raise ValueError('time_points must be in non-decrea...
[ "Assign labels to a set of points in time given a set of intervals.\n\n Time points that do not lie within an interval are mapped to `fill_value`.\n\n Parameters\n ----------\n intervals : np.ndarray, shape=(n, 2)\n An array of time intervals, as returned by\n :func:`mir_eval.io.load_inter...
Please provide a description of the function:def sort_labeled_intervals(intervals, labels=None): '''Sort intervals, and optionally, their corresponding labels according to start time. Parameters ---------- intervals : np.ndarray, shape=(n, 2) The input intervals labels : list, optional...
[]
Please provide a description of the function:def f_measure(precision, recall, beta=1.0): if precision == 0 and recall == 0: return 0.0 return (1 + beta**2)*precision*recall/((beta**2)*precision + recall)
[ "Compute the f-measure from precision and recall scores.\n\n Parameters\n ----------\n precision : float in (0, 1]\n Precision\n recall : float in (0, 1]\n Recall\n beta : float > 0\n Weighting factor for f-measure\n (Default value = 1.0)\n\n Returns\n -------\n f...
Please provide a description of the function:def intervals_to_boundaries(intervals, q=5): return np.unique(np.ravel(np.round(intervals, decimals=q)))
[ "Convert interval times into boundaries.\n\n Parameters\n ----------\n intervals : np.ndarray, shape=(n_events, 2)\n Array of interval start and end-times\n q : int\n Number of decimals to round to. (Default value = 5)\n\n Returns\n -------\n boundaries : np.ndarray\n Inter...
Please provide a description of the function:def boundaries_to_intervals(boundaries): if not np.allclose(boundaries, np.unique(boundaries)): raise ValueError('Boundary times are not unique or not ascending.') intervals = np.asarray(list(zip(boundaries[:-1], boundaries[1:]))) return intervals
[ "Convert an array of event times into intervals\n\n Parameters\n ----------\n boundaries : list-like\n List-like of event times. These are assumed to be unique\n timestamps in ascending order.\n\n Returns\n -------\n intervals : np.ndarray, shape=(n_intervals, 2)\n Start and ...
Please provide a description of the function:def adjust_intervals(intervals, labels=None, t_min=0.0, t_max=None, start_label='__T_MIN', end_label='__T_MAX'): # When supplied intervals are empty and t_max a...
[ "Adjust a list of time intervals to span the range ``[t_min, t_max]``.\n\n Any intervals lying completely outside the specified range will be removed.\n\n Any intervals lying partially outside the specified range will be cropped.\n\n If the specified range exceeds the span of the provided data in either\n ...
Please provide a description of the function:def adjust_events(events, labels=None, t_min=0.0, t_max=None, label_prefix='__'): if t_min is not None: first_idx = np.argwhere(events >= t_min) if len(first_idx) > 0: # We have events below t_min # Crop the...
[ "Adjust the given list of event times to span the range\n ``[t_min, t_max]``.\n\n Any event times outside of the specified range will be removed.\n\n If the times do not span ``[t_min, t_max]``, additional events will be\n added with the prefix ``label_prefix``.\n\n Parameters\n ----------\n ev...
Please provide a description of the function:def intersect_files(flist1, flist2): def fname(abs_path): return os.path.splitext(os.path.split(abs_path)[-1])[0] fmap = dict([(fname(f), f) for f in flist1]) pairs = [list(), list()] for f in flist2: if fname(f) in fmap: ...
[ "Return the intersection of two sets of filepaths, based on the file name\n (after the final '/') and ignoring the file extension.\n\n Examples\n --------\n >>> flist1 = ['/a/b/abc.lab', '/c/d/123.lab', '/e/f/xyz.lab']\n >>> flist2 = ['/g/h/xyz.npy', '/i/j/123.txt', '/k/l/456.lab']\n >>> sublis...
Please provide a description of the function:def merge_labeled_intervals(x_intervals, x_labels, y_intervals, y_labels): r align_check = [x_intervals[0, 0] == y_intervals[0, 0], x_intervals[-1, 1] == y_intervals[-1, 1]] if False in align_check: raise ValueError( "Time i...
[ "Merge the time intervals of two sequences.\n\n Parameters\n ----------\n x_intervals : np.ndarray\n Array of interval times (seconds)\n x_labels : list or None\n List of labels\n y_intervals : np.ndarray\n Array of interval times (seconds)\n y_labels : list or None\n L...
Please provide a description of the function:def _bipartite_match(graph): # Adapted from: # # Hopcroft-Karp bipartite max-cardinality matching and max independent set # David Eppstein, UC Irvine, 27 Apr 2002 # initialize greedy matching (redundant, but faster than full search) matching = {...
[ "Find maximum cardinality matching of a bipartite graph (U,V,E).\n The input format is a dictionary mapping members of U to a list\n of their neighbors in V.\n\n The output is a dict M mapping members of V to their matches in U.\n\n Parameters\n ----------\n graph : dictionary : left-vertex -> lis...
Please provide a description of the function:def _outer_distance_mod_n(ref, est, modulus=12): ref_mod_n = np.mod(ref, modulus) est_mod_n = np.mod(est, modulus) abs_diff = np.abs(np.subtract.outer(ref_mod_n, est_mod_n)) return np.minimum(abs_diff, modulus - abs_diff)
[ "Compute the absolute outer distance modulo n.\n Using this distance, d(11, 0) = 1 (modulo 12)\n\n Parameters\n ----------\n ref : np.ndarray, shape=(n,)\n Array of reference values.\n est : np.ndarray, shape=(m,)\n Array of estimated values.\n modulus : int\n The modulus.\n ...
Please provide a description of the function:def match_events(ref, est, window, distance=None): if distance is not None: # Compute the indices of feasible pairings hits = np.where(distance(ref, est) <= window) else: hits = _fast_hit_windows(ref, est, window) # Construct the gra...
[ "Compute a maximum matching between reference and estimated event times,\n subject to a window constraint.\n\n Given two lists of event times ``ref`` and ``est``, we seek the largest set\n of correspondences ``(ref[i], est[j])`` such that\n ``distance(ref[i], est[j]) <= window``, and each\n ``ref[i]`...
Please provide a description of the function:def _fast_hit_windows(ref, est, window): '''Fast calculation of windowed hits for time events. Given two lists of event times ``ref`` and ``est``, and a tolerance window, computes a list of pairings ``(i, j)`` where ``|ref[i] - est[j]| <= window``. This...
[]
Please provide a description of the function:def validate_intervals(intervals): # Validate interval shape if intervals.ndim != 2 or intervals.shape[1] != 2: raise ValueError('Intervals should be n-by-2 numpy ndarray, ' 'but shape={}'.format(intervals.shape)) # Make su...
[ "Checks that an (n, 2) interval ndarray is well-formed, and raises errors\n if not.\n\n Parameters\n ----------\n intervals : np.ndarray, shape=(n, 2)\n Array of interval start/end locations.\n\n " ]
Please provide a description of the function:def validate_events(events, max_time=30000.): # Make sure no event times are huge if (events > max_time).any(): raise ValueError('An event at time {} was found which is greater than ' 'the maximum allowable time of max_time = {} ...
[ "Checks that a 1-d event location ndarray is well-formed, and raises\n errors if not.\n\n Parameters\n ----------\n events : np.ndarray, shape=(n,)\n Array of event times\n max_time : float\n If an event is found above this time, a ValueError will be raised.\n (Default value = 30...
Please provide a description of the function:def validate_frequencies(frequencies, max_freq, min_freq, allow_negatives=False): # If flag is true, map frequencies to their absolute value. if allow_negatives: frequencies = np.abs(frequencies) # Make sure no frequency valu...
[ "Checks that a 1-d frequency ndarray is well-formed, and raises\n errors if not.\n\n Parameters\n ----------\n frequencies : np.ndarray, shape=(n,)\n Array of frequency values\n max_freq : float\n If a frequency is found above this pitch, a ValueError will be raised.\n (Default v...
Please provide a description of the function:def has_kwargs(function): r'''Determine whether a function has \*\*kwargs. Parameters ---------- function : callable The function to test Returns ------- True if function accepts arbitrary keyword arguments. False otherwise. ''' ...
[]
Please provide a description of the function:def filter_kwargs(_function, *args, **kwargs): if has_kwargs(_function): return _function(*args, **kwargs) # Get the list of function arguments func_code = six.get_function_code(_function) function_args = func_code.co_varnames[:func_code.co_arg...
[ "Given a function and args and keyword args to pass to it, call the function\n but using only the keyword arguments which it accepts. This is equivalent\n to redefining the function with an additional \\*\\*kwargs to accept slop\n keyword args.\n\n If the target function already accepts \\*\\*kwargs pa...
Please provide a description of the function:def intervals_to_durations(intervals): validate_intervals(intervals) return np.abs(np.diff(intervals, axis=-1)).flatten()
[ "Converts an array of n intervals to their n durations.\n\n Parameters\n ----------\n intervals : np.ndarray, shape=(n, 2)\n An array of time intervals, as returned by\n :func:`mir_eval.io.load_intervals()`.\n The ``i`` th interval spans time ``intervals[i, 0]`` to\n ``intervals...
Please provide a description of the function:def validate(reference_sources, estimated_sources): if reference_sources.shape != estimated_sources.shape: raise ValueError('The shape of estimated sources and the true ' 'sources should match. reference_sources.shape ' ...
[ "Checks that the input data to a metric are valid, and throws helpful\n errors if not.\n\n Parameters\n ----------\n reference_sources : np.ndarray, shape=(nsrc, nsampl)\n matrix containing true sources\n estimated_sources : np.ndarray, shape=(nsrc, nsampl)\n matrix containing estimated...
Please provide a description of the function:def _any_source_silent(sources): return np.any(np.all(np.sum( sources, axis=tuple(range(2, sources.ndim))) == 0, axis=1))
[ "Returns true if the parameter sources has any silent first dimensions" ]
Please provide a description of the function:def bss_eval_sources(reference_sources, estimated_sources, compute_permutation=True): # make sure the input is of shape (nsrc, nsampl) if estimated_sources.ndim == 1: estimated_sources = estimated_sources[np.newaxis, :] if refer...
[ "\n Ordering and measurement of the separation quality for estimated source\n signals in terms of filtered true source, interference and artifacts.\n\n The decomposition allows a time-invariant filter distortion of length\n 512, as described in Section III.B of [#vincent2006performance]_.\n\n Passing...
Please provide a description of the function:def bss_eval_sources_framewise(reference_sources, estimated_sources, window=30*44100, hop=15*44100, compute_permutation=False): # make sure the input is of shape (nsrc, nsampl) if estimated_sources.n...
[ "Framewise computation of bss_eval_sources\n\n Please be aware that this function does not compute permutations (by\n default) on the possible relations between reference_sources and\n estimated_sources due to the dangers of a changing permutation. Therefore\n (by default), it assumes that ``reference_s...
Please provide a description of the function:def bss_eval_images(reference_sources, estimated_sources, compute_permutation=True): # make sure the input has 3 dimensions # assuming input is in shape (nsampl) or (nsrc, nsampl) estimated_sources = np.atleast_3d(estimated_sources) ...
[ "Implementation of the bss_eval_images function from the\n BSS_EVAL Matlab toolbox.\n\n Ordering and measurement of the separation quality for estimated source\n signals in terms of filtered true source, interference and artifacts.\n This method also provides the ISR measure.\n\n The decomposition al...
Please provide a description of the function:def bss_eval_images_framewise(reference_sources, estimated_sources, window=30*44100, hop=15*44100, compute_permutation=False): # make sure the input has 3 dimensions # assuming input is in shape (nsamp...
[ "Framewise computation of bss_eval_images\n\n Please be aware that this function does not compute permutations (by\n default) on the possible relations between ``reference_sources`` and\n ``estimated_sources`` due to the dangers of a changing permutation.\n Therefore (by default), it assumes that ``refe...
Please provide a description of the function:def _bss_decomp_mtifilt(reference_sources, estimated_source, j, flen): nsampl = estimated_source.size # decomposition # true source image s_true = np.hstack((reference_sources[j], np.zeros(flen - 1))) # spatial (or filtering) distortion e_spat = ...
[ "Decomposition of an estimated source image into four components\n representing respectively the true source image, spatial (or filtering)\n distortion, interference and artifacts, derived from the true source\n images using multichannel time-invariant filters.\n " ]
Please provide a description of the function:def _bss_decomp_mtifilt_images(reference_sources, estimated_source, j, flen, Gj=None, G=None): nsampl = np.shape(estimated_source)[0] nchan = np.shape(estimated_source)[1] # are we saving the Gj and G parameters? saveg = Gj...
[ "Decomposition of an estimated source image into four components\n representing respectively the true source image, spatial (or filtering)\n distortion, interference and artifacts, derived from the true source\n images using multichannel time-invariant filters.\n Adapted version to work with multichanne...
Please provide a description of the function:def _project(reference_sources, estimated_source, flen): nsrc = reference_sources.shape[0] nsampl = reference_sources.shape[1] # computing coefficients of least squares problem via FFT ## # zero padding and FFT of input data reference_sources = np.h...
[ "Least-squares projection of estimated source on the subspace spanned by\n delayed versions of reference sources, with delays between 0 and flen-1\n " ]
Please provide a description of the function:def _project_images(reference_sources, estimated_source, flen, G=None): nsrc = reference_sources.shape[0] nsampl = reference_sources.shape[1] nchan = reference_sources.shape[2] reference_sources = np.reshape(np.transpose(reference_sources, (2, 0, 1)), ...
[ "Least-squares projection of estimated source on the subspace spanned by\n delayed versions of reference sources, with delays between 0 and flen-1.\n Passing G as all zeros will populate the G matrix and return it so it can\n be passed into the next call to avoid recomputing G (this will only works\n if...
Please provide a description of the function:def _bss_source_crit(s_true, e_spat, e_interf, e_artif): # energy ratios s_filt = s_true + e_spat sdr = _safe_db(np.sum(s_filt**2), np.sum((e_interf + e_artif)**2)) sir = _safe_db(np.sum(s_filt**2), np.sum(e_interf**2)) sar = _safe_db(np.sum((s_filt ...
[ "Measurement of the separation quality for a given source in terms of\n filtered true source, interference and artifacts.\n " ]
Please provide a description of the function:def _bss_image_crit(s_true, e_spat, e_interf, e_artif): # energy ratios sdr = _safe_db(np.sum(s_true**2), np.sum((e_spat+e_interf+e_artif)**2)) isr = _safe_db(np.sum(s_true**2), np.sum(e_spat**2)) sir = _safe_db(np.sum((s_true+e_spat)**2), np.sum(e_inter...
[ "Measurement of the separation quality for a given image in terms of\n filtered true source, spatial error, interference and artifacts.\n " ]
Please provide a description of the function:def _safe_db(num, den): if den == 0: return np.Inf return 10 * np.log10(num / den)
[ "Properly handle the potential +Inf db SIR, instead of raising a\n RuntimeWarning. Only denominator is checked because the numerator can never\n be 0.\n " ]
Please provide a description of the function:def evaluate(reference_sources, estimated_sources, **kwargs): # Compute all the metrics scores = collections.OrderedDict() sdr, isr, sir, sar, perm = util.filter_kwargs( bss_eval_images, reference_sources, estimated_sources, ...
[ "Compute all metrics for the given reference and estimated signals.\n\n NOTE: This will always compute :func:`mir_eval.separation.bss_eval_images`\n for any valid input and will additionally compute\n :func:`mir_eval.separation.bss_eval_sources` for valid input with fewer\n than 3 dimensions.\n\n Exa...
Please provide a description of the function:def clicks(times, fs, click=None, length=None): # Create default click signal if click is None: # 1 kHz tone, 100ms click = np.sin(2*np.pi*np.arange(fs*.1)*1000/(1.*fs)) # Exponential decay click *= np.exp(-np.arange(fs*.1)/(fs*.0...
[ "Returns a signal with the signal 'click' placed at each specified time\n\n Parameters\n ----------\n times : np.ndarray\n times to place clicks, in seconds\n fs : int\n desired sampling rate of the output signal\n click : np.ndarray\n click signal, defaults to a 1 kHz blip\n ...
Please provide a description of the function:def time_frequency(gram, frequencies, times, fs, function=np.sin, length=None, n_dec=1): # Default value for length if times.ndim == 1: # Convert to intervals times = util.boundaries_to_intervals(times) if length is None: ...
[ "Reverse synthesis of a time-frequency representation of a signal\n\n Parameters\n ----------\n gram : np.ndarray\n ``gram[n, m]`` is the magnitude of ``frequencies[n]``\n from ``times[m]`` to ``times[m + 1]``\n\n Non-positive magnitudes are interpreted as silence.\n\n frequencies :...
Please provide a description of the function:def pitch_contour(times, frequencies, fs, amplitudes=None, function=np.sin, length=None, kind='linear'): '''Sonify a pitch contour. Parameters ---------- times : np.ndarray time indices for each frequency measurement, in seconds ...
[]
Please provide a description of the function:def chroma(chromagram, times, fs, **kwargs): # We'll just use time_frequency with a Shepard tone-gram # To create the Shepard tone-gram, we copy the chromagram across 7 octaves n_octaves = 7 # starting from C2 base_note = 24 # and weight each oct...
[ "Reverse synthesis of a chromagram (semitone matrix)\n\n Parameters\n ----------\n chromagram : np.ndarray, shape=(12, times.shape[0])\n Chromagram matrix, where each row represents a semitone [C->Bb]\n i.e., ``chromagram[3, j]`` is the magnitude of D# from ``times[j]`` to\n ``times[j ...
Please provide a description of the function:def chords(chord_labels, intervals, fs, **kwargs): util.validate_intervals(intervals) # Convert from labels to chroma roots, interval_bitmaps, _ = chord.encode_many(chord_labels) chromagram = np.array([np.roll(interval_bitmap, root) ...
[ "Synthesizes chord labels\n\n Parameters\n ----------\n chord_labels : list of str\n List of chord label strings.\n intervals : np.ndarray, shape=(len(chord_labels), 2)\n Start and end times of each chord label\n fs : int\n Sampling rate to synthesize at\n kwargs\n Addi...
Please provide a description of the function:def validate(reference_onsets, estimated_onsets): # If reference or estimated onsets are empty, warn because metric will be 0 if reference_onsets.size == 0: warnings.warn("Reference onsets are empty.") if estimated_onsets.size == 0: warnings....
[ "Checks that the input annotations to a metric look like valid onset time\n arrays, and throws helpful errors if not.\n\n Parameters\n ----------\n reference_onsets : np.ndarray\n reference onset locations, in seconds\n estimated_onsets : np.ndarray\n estimated onset locations, in secon...
Please provide a description of the function:def f_measure(reference_onsets, estimated_onsets, window=.05): validate(reference_onsets, estimated_onsets) # If either list is empty, return 0s if reference_onsets.size == 0 or estimated_onsets.size == 0: return 0., 0., 0. # Compute the best-cas...
[ "Compute the F-measure of correct vs incorrectly predicted onsets.\n \"Corectness\" is determined over a small window.\n\n Examples\n --------\n >>> reference_onsets = mir_eval.io.load_events('reference.txt')\n >>> estimated_onsets = mir_eval.io.load_events('estimated.txt')\n >>> F, P, R = mir_eva...
Please provide a description of the function:def evaluate(reference_onsets, estimated_onsets, **kwargs): # Compute all metrics scores = collections.OrderedDict() (scores['F-measure'], scores['Precision'], scores['Recall']) = util.filter_kwargs(f_measure, reference_onsets, ...
[ "Compute all metrics for the given reference and estimated annotations.\n\n Examples\n --------\n >>> reference_onsets = mir_eval.io.load_events('reference.txt')\n >>> estimated_onsets = mir_eval.io.load_events('estimated.txt')\n >>> scores = mir_eval.onset.evaluate(reference_onsets,\n ... ...
Please provide a description of the function:def validate(ref_intervals, ref_pitches, est_intervals, est_pitches): # Validate intervals validate_intervals(ref_intervals, est_intervals) # Make sure intervals and pitches match in length if not ref_intervals.shape[0] == ref_pitches.shape[0]: ...
[ "Checks that the input annotations to a metric look like time intervals\n and a pitch list, and throws helpful errors if not.\n\n Parameters\n ----------\n ref_intervals : np.ndarray, shape=(n,2)\n Array of reference notes time intervals (onset and offset times)\n ref_pitches : np.ndarray, sha...
Please provide a description of the function:def validate_intervals(ref_intervals, est_intervals): # If reference or estimated notes are empty, warn if ref_intervals.size == 0: warnings.warn("Reference notes are empty.") if est_intervals.size == 0: warnings.warn("Estimated notes are emp...
[ "Checks that the input annotations to a metric look like time intervals,\n and throws helpful errors if not.\n\n Parameters\n ----------\n ref_intervals : np.ndarray, shape=(n,2)\n Array of reference notes time intervals (onset and offset times)\n est_intervals : np.ndarray, shape=(m,2)\n ...
Please provide a description of the function:def match_note_offsets(ref_intervals, est_intervals, offset_ratio=0.2, offset_min_tolerance=0.05, strict=False): # set the comparison function if strict: cmp_func = np.less else: cmp_func = np.less_equal # check fo...
[ "Compute a maximum matching between reference and estimated notes,\n only taking note offsets into account.\n\n Given two note sequences represented by ``ref_intervals`` and\n ``est_intervals`` (see :func:`mir_eval.io.load_valued_intervals`), we seek\n the largest set of correspondences ``(i, j)`` such ...
Please provide a description of the function:def match_note_onsets(ref_intervals, est_intervals, onset_tolerance=0.05, strict=False): # set the comparison function if strict: cmp_func = np.less else: cmp_func = np.less_equal # check for onset matches onset...
[ "Compute a maximum matching between reference and estimated notes,\n only taking note onsets into account.\n\n Given two note sequences represented by ``ref_intervals`` and\n ``est_intervals`` (see :func:`mir_eval.io.load_valued_intervals`), we see\n the largest set of correspondences ``(i,j)`` such tha...
Please provide a description of the function:def match_notes(ref_intervals, ref_pitches, est_intervals, est_pitches, onset_tolerance=0.05, pitch_tolerance=50.0, offset_ratio=0.2, offset_min_tolerance=0.05, strict=False): # set the comparison function if strict: cmp_f...
[ "Compute a maximum matching between reference and estimated notes,\n subject to onset, pitch and (optionally) offset constraints.\n\n Given two note sequences represented by ``ref_intervals``, ``ref_pitches``,\n ``est_intervals`` and ``est_pitches``\n (see :func:`mir_eval.io.load_valued_intervals`), we ...
Please provide a description of the function:def precision_recall_f1_overlap(ref_intervals, ref_pitches, est_intervals, est_pitches, onset_tolerance=0.05, pitch_tolerance=50.0, offset_ratio=0.2, offset_min_tolerance=0.05, st...
[ "Compute the Precision, Recall and F-measure of correct vs incorrectly\n transcribed notes, and the Average Overlap Ratio for correctly transcribed\n notes (see :func:`average_overlap_ratio`). \"Correctness\" is determined\n based on note onset, pitch and (optionally) offset: an estimated note is\n assu...
Please provide a description of the function:def average_overlap_ratio(ref_intervals, est_intervals, matching): ratios = [] for match in matching: ref_int = ref_intervals[match[0]] est_int = est_intervals[match[1]] overlap_ratio = ( (min(ref_int[1], est_int[1]) - max(ref...
[ "Compute the Average Overlap Ratio between a reference and estimated\n note transcription. Given a reference and corresponding estimated note,\n their overlap ratio (OR) is defined as the ratio between the duration of\n the time segment in which the two notes overlap and the time segment\n spanned by th...
Please provide a description of the function:def onset_precision_recall_f1(ref_intervals, est_intervals, onset_tolerance=0.05, strict=False, beta=1.0): validate_intervals(ref_intervals, est_intervals) # When reference notes are empty, metrics are undefined, return 0's if l...
[ "Compute the Precision, Recall and F-measure of note onsets: an estimated\n onset is considered correct if it is within +-50ms of a reference onset.\n Note that this metric completely ignores note offset and note pitch. This\n means an estimated onset will be considered correct if it matches a\n referen...
Please provide a description of the function:def offset_precision_recall_f1(ref_intervals, est_intervals, offset_ratio=0.2, offset_min_tolerance=0.05, strict=False, beta=1.0): validate_intervals(ref_intervals, est_intervals) # When reference not...
[ "Compute the Precision, Recall and F-measure of note offsets: an\n estimated offset is considered correct if it is within +-50ms (or 20% of\n the ref note duration, which ever is greater) of a reference offset. Note\n that this metric completely ignores note onsets and note pitch. This means\n an estima...
Please provide a description of the function:def evaluate(ref_intervals, ref_pitches, est_intervals, est_pitches, **kwargs): # Compute all the metrics scores = collections.OrderedDict() # Precision, recall and f-measure taking note offsets into account kwargs.setdefault('offset_ratio', 0.2) or...
[ "Compute all metrics for the given reference and estimated annotations.\n\n Examples\n --------\n >>> ref_intervals, ref_pitches = mir_eval.io.load_valued_intervals(\n ... 'reference.txt')\n >>> est_intervals, est_pitches = mir_eval.io.load_valued_intervals(\n ... 'estimate.txt')\n >>> sc...
Please provide a description of the function:def validate_key(key): if len(key.split()) != 2: raise ValueError("'{}' is not in the form '(key) (mode)'".format(key)) key, mode = key.split() if key.lower() not in KEY_TO_SEMITONE: raise ValueError( "Key {} is invalid; should be...
[ "Checks that a key is well-formatted, e.g. in the form ``'C# major'``.\n\n Parameters\n ----------\n key : str\n Key to verify\n " ]
Please provide a description of the function:def split_key_string(key): key, mode = key.split() return KEY_TO_SEMITONE[key.lower()], mode
[ "Splits a key string (of the form, e.g. ``'C# major'``), into a tuple of\n ``(key, mode)`` where ``key`` is is an integer representing the semitone\n distance from C.\n\n Parameters\n ----------\n key : str\n String representing a key.\n\n Returns\n -------\n key : int\n Number...
Please provide a description of the function:def weighted_score(reference_key, estimated_key): validate(reference_key, estimated_key) reference_key, reference_mode = split_key_string(reference_key) estimated_key, estimated_mode = split_key_string(estimated_key) # If keys are the same, return 1. ...
[ "Computes a heuristic score which is weighted according to the\n relationship of the reference and estimated key, as follows:\n\n +------------------------------------------------------+-------+\n | Relationship | Score |\n +---------------------------------------...
Please provide a description of the function:def evaluate(reference_key, estimated_key, **kwargs): # Compute all metrics scores = collections.OrderedDict() scores['Weighted Score'] = util.filter_kwargs( weighted_score, reference_key, estimated_key) return scores
[ "Compute all metrics for the given reference and estimated annotations.\n\n Examples\n --------\n >>> ref_key = mir_eval.io.load_key('reference.txt')\n >>> est_key = mir_eval.io.load_key('estimated.txt')\n >>> scores = mir_eval.key.evaluate(ref_key, est_key)\n\n Parameters\n ----------\n ref...
Please provide a description of the function:def validate_voicing(ref_voicing, est_voicing): if ref_voicing.size == 0: warnings.warn("Reference voicing array is empty.") if est_voicing.size == 0: warnings.warn("Estimated voicing array is empty.") if ref_voicing.sum() == 0: warni...
[ "Checks that voicing inputs to a metric are in the correct format.\n\n Parameters\n ----------\n ref_voicing : np.ndarray\n Reference boolean voicing array\n est_voicing : np.ndarray\n Estimated boolean voicing array\n\n " ]
Please provide a description of the function:def validate(ref_voicing, ref_cent, est_voicing, est_cent): if ref_cent.size == 0: warnings.warn("Reference frequency array is empty.") if est_cent.size == 0: warnings.warn("Estimated frequency array is empty.") # Make sure they're the same l...
[ "Checks that voicing and frequency arrays are well-formed. To be used in\n conjunction with :func:`mir_eval.melody.validate_voicing`\n\n Parameters\n ----------\n ref_voicing : np.ndarray\n Reference boolean voicing array\n ref_cent : np.ndarray\n Reference pitch sequence in cents\n ...
Please provide a description of the function:def hz2cents(freq_hz, base_frequency=10.0): freq_cent = np.zeros(freq_hz.shape[0]) freq_nonz_ind = np.flatnonzero(freq_hz) normalized_frequency = np.abs(freq_hz[freq_nonz_ind])/base_frequency freq_cent[freq_nonz_ind] = 1200*np.log2(normalized_frequency) ...
[ "Convert an array of frequency values in Hz to cents.\n 0 values are left in place.\n\n Parameters\n ----------\n freq_hz : np.ndarray\n Array of frequencies in Hz.\n base_frequency : float\n Base frequency for conversion.\n (Default value = 10.0)\n\n Returns\n -------\n ...
Please provide a description of the function:def constant_hop_timebase(hop, end_time): # Compute new timebase. Rounding/linspace is to avoid float problems. end_time = np.round(end_time, 10) times = np.linspace(0, hop*int(np.floor(end_time/hop)), int(np.floor(end_time/hop)) + 1...
[ "Generates a time series from 0 to ``end_time`` with times spaced ``hop``\n apart\n\n Parameters\n ----------\n hop : float\n Spacing of samples in the time series\n end_time : float\n Time series will span ``[0, end_time]``\n\n Returns\n -------\n times : np.ndarray\n G...
Please provide a description of the function:def resample_melody_series(times, frequencies, voicing, times_new, kind='linear'): # If the timebases are already the same, no need to interpolate if times.shape == times_new.shape and np.allclose(times, times_new): return freq...
[ "Resamples frequency and voicing time series to a new timescale. Maintains\n any zero (\"unvoiced\") values in frequencies.\n\n If ``times`` and ``times_new`` are equivalent, no resampling will be\n performed.\n\n Parameters\n ----------\n times : np.ndarray\n Times of each frequency value\...
Please provide a description of the function:def to_cent_voicing(ref_time, ref_freq, est_time, est_freq, base_frequency=10., hop=None, kind='linear'): # Check if missing sample at time 0 and if so add one if ref_time[0] > 0: ref_time = np.insert(ref_time, 0, 0) ref_freq ...
[ "Converts reference and estimated time/frequency (Hz) annotations to sampled\n frequency (cent)/voicing arrays.\n\n A zero frequency indicates \"unvoiced\".\n\n A negative frequency indicates \"Predicted as unvoiced, but if it's voiced,\n this is the frequency estimate\".\n\n Parameters\n --------...
Please provide a description of the function:def voicing_measures(ref_voicing, est_voicing): validate_voicing(ref_voicing, est_voicing) ref_voicing = ref_voicing.astype(bool) est_voicing = est_voicing.astype(bool) # When input arrays are empty, return 0 by special case if ref_voicing.size == 0 ...
[ "Compute the voicing recall and false alarm rates given two voicing\n indicator sequences, one as reference (truth) and the other as the estimate\n (prediction). The sequences must be of the same length.\n\n Examples\n --------\n >>> ref_time, ref_freq = mir_eval.io.load_time_series('ref.txt')\n ...
Please provide a description of the function:def raw_pitch_accuracy(ref_voicing, ref_cent, est_voicing, est_cent, cent_tolerance=50): validate_voicing(ref_voicing, est_voicing) validate(ref_voicing, ref_cent, est_voicing, est_cent) ref_voicing = ref_voicing.astype(bool) est_...
[ "Compute the raw pitch accuracy given two pitch (frequency) sequences in\n cents and matching voicing indicator sequences. The first pitch and voicing\n arrays are treated as the reference (truth), and the second two as the\n estimate (prediction). All 4 sequences must be of the same length.\n\n Exampl...
Please provide a description of the function:def raw_chroma_accuracy(ref_voicing, ref_cent, est_voicing, est_cent, cent_tolerance=50): validate_voicing(ref_voicing, est_voicing) validate(ref_voicing, ref_cent, est_voicing, est_cent) ref_voicing = ref_voicing.astype(bool) est...
[ "Compute the raw chroma accuracy given two pitch (frequency) sequences\n in cents and matching voicing indicator sequences. The first pitch and\n voicing arrays are treated as the reference (truth), and the second two as\n the estimate (prediction). All 4 sequences must be of the same length.\n\n\n Exa...
Please provide a description of the function:def overall_accuracy(ref_voicing, ref_cent, est_voicing, est_cent, cent_tolerance=50): validate_voicing(ref_voicing, est_voicing) validate(ref_voicing, ref_cent, est_voicing, est_cent) ref_voicing = ref_voicing.astype(bool) est_voici...
[ "Compute the overall accuracy given two pitch (frequency) sequences in cents\n and matching voicing indicator sequences. The first pitch and voicing\n arrays are treated as the reference (truth), and the second two as the\n estimate (prediction). All 4 sequences must be of the same length.\n\n Examples...
Please provide a description of the function:def evaluate(ref_time, ref_freq, est_time, est_freq, **kwargs): # Convert to reference/estimated voicing/frequency (cent) arrays (ref_voicing, ref_cent, est_voicing, est_cent) = util.filter_kwargs( to_cent_voicing, ref_time, ref_freq, est_time, est...
[ "Evaluate two melody (predominant f0) transcriptions, where the first is\n treated as the reference (ground truth) and the second as the estimate to\n be evaluated (prediction).\n\n Examples\n --------\n >>> ref_time, ref_freq = mir_eval.io.load_time_series('ref.txt')\n >>> est_time, est_freq = mi...
Please provide a description of the function:def validate_boundary(reference_intervals, estimated_intervals, trim): if trim: # If we're trimming, then we need at least 2 intervals min_size = 2 else: # If we're not trimming, then we only need one interval min_size = 1 i...
[ "Checks that the input annotations to a segment boundary estimation\n metric (i.e. one that only takes in segment intervals) look like valid\n segment times, and throws helpful errors if not.\n\n Parameters\n ----------\n reference_intervals : np.ndarray, shape=(n, 2)\n reference segment inter...
Please provide a description of the function:def validate_structure(reference_intervals, reference_labels, estimated_intervals, estimated_labels): for (intervals, labels) in [(reference_intervals, reference_labels), (estimated_intervals, estimated_labels)]...
[ "Checks that the input annotations to a structure estimation metric (i.e.\n one that takes in both segment boundaries and their labels) look like valid\n segment times and labels, and throws helpful errors if not.\n\n Parameters\n ----------\n reference_intervals : np.ndarray, shape=(n, 2)\n r...
Please provide a description of the function:def detection(reference_intervals, estimated_intervals, window=0.5, beta=1.0, trim=False): validate_boundary(reference_intervals, estimated_intervals, trim) # Convert intervals to boundaries reference_boundaries = util.intervals_to_boundaries...
[ "Boundary detection hit-rate.\n\n A hit is counted whenever an reference boundary is within ``window`` of a\n estimated boundary. Note that each boundary is matched at most once: this\n is achieved by computing the size of a maximal matching between reference\n and estimated boundary points, subject to...
Please provide a description of the function:def deviation(reference_intervals, estimated_intervals, trim=False): validate_boundary(reference_intervals, estimated_intervals, trim) # Convert intervals to boundaries reference_boundaries = util.intervals_to_boundaries(reference_intervals) estimated_...
[ "Compute the median deviations between reference\n and estimated boundary times.\n\n Examples\n --------\n >>> ref_intervals, _ = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> est_intervals, _ = mir_eval.io.load_labeled_intervals('est.lab')\n >>> r_to_e, e_to_r = mir_eval.boundary.deviation(...
Please provide a description of the function:def pairwise(reference_intervals, reference_labels, estimated_intervals, estimated_labels, frame_size=0.1, beta=1.0): validate_structure(reference_intervals, reference_labels, estimated_intervals, estimated_labels) ...
[ "Frame-clustering segmentation evaluation by pair-wise agreement.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> # Trim or pad the est...
Please provide a description of the function:def rand_index(reference_intervals, reference_labels, estimated_intervals, estimated_labels, frame_size=0.1, beta=1.0): validate_structure(reference_intervals, reference_labels, estimated_intervals, estimated_lab...
[ "(Non-adjusted) Rand index.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> # Trim or pad the estimate to match reference timing\n >...
Please provide a description of the function:def _contingency_matrix(reference_indices, estimated_indices): ref_classes, ref_class_idx = np.unique(reference_indices, return_inverse=True) est_classes, est_class_idx = np.unique(estimated_indices, ...
[ "Computes the contingency matrix of a true labeling vs an estimated one.\n\n Parameters\n ----------\n reference_indices : np.ndarray\n Array of reference indices\n estimated_indices : np.ndarray\n Array of estimated indices\n\n Returns\n -------\n contingency_matrix : np.ndarray\...
Please provide a description of the function:def _adjusted_rand_index(reference_indices, estimated_indices): n_samples = len(reference_indices) ref_classes = np.unique(reference_indices) est_classes = np.unique(estimated_indices) # Special limit cases: no clustering since the data is not split; ...
[ "Compute the Rand index, adjusted for change.\n\n Parameters\n ----------\n reference_indices : np.ndarray\n Array of reference indices\n estimated_indices : np.ndarray\n Array of estimated indices\n\n Returns\n -------\n ari : float\n Adjusted Rand index\n\n .. note:: B...
Please provide a description of the function:def ari(reference_intervals, reference_labels, estimated_intervals, estimated_labels, frame_size=0.1): validate_structure(reference_intervals, reference_labels, estimated_intervals, estimated_labels) # Check for empty anno...
[ "Adjusted Rand Index (ARI) for frame clustering segmentation evaluation.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> # Trim or pad ...
Please provide a description of the function:def _mutual_info_score(reference_indices, estimated_indices, contingency=None): if contingency is None: contingency = _contingency_matrix(reference_indices, estimated_indices).astype(float) contingency_sum = np.s...
[ "Compute the mutual information between two sequence labelings.\n\n Parameters\n ----------\n reference_indices : np.ndarray\n Array of reference indices\n estimated_indices : np.ndarray\n Array of estimated indices\n contingency : np.ndarray\n Pre-computed contingency matrix. I...
Please provide a description of the function:def _entropy(labels): if len(labels) == 0: return 1.0 label_idx = np.unique(labels, return_inverse=True)[1] pi = np.bincount(label_idx).astype(np.float) pi = pi[pi > 0] pi_sum = np.sum(pi) # log(a / b) should be calculated as log(a) - log...
[ "Calculates the entropy for a labeling.\n\n Parameters\n ----------\n labels : list-like\n List of labels.\n\n Returns\n -------\n entropy : float\n Entropy of the labeling.\n\n .. note:: Based on sklearn.metrics.cluster.entropy\n\n " ]
Please provide a description of the function:def _adjusted_mutual_info_score(reference_indices, estimated_indices): n_samples = len(reference_indices) ref_classes = np.unique(reference_indices) est_classes = np.unique(estimated_indices) # Special limit cases: no clustering since the data is not spl...
[ "Compute the mutual information between two sequence labelings, adjusted for\n chance.\n\n Parameters\n ----------\n reference_indices : np.ndarray\n Array of reference indices\n\n estimated_indices : np.ndarray\n Array of estimated indices\n\n Returns\n -------\n ami : float <...
Please provide a description of the function:def _normalized_mutual_info_score(reference_indices, estimated_indices): ref_classes = np.unique(reference_indices) est_classes = np.unique(estimated_indices) # Special limit cases: no clustering since the data is not split. # This is a perfect match hen...
[ "Compute the mutual information between two sequence labelings, adjusted for\n chance.\n\n Parameters\n ----------\n reference_indices : np.ndarray\n Array of reference indices\n\n estimated_indices : np.ndarray\n Array of estimated indices\n\n Returns\n -------\n nmi : float <...
Please provide a description of the function:def mutual_information(reference_intervals, reference_labels, estimated_intervals, estimated_labels, frame_size=0.1): validate_structure(reference_intervals, reference_labels, estimated_intervals, ...
[ "Frame-clustering segmentation: mutual information metrics.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> # Trim or pad the estimate ...
Please provide a description of the function:def nce(reference_intervals, reference_labels, estimated_intervals, estimated_labels, frame_size=0.1, beta=1.0, marginal=False): validate_structure(reference_intervals, reference_labels, estimated_intervals, estimated_labels) # C...
[ "Frame-clustering segmentation: normalized conditional entropy\n\n Computes cross-entropy of cluster assignment, normalized by the\n max-entropy.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_...
Please provide a description of the function:def vmeasure(reference_intervals, reference_labels, estimated_intervals, estimated_labels, frame_size=0.1, beta=1.0): return nce(reference_intervals, reference_labels, estimated_intervals, estimated_labels, frame_size=fram...
[ "Frame-clustering segmentation: v-measure\n\n Computes cross-entropy of cluster assignment, normalized by the\n marginal-entropy.\n\n This is equivalent to `nce(..., marginal=True)`.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')...
Please provide a description of the function:def evaluate(ref_intervals, ref_labels, est_intervals, est_labels, **kwargs): # Adjust timespan of estimations relative to ground truth ref_intervals, ref_labels = \ util.adjust_intervals(ref_intervals, labels=ref_labels, t_min=0.0) est_intervals, ...
[ "Compute all metrics for the given reference and estimated annotations.\n\n Examples\n --------\n >>> (ref_intervals,\n ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab')\n >>> (est_intervals,\n ... est_labels) = mir_eval.io.load_labeled_intervals('est.lab')\n >>> scores = mir_ev...
Please provide a description of the function:def validate_tempi(tempi, reference=True): if tempi.size != 2: raise ValueError('tempi must have exactly two values') if not np.all(np.isfinite(tempi)) or np.any(tempi < 0): raise ValueError('tempi={} must be non-negative numbers'.format(tempi)...
[ "Checks that there are two non-negative tempi.\n For a reference value, at least one tempo has to be greater than zero.\n\n Parameters\n ----------\n tempi : np.ndarray\n length-2 array of tempo, in bpm\n\n reference : bool\n indicates a reference value\n\n " ]
Please provide a description of the function:def validate(reference_tempi, reference_weight, estimated_tempi): validate_tempi(reference_tempi, reference=True) validate_tempi(estimated_tempi, reference=False) if reference_weight < 0 or reference_weight > 1: raise ValueError('Reference weight mu...
[ "Checks that the input annotations to a metric look like valid tempo\n annotations.\n\n Parameters\n ----------\n reference_tempi : np.ndarray\n reference tempo values, in bpm\n\n reference_weight : float\n perceptual weight of slow vs fast in reference\n\n estimated_tempi : np.ndarr...
Please provide a description of the function:def detection(reference_tempi, reference_weight, estimated_tempi, tol=0.08): validate(reference_tempi, reference_weight, estimated_tempi) if tol < 0 or tol > 1: raise ValueError('invalid tolerance {}: must lie in the range ' '[...
[ "Compute the tempo detection accuracy metric.\n\n Parameters\n ----------\n reference_tempi : np.ndarray, shape=(2,)\n Two non-negative reference tempi\n\n reference_weight : float > 0\n The relative strength of ``reference_tempi[0]`` vs\n ``reference_tempi[1]``.\n\n estimated_te...
Please provide a description of the function:def evaluate(reference_tempi, reference_weight, estimated_tempi, **kwargs): # Compute all metrics scores = collections.OrderedDict() (scores['P-score'], scores['One-correct'], scores['Both-correct']) = util.filter_kwargs(detection, reference_tempi...
[ "Compute all metrics for the given reference and estimated annotations.\n\n Parameters\n ----------\n reference_tempi : np.ndarray, shape=(2,)\n Two non-negative reference tempi\n\n reference_weight : float > 0\n The relative strength of ``reference_tempi[0]`` vs\n ``reference_tempi...
Please provide a description of the function:def validate(ref_time, ref_freqs, est_time, est_freqs): util.validate_events(ref_time, max_time=MAX_TIME) util.validate_events(est_time, max_time=MAX_TIME) if ref_time.size == 0: warnings.warn("Reference times are empty.") if ref_time.ndim != 1...
[ "Checks that the time and frequency inputs are well-formed.\n\n Parameters\n ----------\n ref_time : np.ndarray\n reference time stamps in seconds\n ref_freqs : list of np.ndarray\n reference frequencies in Hz\n est_time : np.ndarray\n estimate time stamps in seconds\n est_fre...
Please provide a description of the function:def resample_multipitch(times, frequencies, target_times): if target_times.size == 0: return [] if times.size == 0: return [np.array([])]*len(target_times) n_times = len(frequencies) # scipy's interpolate doesn't handle ragged arrays. ...
[ "Resamples multipitch time series to a new timescale. Values in\n ``target_times`` outside the range of ``times`` return no pitch estimate.\n\n Parameters\n ----------\n times : np.ndarray\n Array of time stamps\n frequencies : list of np.ndarray\n List of np.ndarrays of frequency value...
Please provide a description of the function:def compute_num_true_positives(ref_freqs, est_freqs, window=0.5, chroma=False): n_frames = len(ref_freqs) true_positives = np.zeros((n_frames, )) for i, (ref_frame, est_frame) in enumerate(zip(ref_freqs, est_freqs)): if chroma: # match c...
[ "Compute the number of true positives in an estimate given a reference.\n A frequency is correct if it is within a quartertone of the\n correct frequency.\n\n Parameters\n ----------\n ref_freqs : list of np.ndarray\n reference frequencies (MIDI)\n est_freqs : list of np.ndarray\n es...
Please provide a description of the function:def compute_accuracy(true_positives, n_ref, n_est): true_positive_sum = float(true_positives.sum()) n_est_sum = n_est.sum() if n_est_sum > 0: precision = true_positive_sum/n_est.sum() else: warnings.warn("Estimate frequencies are all emp...
[ "Compute accuracy metrics.\n\n Parameters\n ----------\n true_positives : np.ndarray\n Array containing the number of true positives at each time point.\n n_ref : np.ndarray\n Array containing the number of reference frequencies at each time\n point.\n n_est : np.ndarray\n ...
Please provide a description of the function:def compute_err_score(true_positives, n_ref, n_est): n_ref_sum = float(n_ref.sum()) if n_ref_sum == 0: warnings.warn("Reference frequencies are all empty.") return 0., 0., 0., 0. # Substitution error e_sub = (np.min([n_ref, n_est], axis...
[ "Compute error score metrics.\n\n Parameters\n ----------\n true_positives : np.ndarray\n Array containing the number of true positives at each time point.\n n_ref : np.ndarray\n Array containing the number of reference frequencies at each time\n point.\n n_est : np.ndarray\n ...
Please provide a description of the function:def metrics(ref_time, ref_freqs, est_time, est_freqs, **kwargs): validate(ref_time, ref_freqs, est_time, est_freqs) # resample est_freqs if est_times is different from ref_times if est_time.size != ref_time.size or not np.allclose(est_time, ref_time): ...
[ "Compute multipitch metrics. All metrics are computed at the 'macro' level\n such that the frame true positive/false positive/false negative rates are\n summed across time and the metrics are computed on the combined values.\n\n Examples\n --------\n >>> ref_time, ref_freqs = mir_eval.io.load_ragged_...
Please provide a description of the function:def evaluate(ref_time, ref_freqs, est_time, est_freqs, **kwargs): scores = collections.OrderedDict() (scores['Precision'], scores['Recall'], scores['Accuracy'], scores['Substitution Error'], scores['Miss Error'], scores['False Alarm Err...
[ "Evaluate two multipitch (multi-f0) transcriptions, where the first is\n treated as the reference (ground truth) and the second as the estimate to\n be evaluated (prediction).\n\n Examples\n --------\n >>> ref_time, ref_freq = mir_eval.io.load_ragged_time_series('ref.txt')\n >>> est_time, est_freq...