{"id":5998,"library":"mir-eval","title":"mir_eval: Music Information Retrieval Evaluation","description":"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.","status":"active","version":"0.8.2","language":"en","source_language":"en","source_url":"https://github.com/mir-evaluation/mir_eval","tags":["audio","music","information retrieval","evaluation","metrics","signal processing","numpy","scipy"],"install":[{"cmd":"pip install mir-eval","lang":"bash","label":"Install latest stable version"}],"dependencies":[{"reason":"Fundamental numerical computing library for array operations.","package":"numpy","optional":false},{"reason":"Scientific computing tools, often used in signal processing and numerical algorithms.","package":"scipy","optional":false},{"reason":"Machine learning utilities, particularly for clustering or classification tasks used in some metrics.","package":"scikit-learn","optional":false}],"imports":[{"note":"The primary import for accessing submodules and evaluation functions.","symbol":"mir_eval","correct":"import mir_eval"},{"note":"Commonly imported submodule for beat tracking evaluation.","symbol":"mir_eval.beat","correct":"import mir_eval.beat"},{"note":"While direct import `from mir_eval.onset import evaluate` works, it's generally recommended to import the submodule `onset` and call `onset.evaluate` for consistency and clarity, especially when multiple metrics from the same submodule might be used.","wrong":"from mir_eval.onset import evaluate\nscores = evaluate(reference_onsets, estimated_onsets)","symbol":"mir_eval.onset.evaluate","correct":"from mir_eval import onset\nscores = onset.evaluate(reference_onsets, estimated_onsets)"}],"quickstart":{"code":"import numpy as np\nimport mir_eval.beat\n\n# Reference beat times (ground truth)\nreference_beats = np.array([0.5, 1.0, 1.5, 2.0, 2.5, 3.0])\n\n# Estimated beat times from an algorithm\nestimated_beats = np.array([0.51, 1.02, 1.48, 2.03, 2.55, 3.01])\n\n# Calculate F-measure for beat tracking\nf_measure = mir_eval.beat.f_measure(reference_beats, estimated_beats)\n\n# Calculate other beat metrics\nalternate_accuracy = mir_eval.beat.alternate_period_accuracy(reference_beats, estimated_beats)\ncml_t = mir_eval.beat.cemgil_metric(reference_beats, estimated_beats)\n\nprint(f\"Beat F-measure: {f_measure:.4f}\")\nprint(f\"Alternate Period Accuracy: {alternate_accuracy:.4f}\")\nprint(f\"Cemgil Metric (T): {cml_t:.4f}\")","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade `mir_eval` to version 0.8.0 or newer. If you are stuck on an older `mir_eval` version, you may need to downgrade NumPy to <1.24. Otherwise, update your custom code to use Python built-in types (`int`, `float`) or specific NumPy dtypes (e.g., `np.int64`, `np.float64`) instead of the deprecated aliases.","message":"Older versions of `mir_eval` (pre-0.8.0) used deprecated NumPy type aliases like `np.int` and `np.float`. These aliases were deprecated in NumPy 1.20 and removed entirely in NumPy 1.24+ and NumPy 2.0+.","severity":"breaking","affected_versions":"<0.8.0"},{"fix":"Review any operations where `mir_eval` outputs are combined with other NumPy arrays or Python scalars, especially if precision is critical. Explicitly cast to desired dtypes (e.g., `np.float64`) or convert to Python scalars (`int()`, `float()`) before operations to ensure consistent behavior.","message":"NumPy 2.0 introduced significant changes to its numeric promotion rules, which can affect the precision of results when combining scalars of different types (e.g., `float32` with Python `float`). This could lead to unexpected lower precision or integer overflows in some edge cases.","severity":"gotcha","affected_versions":"All versions when used with NumPy 2.0+"},{"fix":"Ensure `mir_eval` and `matplotlib` versions are reasonably aligned. For best compatibility, use `mir_eval` 0.5 or newer with `matplotlib` 2.0 or newer. If issues persist, check the `mir_eval` documentation for specific `matplotlib` version requirements if you rely heavily on `mir_eval.display`.","message":"The `mir_eval.display` submodule, used for plotting, has had compatibility updates (e.g., in version 0.5, it updated to use Matplotlib 2). Using older `mir_eval` versions with newer Matplotlib or vice versa might lead to plotting errors or unexpected visual outputs.","severity":"gotcha","affected_versions":"<0.5"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}