code: def test_baseline(art_warning, get_iris_dataset, model_type):
      try:
          attack_feature = 2  # petal length
  
          # need to transform attacked feature into categorical
          def transform_feature(x):
              x[x > 0.5] = 2.0
              x[(x > 0.2) & (x <= 0.5)] = 1.0
              x[x <= 0.2] = 0.0
  
          values = [0.0, 1.0, 2.0]
  
          (x_train_iris, y_train_iris), (
              x_test_iris,
              y_test_iris,
          ) = get_iris_dataset
  
          # training data without attacked feature
          x_train_for_attack = np.delete(
              x_train_iris, attack_feature, 1
          )
          # only attacked feature
          x_train_feature = (
              x_train_iris[:, attack_feature].copy().reshape(-1, 1)
          )
          transform_feature(x_train_feature)
          # training data with attacked feature (after transformation)
          x_train = np.concatenate(
              (x_train_for_attack[:, :attack_feature], x_train_feature),
              axis=1,
          )
          x_train = np.concatenate(
              (x_train, x_train_for_attack[:, attack_feature:]), axis=1
          )
  
          # test data without attacked feature
          x_test_for_attack = np.delete(x_test_iris, attack_feature, 1)
          # only attacked feature
          x_test_feature = (
              x_test_iris[:, attack_feature].copy().reshape(-1, 1)
          )
          transform_feature(x_test_feature)
  
          baseline_attack = AttributeInferenceBaseline(
              attack_feature=attack_feature,
              attack_model_type=model_type,
          )
          # train attack model
          baseline_attack.fit(x_train)
          # infer attacked feature
          baseline_inferred_train = baseline_attack.infer(
              x_train_for_attack, values=values
          )
          baseline_inferred_test = baseline_attack.infer(
              x_test_for_attack, values=values
          )
          # check accuracy
          baseline_train_acc = np.sum(
              baseline_inferred_train == x_train_feature.reshape(1, -1)
          ) / len(baseline_inferred_train)
          baseline_test_acc = np.sum(
              baseline_inferred_test == x_test_feature.reshape(1, -1)
          ) / len(baseline_inferred_test)
  
          expected_train_acc = {
              "nn": 0.58,
              "rf": 0.98,
              "gb": 0.98,
              "lr": 0.77,
              "dt": 0.98,
              "knn": 0.86,
              "svm": 0.83,
          }
          expected_test_acc = {
              "nn": 0.62,
              "rf": 0.86,
              "gb": 0.82,
              "lr": 0.86,
              "dt": 0.84,
              "knn": 0.82,
              "svm": 0.93,
          }
  
          assert expected_train_acc[model_type] <= baseline_train_acc
          assert expected_test_acc[model_type] <= baseline_test_acc
  
      except ARTTestException as e:
          art_warning(e)
  
file_path: adversarial-robustness-toolbox/tests/attacks/inference/attribute_inference/test_baseline.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import pytest
  import numpy
  from sklearn.compose import ColumnTransformer
  from sklearn.preprocessing import OrdinalEncoder
  from art.attacks.inference.attribute_inference.baseline import AttributeInferenceBaseline
  from art.utils import check_and_transform_label_format
  from tests.utils import ARTTestException
label_desc: Use image node_id 1 for calling a global function with example usage: test_baseline(art_warning, get_iris_dataset, model_type) without return types