def _train_iis(xs, classes, features, f_sharp, alphas, e_empirical, max_newton_iterations, newton_converge):
 p_yx = _calc_p_class_given_x(xs, classes, features, alphas)
 N = len(xs)
 newalphas = alphas[:]
 for i in range(len(alphas)):
  delta = _iis_solve_delta(N, features[i], f_sharp, e_empirical[i], p_yx, max_newton_iterations, newton_converge)
  newalphas[i] += delta
 return newalphas

def _train_iis ( xs , classes , features , f_sharp , alphas , e_empirical , max_newton_iterations , newton_converge ) : p_yx = _calc_p_class_given_x ( xs , classes , features , alphas ) N = len ( xs ) newalphas = alphas [ : ] for i in range ( len ( alphas ) ) : delta = _iis_solve_delta ( N , features [ i ] , f_sharp , e_empirical [ i ] , p_yx , max_newton_iterations , newton_converge ) newalphas [ i ] += delta return newalphas
do one iteration of hill climbing to find better alphas .