Compact Markov-modulated models for multiclass trace fitting