mir_eval: Music Information Retrieval Evaluation

0.8.2 · active · verified Tue Apr 14

mir_eval is a Python library providing a transparent, standardized, and straightforward way to evaluate Music Information Retrieval (MIR) systems. It includes common metrics for tasks such as beat detection, chord estimation, melody extraction, and onset detection. The library is actively maintained, with the current version being 0.8.2, and sees regular updates to ensure compatibility and introduce minor enhancements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to compute beat tracking evaluation metrics using `mir_eval.beat`. It initializes synthetic reference and estimated beat times and then calculates common metrics like F-measure, alternate period accuracy, and the Cemgil metric.

import numpy as np
import mir_eval.beat

# Reference beat times (ground truth)
reference_beats = np.array([0.5, 1.0, 1.5, 2.0, 2.5, 3.0])

# Estimated beat times from an algorithm
estimated_beats = np.array([0.51, 1.02, 1.48, 2.03, 2.55, 3.01])

# Calculate F-measure for beat tracking
f_measure = mir_eval.beat.f_measure(reference_beats, estimated_beats)

# Calculate other beat metrics
alternate_accuracy = mir_eval.beat.alternate_period_accuracy(reference_beats, estimated_beats)
cml_t = mir_eval.beat.cemgil_metric(reference_beats, estimated_beats)

print(f"Beat F-measure: {f_measure:.4f}")
print(f"Alternate Period Accuracy: {alternate_accuracy:.4f}")
print(f"Cemgil Metric (T): {cml_t:.4f}")

view raw JSON →