prediction function code in python