code: def test_target_categorizer():
      input_df_train_binary_target = pd.DataFrame(
          {
              "feat1_num": [1, 0.5, nan, 100, 10, 0.7],
              "feat2_cat": ["a", "a", "a", "b", "c", "c"],
              "feat3_cat": ["c", "c", "c", "a", "a", "a"],
              "target": [1, 0, 0, 1, 0, 1],
          }
      )
  
      expected_output_train_binary_target = pd.DataFrame(
          OrderedDict(
              (
                  ("feat1_num", [1, 0.5, nan, 100, 10, 0.7]),
                  ("feat2_cat", [0.375, 0.375, 0.375, 0.75, 0.5, 0.5]),
                  (
                      "feat3_cat",
                      [0.375, 0.375, 0.375, 0.625, 0.625, 0.625],
                  ),
                  ("target", [1, 0, 0, 1, 0, 1]),
              )
          )
      )
  
      input_df_test_binary_target = pd.DataFrame(
          {
              "feat1_num": [2.0, 4.0, 8.0],
              "feat2_cat": ["b", "a", "c"],
              "feat3_cat": ["c", "b", "a"],
          }
      )
  
      expected_output_test_binary_target = pd.DataFrame(
          OrderedDict(
              (
                  ("feat1_num", [2.0, 4.0, 8.0]),
                  ("feat2_cat", [0.75, 0.375, 0.5]),
                  ("feat3_cat", [0.375, nan, 0.625]),
              )
          )
      )
  
      input_df_train_continuous_target = pd.DataFrame(
          {
              "feat1_num": [1, 0.5, nan, 100, 10, 0.7],
              "feat2_cat": ["a", "a", "a", nan, "c", "c"],
              "target": [41.0, 10.5, 23.0, 4.0, 5.5, 60.0],
          }
      )
  
      expected_output_train_continuous_target = pd.DataFrame(
          OrderedDict(
              (
                  ("feat1_num", [1, 0.5, nan, 100, 10, 0.7]),
                  (
                      "feat2_cat",
                      [24.625, 24.625, 24.625, nan, 29.83333, 29.83333],
                  ),
                  ("target", [41.0, 10.5, 23.0, 4.0, 5.5, 60.0]),
              )
          )
      )
  
      input_df_test_continuous_target = pd.DataFrame(
          {"feat1_num": [2.0, 4.0, 8.0], "feat2_cat": ["b", "a", "c"]}
      )
  
      expected_output_test_continuous_target = pd.DataFrame(
          OrderedDict(
              (
                  ("feat1_num", [2.0, 4.0, 8.0]),
                  ("feat2_cat", [24.0, 24.625, 29.83333]),
              )
          )
      )
  
      # Test with binary target
      categorizer_learner1 = target_categorizer(
          columns_to_categorize=["feat2_cat", "feat3_cat"],
          target_column="target",
      )
      categorizer_learner2 = target_categorizer(
          columns_to_categorize=["feat2_cat", "feat3_cat"],
          target_column="target",
          suffix="_suffix",
      )
      categorizer_learner3 = target_categorizer(
          columns_to_categorize=["feat2_cat", "feat3_cat"],
          target_column="target",
          prefix="prefix_",
      )
      categorizer_learner4 = target_categorizer(
          columns_to_categorize=["feat2_cat", "feat3_cat"],
          target_column="target",
          columns_mapping={
              "feat2_cat": "feat2_cat_raw",
              "feat3_cat": "feat3_cat_raw",
          },
      )
  
      pred_fn1, data1, log = categorizer_learner1(
          input_df_train_binary_target
      )
      pred_fn2, data2, log = categorizer_learner2(
          input_df_train_binary_target
      )
      pred_fn3, data3, log = categorizer_learner3(
          input_df_train_binary_target
      )
      pred_fn4, data4, log = categorizer_learner4(
          input_df_train_binary_target
      )
  
      assert expected_output_train_binary_target.equals(data1)
      assert expected_output_test_binary_target.equals(
          pred_fn1(input_df_test_binary_target)
      )
  
      categorized = ["feat2_cat", "feat3_cat"]
      assert pd.concat(
          [
              expected_output_train_binary_target,
              input_df_train_binary_target[categorized]
              .copy()
              .add_suffix("_suffix"),
          ],
          axis=1,
      ).equals(data2)
      assert pd.concat(
          [
              expected_output_test_binary_target,
              input_df_test_binary_target[categorized]
              .copy()
              .add_suffix("_suffix"),
          ],
          axis=1,
      ).equals(pred_fn2(input_df_test_binary_target))
  
      assert pd.concat(
          [
              expected_output_train_binary_target,
              input_df_train_binary_target[categorized]
              .copy()
              .add_prefix("prefix_"),
          ],
          axis=1,
      ).equals(data3)
      assert pd.concat(
          [
              expected_output_test_binary_target,
              input_df_test_binary_target[categorized]
              .copy()
              .add_prefix("prefix_"),
          ],
          axis=1,
      ).equals(pred_fn3(input_df_test_binary_target))
  
      assert pd.concat(
          [
              expected_output_train_binary_target,
              input_df_train_binary_target[categorized]
              .copy()
              .add_suffix("_raw"),
          ],
          axis=1,
      ).equals(data4)
      assert pd.concat(
          [
              expected_output_test_binary_target,
              input_df_test_binary_target[categorized]
              .copy()
              .add_suffix("_raw"),
          ],
          axis=1,
      ).equals(pred_fn4(input_df_test_binary_target))
  
      # Test with continuous target
      categorizer_learner1 = target_categorizer(
          columns_to_categorize=["feat2_cat"],
          ignore_unseen=False,
          target_column="target",
      )
      categorizer_learner2 = target_categorizer(
          columns_to_categorize=["feat2_cat"],
          ignore_unseen=False,
          target_column="target",
          suffix="_suffix",
      )
      categorizer_learner3 = target_categorizer(
          columns_to_categorize=["feat2_cat"],
          ignore_unseen=False,
          target_column="target",
          prefix="prefix_",
      )
      categorizer_learner4 = target_categorizer(
          columns_to_categorize=["feat2_cat"],
          ignore_unseen=False,
          target_column="target",
          columns_mapping={"feat2_cat": "feat2_cat_raw"},
      )
  
      pred_fn1, data1, log = categorizer_learner1(
          input_df_train_continuous_target
      )
      pred_fn2, data2, log = categorizer_learner2(
          input_df_train_continuous_target
      )
      pred_fn3, data3, log = categorizer_learner3(
          input_df_train_continuous_target
      )
      pred_fn4, data4, log = categorizer_learner4(
          input_df_train_continuous_target
      )
  
      assert_almost_equal(
          expected_output_train_continuous_target.values,
          data1.values,
          decimal=5,
      )
      assert_almost_equal(
          expected_output_test_continuous_target.values,
          pred_fn1(input_df_test_continuous_target).values,
          decimal=5,
      )
  
      assert_almost_equal(
          expected_output_train_continuous_target.values,
          data2.drop(columns=["feat2_cat_suffix"]).values,
          decimal=5,
      )
      assert (
          input_df_train_continuous_target[["feat2_cat"]]
          .copy()
          .add_suffix("_suffix")
          .equals(data2[["feat2_cat_suffix"]])
      )
      assert_almost_equal(
          expected_output_test_continuous_target.values,
          pred_fn2(input_df_test_continuous_target)
          .drop(columns=["feat2_cat_suffix"])
          .values,
          decimal=5,
      )
      assert (
          input_df_test_continuous_target[["feat2_cat"]]
          .copy()
          .add_suffix("_suffix")
          .equals(
              pred_fn2(input_df_test_continuous_target)[
                  ["feat2_cat_suffix"]
              ]
          )
      )
  
      assert_almost_equal(
          expected_output_train_continuous_target.values,
          data3.drop(columns=["prefix_feat2_cat"]).values,
          decimal=5,
      )
      assert (
          input_df_train_continuous_target[["feat2_cat"]]
          .copy()
          .add_prefix("prefix_")
          .equals(data3[["prefix_feat2_cat"]])
      )
      assert_almost_equal(
          expected_output_test_continuous_target.values,
          pred_fn3(input_df_test_continuous_target)
          .drop(columns=["prefix_feat2_cat"])
          .values,
          decimal=5,
      )
      assert (
          input_df_test_continuous_target[["feat2_cat"]]
          .copy()
          .add_prefix("prefix_")
          .equals(
              pred_fn3(input_df_test_continuous_target)[
                  ["prefix_feat2_cat"]
              ]
          )
      )
  
      assert_almost_equal(
          expected_output_train_continuous_target.values,
          data4.drop(columns=["feat2_cat_raw"]).values,
          decimal=5,
      )
      assert (
          input_df_train_continuous_target[["feat2_cat"]]
          .copy()
          .rename(columns={"feat2_cat": "feat2_cat_raw"})
          .equals(data4[["feat2_cat_raw"]])
      )
      assert_almost_equal(
          expected_output_test_continuous_target.values,
          pred_fn4(input_df_test_continuous_target)
          .drop(columns=["feat2_cat_raw"])
          .values,
          decimal=5,
      )
      assert (
          input_df_test_continuous_target[["feat2_cat"]]
          .copy()
          .rename(columns={"feat2_cat": "feat2_cat_raw"})
          .equals(
              pred_fn4(input_df_test_continuous_target)[
                  ["feat2_cat_raw"]
              ]
          )
      )
  
imports: from collections import OrderedDict
  import math
  import pandas
  import pytest
  from numpy import nan, round, sqrt, floor, log
  from numpy.testing import assert_almost_equal
  from pandas.testing import assert_frame_equal
  from fklearn.training.transformation import selector, capper, floorer, prediction_ranger, count_categorizer, label_categorizer, quantile_biner, truncate_categorical, rank_categorical, onehot_categorizer, target_categorizer, standard_scaler, ecdfer, discrete_ecdfer, custom_transformer, value_mapper, null_injector, missing_warner
label_desc: Use image node_id 12 for calling a global function with example usage: test_target_categorizer() without return types