nodes: 0, module; 1, function_definition; 2, function_name:local_accuracy; 3, parameters; 4, block; 5, identifier:X; 6, identifier:y; 7, identifier:model_generator; 8, identifier:method_name; 9, expression_statement; 10, function_definition; 11, function_definition; 12, return_statement; 13, comment:""" Local Accuracy
      transform = "identity"
      sort_order = 2
      """; 14, function_name:score_map; 15, parameters; 16, block; 17, function_name:score_function; 18, parameters; 19, block; 20, expression_list; 21, identifier:true; 22, identifier:pred; 23, expression_statement; 24, expression_statement; 25, if_statement; 26, identifier:X_train; 27, identifier:X_test; 28, identifier:y_train; 29, identifier:y_test; 30, identifier:attr_function; 31, identifier:trained_model; 32, identifier:random_state; 33, return_statement; 34, None; 35, call; 36, comment:""" Converts local accuracy from % of standard deviation to numerical scores for coloring.
          """; 37, assignment; 38, comparison_operator:v < 1e-6; 39, block; 40, elif_clause; 41, elif_clause; 42, elif_clause; 43, elif_clause; 44, elif_clause; 45, elif_clause; 46, elif_clause; 47, else_clause; 48, call; 49, identifier:__score_method; 50, argument_list; 51, identifier:v; 52, call; 53, identifier:v; 54, float:1e-6; 55, return_statement; 56, comparison_operator:v < 0.01; 57, block; 58, comparison_operator:v < 0.05; 59, block; 60, comparison_operator:v < 0.1; 61, block; 62, comparison_operator:v < 0.2; 63, block; 64, comparison_operator:v < 0.3; 65, block; 66, comparison_operator:v < 0.5; 67, block; 68, comparison_operator:v < 0.7; 69, block; 70, block; 71, attribute; 72, argument_list; 73, identifier:X; 74, identifier:y; 75, None; 76, identifier:model_generator; 77, identifier:score_function; 78, identifier:method_name; 79, identifier:min; 80, argument_list; 81, float:1.0; 82, identifier:v; 83, float:0.01; 84, return_statement; 85, identifier:v; 86, float:0.05; 87, return_statement; 88, identifier:v; 89, float:0.1; 90, return_statement; 91, identifier:v; 92, float:0.2; 93, return_statement; 94, identifier:v; 95, float:0.3; 96, return_statement; 97, identifier:v; 98, float:0.5; 99, return_statement; 100, identifier:v; 101, float:0.7; 102, return_statement; 103, return_statement; 104, identifier:measures; 105, identifier:local_accuracy; 106, identifier:X_train; 107, identifier:y_train; 108, identifier:X_test; 109, identifier:y_test; 110, call; 111, identifier:model_generator; 112, identifier:score_map; 113, identifier:trained_model; 114, float:1.0; 115, binary_operator:np.std(pred - true) / (np.std(true) + 1e-8); 116, float:0.9; 117, float:0.75; 118, float:0.6; 119, float:0.4; 120, float:0.3; 121, float:0.2; 122, float:0.1; 123, float:0.0; 124, identifier:attr_function; 125, argument_list; 126, call; 127, parenthesized_expression; 128, identifier:X_test; 129, attribute; 130, argument_list; 131, binary_operator:np.std(true) + 1e-8; 132, identifier:np; 133, identifier:std; 134, binary_operator:pred - true; 135, call; 136, float:1e-8; 137, identifier:pred; 138, identifier:true; 139, attribute; 140, argument_list; 141, identifier:np; 142, identifier:std; 143, identifier:true
code: def local_accuracy(X, y, model_generator, method_name):
      """ Local Accuracy
      transform = "identity"
      sort_order = 2
      """
  
      def score_map(true, pred):
          """ Converts local accuracy from % of standard deviation to numerical scores for coloring.
          """
  
          v = min(1.0, np.std(pred - true) / (np.std(true) + 1e-8))
          if v < 1e-6:
              return 1.0
          elif v < 0.01:
              return 0.9
          elif v < 0.05:
              return 0.75
          elif v < 0.1:
              return 0.6
          elif v < 0.2:
              return 0.4
          elif v < 0.3:
              return 0.3
          elif v < 0.5:
              return 0.2
          elif v < 0.7:
              return 0.1
          else:
              return 0.0
      def score_function(X_train, X_test, y_train, y_test, attr_function, trained_model, random_state):
          return measures.local_accuracy(
              X_train, y_train, X_test, y_test, attr_function(X_test),
              model_generator, score_map, trained_model
          )
      return None, __score_method(X, y, None, model_generator, score_function, method_name)