Modified version of adpredictor Python implementation