nodes: 0, module; 1, function_definition; 2, function_name:runtime; 3, parameters; 4, block; 5, identifier:X; 6, identifier:y; 7, identifier:model_generator; 8, identifier:method_name; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, comment:# average the method scores over several train/test splits; 13, expression_statement; 14, for_statement; 15, expression_statement; 16, return_statement; 17, comment:""" Runtime
      transform = "negate"
      sort_order = 1
      """; 18, assignment; 19, call; 20, assignment; 21, identifier:i; 22, call; 23, block; 24, call; 25, expression_list; 26, identifier:old_seed; 27, call; 28, attribute; 29, argument_list; 30, identifier:method_reps; 31, list; 32, identifier:range; 33, argument_list; 34, expression_statement; 35, comment:# define the model we are going to explain; 36, expression_statement; 37, expression_statement; 38, comment:# evaluate each method; 39, expression_statement; 40, expression_statement; 41, expression_statement; 42, expression_statement; 43, expression_statement; 44, expression_statement; 45, comment:# we always normalize the explain time as though we were explaining 1000 samples; 46, comment:# even if to reduce the runtime of the benchmark we do less (like just 100); 47, expression_statement; 48, attribute; 49, argument_list; 50, None; 51, call; 52, attribute; 53, argument_list; 54, attribute; 55, identifier:seed; 56, integer:3293; 57, integer:1; 58, assignment; 59, assignment; 60, call; 61, assignment; 62, assignment; 63, assignment; 64, assignment; 65, call; 66, assignment; 67, call; 68, attribute; 69, identifier:seed; 70, identifier:old_seed; 71, attribute; 72, argument_list; 73, attribute; 74, identifier:seed; 75, identifier:np; 76, identifier:random; 77, pattern_list; 78, call; 79, identifier:model; 80, call; 81, attribute; 82, argument_list; 83, identifier:start; 84, call; 85, identifier:explainer; 86, call; 87, identifier:build_time; 88, binary_operator:time.time() - start; 89, identifier:start; 90, call; 91, identifier:explainer; 92, argument_list; 93, identifier:explain_time; 94, binary_operator:time.time() - start; 95, attribute; 96, argument_list; 97, identifier:np; 98, identifier:random; 99, identifier:np; 100, identifier:mean; 101, identifier:method_reps; 102, identifier:np; 103, identifier:random; 104, identifier:X_train; 105, identifier:X_test; 106, identifier:y_train; 107, identifier:_; 108, identifier:train_test_split; 109, argument_list; 110, identifier:model_generator; 111, argument_list; 112, identifier:model; 113, identifier:fit; 114, identifier:X_train; 115, identifier:y_train; 116, attribute; 117, argument_list; 118, call; 119, argument_list; 120, call; 121, identifier:start; 122, attribute; 123, argument_list; 124, identifier:X_test; 125, call; 126, identifier:start; 127, identifier:method_reps; 128, identifier:append; 129, binary_operator:build_time + explain_time * 1000.0 / X_test.shape[0]; 130, call; 131, identifier:y; 132, keyword_argument; 133, keyword_argument; 134, identifier:time; 135, identifier:time; 136, identifier:getattr; 137, argument_list; 138, identifier:model; 139, identifier:X_train; 140, attribute; 141, argument_list; 142, identifier:time; 143, identifier:time; 144, attribute; 145, argument_list; 146, identifier:build_time; 147, binary_operator:explain_time * 1000.0 / X_test.shape[0]; 148, identifier:__toarray; 149, argument_list; 150, identifier:test_size; 151, integer:100; 152, identifier:random_state; 153, identifier:i; 154, identifier:methods; 155, identifier:method_name; 156, identifier:time; 157, identifier:time; 158, identifier:time; 159, identifier:time; 160, binary_operator:explain_time * 1000.0; 161, subscript; 162, identifier:X; 163, identifier:explain_time; 164, float:1000.0; 165, attribute; 166, integer:0; 167, identifier:X_test; 168, identifier:shape
code: def runtime(X, y, model_generator, method_name):
      """ Runtime
      transform = "negate"
      sort_order = 1
      """
  
      old_seed = np.random.seed()
      np.random.seed(3293)
  
      # average the method scores over several train/test splits
      method_reps = []
      for i in range(1):
          X_train, X_test, y_train, _ = train_test_split(__toarray(X), y, test_size=100, random_state=i)
  
          # define the model we are going to explain
          model = model_generator()
          model.fit(X_train, y_train)
  
          # evaluate each method
          start = time.time()
          explainer = getattr(methods, method_name)(model, X_train)
          build_time = time.time() - start
  
          start = time.time()
          explainer(X_test)
          explain_time = time.time() - start
  
          # we always normalize the explain time as though we were explaining 1000 samples
          # even if to reduce the runtime of the benchmark we do less (like just 100)
          method_reps.append(build_time + explain_time * 1000.0 / X_test.shape[0])
      np.random.seed(old_seed)
  
      return None, np.mean(method_reps)