Maximum-likelihood  general sequence classifier