<s> import numpy as np <EOL> def capped_log10_likelihood ( actual , predicted ) : <EOL> """<STR_LIT>""" <EOL> actual = np . array ( actual ) <EOL> predicted = np . array ( predicted ) <EOL> predicted [ predicted < <NUM_LIT> ] = <NUM_LIT> <EOL> predicted [ predicted > <NUM_LIT> ] = <NUM_LIT> <EOL> score = - ( actual * np . log10 ( predicted ) + ( <NUM_LIT:1> - actual ) * np . log10 ( <NUM_LIT:1> - predicted ) ) <EOL> if type ( score ) == np . ndarray : <EOL> score [ np . isnan ( score ) ] = <NUM_LIT:0> <EOL> else : <EOL> if np . isnan ( score ) : <EOL> score = <NUM_LIT:0> <EOL> return score <EOL> def capped_binomial_deviance ( actual , predicted ) : <EOL> """<STR_LIT>""" <EOL> return np . mean ( capped_log10_likelihood ( actual , predicted ) ) </s>
