class_docstr: Confidence estimation block, uses inductive conformal predictors (ICPs) for model agnosticity 
class_docstr_tok: ["Confidence","estimation","block",",","uses","inductive","conformal","predictors","(","ICPs",")","for","model","agnosticity"]
code: def _formatted(row_insights, global_insights, ns, is_numerical):
      # clip if necessary
      if is_numerical:
          lower_limit = 0.0 if ns.positive_domain else -pow(2, 62)
          upper_limit = pow(2, 62)
          if not (ns.tss.is_timeseries and ns.tss.horizon > 1):
              row_insights["upper"] = row_insights["upper"].clip(
                  lower_limit, upper_limit
              )
              row_insights["lower"] = row_insights["lower"].clip(
                  lower_limit, upper_limit
              )
              row_insights["prediction"] = row_insights[
                  "prediction"
              ].clip(lower_limit, upper_limit)
          else:
              row_insights["upper"] = [
                  np.array(row).clip(lower_limit, upper_limit).tolist()
                  for row in row_insights["upper"]
              ]
              row_insights["lower"] = [
                  np.array(row).clip(lower_limit, upper_limit).tolist()
                  for row in row_insights["lower"]
              ]
              row_insights["prediction"] = [
                  np.array(row).clip(lower_limit, upper_limit).tolist()
                  for row in row_insights["prediction"]
              ]
  
      # Make sure the target and real values are of an appropriate type
      if ns.target_dtype in (dtype.integer,):
          row_insights["prediction"] = row_insights[
              "prediction"
          ].astype(int)
          row_insights["upper"] = row_insights["upper"].astype(int)
          row_insights["lower"] = row_insights["lower"].astype(int)
  
      elif ns.target_dtype in (dtype.float, dtype.quantity):
          row_insights["prediction"] = row_insights[
              "prediction"
          ].astype(float)
          row_insights["upper"] = row_insights["upper"].astype(float)
          row_insights["lower"] = row_insights["lower"].astype(float)
  
      elif ns.target_dtype in (
          dtype.short_text,
          dtype.rich_text,
          dtype.binary,
          dtype.categorical,
      ):
          row_insights["prediction"] = row_insights[
              "prediction"
          ].astype(str)
  
      # horizon collapse
      if ns.tss.is_timeseries and is_numerical and ns.tss.horizon > 1:
          row_insights["prediction_sum"] = row_insights[
              "prediction"
          ].apply(lambda x: sum(x))
          row_insights["lower_sum"] = row_insights["lower"].apply(
              lambda x: min(x)
          )
          row_insights["upper_sum"] = row_insights["upper"].apply(
              lambda x: max(x)
          )
          row_insights["confidence_mean"] = row_insights[
              "confidence"
          ].apply(lambda x: np.mean(x))
  
      return row_insights, global_insights
  
imports: import inspect
  from copy import deepcopy
  from typing import Dict, Tuple, Optional
  from types import SimpleNamespace
  import numpy
  import pandas
  from sklearn.preprocessing import OneHotEncoder
  from type_infer.dtype import dtype
  from lightwood.api.types import PredictionArguments
  from lightwood.helpers.ts import add_tn_num_conf_bounds, add_tn_cat_conf_bounds, get_ts_groups
  from lightwood.data import EncodedDs
  from lightwood.analysis.base import BaseAnalysisBlock
  from lightwood.analysis.nc.norm import Normalizer
  from lightwood.analysis.nc.icp import IcpRegressor, IcpClassifier, IcpTSRegressor
  from lightwood.analysis.nc.base import CachedRegressorAdapter, CachedClassifierAdapter, CachedTSAdapter
  from lightwood.analysis.nc.nc import BoostedAbsErrorErrFunc, RegressorNc, ClassifierNc, MarginErrFunc, TSNc, TSAbsErrorErrFunc
  from lightwood.analysis.nc.util import clean_df, set_conf_range, get_numeric_conf_range, get_categorical_conf, get_anomalies, get_ts_conf_range
label_desc: Use image node_id 4 for calling the ICP obj's underlying member method code with example usage: obj._formatted(row_insights, global_insights, ns, is_numerical) and returns: row_insights,  global_insights