code: def Transform_KM_Features(
      training_data, training_labels, test_data, km_max=0
  ):
      seed = 99
      preds = list(training_data)
      target = training_labels.name
      train_index = training_data.index
      test_index = test_data.index
      if km_max <= 2:
          k_max = 2
      else:
          k_max = copy.deepcopy(km_max)
      ### Calculate the target scale here => the higher the number the better for target accuracy
      try:
          if training_labels.dtype in [
              np.float64,
              np.float32,
              np.float16,
          ]:
              target_range = float(
                  abs(training_labels.max() - training_labels.min())
              )
          elif training_labels.dtype in [object, bool]:
              target_range = int(len(Counter(training_labels)) + 3)
          else:
              target_range = int(
                  abs(training_labels.max() - training_labels.min())
              )
      except:
          target_range = 5.0
      kmf = KMeansFeaturizer(
          k=k_max, target_scale=target_range, random_state=seed
      )
      kmf_hint = kmf.fit(training_data, training_labels)
      ### Just return it with the cluster column => no need to return the data frame ###
      training_cluster_features = kmf_hint.transform(training_data)
      test_cluster_features = kmf_hint.transform(test_data)
      npx = np.c_[training_data, training_labels.values]
      training_with_cluster = np.c_[npx, training_cluster_features]
      test_with_cluster = np.c_[test_data, test_cluster_features]
      ### We are going to just return the cluster values ######
      train_with_cluster_df = training_with_cluster[:, -1]
      test_with_cluster_df = test_with_cluster[:, -1]
      # train_with_cluster_df = pd.DataFrame(training_with_cluster,index=train_index,
      #                                  columns=preds+[target,'cluster'])
      # test_with_cluster_df = pd.DataFrame(test_with_cluster,index=test_index,
      #                                  columns=preds+['cluster'])
      return train_with_cluster_df, test_with_cluster_df
  
file_path: Auto_ViML/autoviml/Transform_KM_Features.py
imports: import numpy
  import pandas
  from sklearn.cluster import KMeans
  import sklearn
  import scipy
  from collections import defaultdict
  import operator
  import pdb
  import copy
  from sklearn.model_selection import train_test_split
label_desc: Use image node_id 1 for calling a global function with example usage: Transform_KM_Features(training_data, training_labels, test_data, km_max) and returns: train_with_cluster_df,  test_with_cluster_df