Unified approach to data-driven quantum error mitigation