A generic prediction algorithm