code: def correlation_ratio(
      categories,
      measurements,
      nan_strategy=REPLACE,
      nan_replace_value=DEFAULT_REPLACE_VALUE,
  ):
      """
      Calculates the Correlation Ratio (sometimes marked by the greek letter Eta)
      for categorical-continuous association.
  
      Answers the question - given a continuous value of a measurement, is it
      possible to know which category is it associated with?
  
      Value is in the range [0,1], where 0 means a category cannot be determined
      by a continuous measurement, and 1 means a category can be determined with
      absolute certainty.
  
      Wikipedia: https://en.wikipedia.org/wiki/Correlation_ratio
  
      **Returns:** float in the range of [0,1]
  
      Parameters
      ----------
      categories : list / NumPy ndarray / Pandas Series
          A sequence of categorical measurements
      measurements : list / NumPy ndarray / Pandas Series
          A sequence of continuous measurements
      nan_strategy : string, default = 'replace'
          How to handle missing values: can be either 'drop' to remove samples
          with missing values, or 'replace' to replace all missing values with
          the nan_replace_value. Missing values are None and np.nan.
      nan_replace_value : any, default = 0.0
          The value used to replace missing values with. Only applicable when
          nan_strategy is set to 'replace'.
      """
      if nan_strategy == REPLACE:
          categories, measurements = replace_nan_with_value(
              categories, measurements, nan_replace_value
          )
      elif nan_strategy == DROP:
          categories, measurements = remove_incomplete_samples(
              categories, measurements
          )
      categories = convert(categories, "array")
      measurements = convert(measurements, "array")
      fcat, _ = pd.factorize(categories)
      cat_num = np.max(fcat) + 1
      y_avg_array = np.zeros(cat_num)
      n_array = np.zeros(cat_num)
      for i in range(0, cat_num):
          cat_measures = measurements[np.argwhere(fcat == i).flatten()]
          n_array[i] = len(cat_measures)
          y_avg_array[i] = np.average(cat_measures)
      y_total_avg = np.sum(np.multiply(y_avg_array, n_array)) / np.sum(
          n_array
      )
      numerator = np.sum(
          np.multiply(
              n_array,
              np.power(np.subtract(y_avg_array, y_total_avg), 2),
          )
      )
      denominator = np.sum(
          np.power(np.subtract(measurements, y_total_avg), 2)
      )
      if numerator == 0:
          eta = 0.0
      else:
          eta = np.sqrt(numerator / denominator)
      return eta
  
file_path: sweetviz/sweetviz/from_dython.py
imports: import numpy
  import pandas
  from collections import Counter
  import math
  import scipy.stats
label_desc: Use image node_id 6 for calling a global function with example usage: correlation_ratio(categories, measurements, nan_strategy, nan_replace_value) and returns: eta