def benchmark_influence(conf):
 prediction_times = []
 prediction_powers = []
 complexities = []
 for param_value in conf['changing_param_values']:
  conf['tuned_params'][conf['changing_param']] = param_value
  estimator = conf['estimator'](**conf['tuned_params'])
  print ('Benchmarking %s' % estimator)
  estimator.fit(conf['data']['X_train'], conf['data']['y_train'])
  conf['postfit_hook'](estimator)
  complexity = conf['complexity_computer'](estimator)
  complexities.append(complexity)
  start_time = time.time()
  for _ in range(conf['n_samples']):
   y_pred = estimator.predict(conf['data']['X_test'])
  elapsed_time = ((time.time() - start_time) / float(conf['n_samples']))
  prediction_times.append(elapsed_time)
  pred_score = conf['prediction_performance_computer'](conf['data']['y_test'], y_pred)
  prediction_powers.append(pred_score)
  print ('Complexity: %d | %s: %.4f | Pred. Time: %fs\n' % (complexity, conf['prediction_performance_label'], pred_score, elapsed_time))
 return (prediction_powers, prediction_times, complexities)

def benchmark_influence ( conf ) : prediction_times = [ ] prediction_powers = [ ] complexities = [ ] for param_value in conf [ 'changing_param_values' ] : conf [ 'tuned_params' ] [ conf [ 'changing_param' ] ] = param_value estimator = conf [ 'estimator' ] ( ** conf [ 'tuned_params' ] ) print ( 'Benchmarking %s' % estimator ) estimator . fit ( conf [ 'data' ] [ 'X_train' ] , conf [ 'data' ] [ 'y_train' ] ) conf [ 'postfit_hook' ] ( estimator ) complexity = conf [ 'complexity_computer' ] ( estimator ) complexities . append ( complexity ) start_time = time . time ( ) for _ in range ( conf [ 'n_samples' ] ) : y_pred = estimator . predict ( conf [ 'data' ] [ 'X_test' ] ) elapsed_time = ( ( time . time ( ) - start_time ) / float ( conf [ 'n_samples' ] ) ) prediction_times . append ( elapsed_time ) pred_score = conf [ 'prediction_performance_computer' ] ( conf [ 'data' ] [ 'y_test' ] , y_pred ) prediction_powers . append ( pred_score ) print ( 'Complexity: %d | %s: %.4f | Pred. Time: %fs\n' % ( complexity , conf [ 'prediction_performance_label' ] , pred_score , elapsed_time ) ) return ( prediction_powers , prediction_times , complexities )
benchmark influence of :changing_param: on both mse and latency .