def cross_validate(features, labels):
 error = 0.0
 for fold in range(10):
  training = np.ones(len(features), bool)
  training[fold::10] = 0
  testing = (~ training)
  model = fit_model(1, features[training], labels[training])
  test_error = accuracy(features[testing], labels[testing], model)
  error += test_error
 return (error / 10.0)

def cross_validate ( features , labels ) : error = 0.0 for fold in range ( 10 ) : training = np . ones ( len ( features ) , bool ) training [ fold : : 10 ] = 0 testing = ( ~ training ) model = fit_model ( 1 , features [ training ] , labels [ training ] ) test_error = accuracy ( features [ testing ] , labels [ testing ] , model ) error += test_error return ( error / 10.0 )
compute cross-validation errors .