class_docstr: Class to perform sensitivity analysis for partially linear model.
  
  An efficient version of the non parametric sensitivity analyzer that works for estimators that return residuals of regression from confounders on treatment and outcome, such as the DML method. For all other methods (or when the partially linear assumption is not guaranteed to be satisfied), use the non-parametric sensitivity analysis.
  
  Based on this work:
      Chernozhukov, V., Cinelli, C., Newey, W., Sharma, A., & Syrgkanis, V. (2022). Long Story Short: Omitted Variable Bias in Causal Machine Learning (No. w30302). National Bureau of Economic Research.
  
  :param estimator: estimator of the causal model
  :param num_splits: number of splits for cross validation. (default = 5)
  :param shuffle_data : shuffle data or not before splitting into folds (default = False)
  :param shuffle_random_seed: seed for randomly shuffling data
  :param effect_strength_treatment: C^2_T, list of plausible sensitivity parameters for effect of confounder on treatment
  :param effect_strength_outcome: C^2_Y, list of plausible sensitivity parameters for effect of confounder on outcome
  :param benchmark_common_causes: names of variables for bounding strength of confounders
  :param significance_level: confidence interval for statistical inference(default = 0.05)
  :param frac_strength_treatment: strength of association between unobserved confounder and treatment compared to benchmark covariate
  :param frac_strength_outcome: strength of association between unobserved confounder and outcome compared to benchmark covariate
  :param g_s_estimator_list: list of estimator objects for finding g_s. These objects should have fit() and predict() functions.
  :param g_s_estimator_param_list: list of dictionaries with parameters for tuning respective estimators in "g_s_estimator_list".
  :param alpha_s_estimator_list: list of estimator objects for finding the treatment predictor which is used for alpha_s estimation. These objects should have fit() and predict_proba() functions.
  :param alpha_s_estimator_param_list: list of dictionaries with parameters for tuning respective estimators in "alpha_s_estimator_list".
                                   The order of the dictionaries in the list should be consistent with the estimator objects order in "g_s_estimator_list"
  :param observed_common_causes: common causes dataframe
  :param outcome: outcome dataframe
  :param treatment: treatment dataframe
class_docstr_tok: ["Class","to","perform","sensitivity","analysis","for","partially","linear","model",".","An","efficient","version","of","the","non","parametric","sensitivity","analyzer","that","works","for","estimators","that","return","residuals","of","regression","from","confounders","on","treatment","and","outcome",",","such","as","the","DML","method",".","For","all","other","methods","(","or","when","the","partially","linear","assumption","is","not","guaranteed","to","be","satisfied",")",",","use","the","non-parametric","sensitivity","analysis",".","Based","on","this","work",":","Chernozhukov",",","V.",",","Cinelli",",","C.",",","Newey",",","W.",",","Sharma",",","A.",",","&","Syrgkanis",",","V.","(","2022",")",".","Long","Story","Short",":","Omitted","Variable","Bias","in","Causal","Machine","Learning","(","No",".","w30302",")",".","National","Bureau","of","Economic","Research",".",":","param","estimator",":","estimator","of","the","causal","model",":","param","num_splits",":","number","of","splits","for","cross","validation",".","(","default","=","5",")",":","param","shuffle_data",":","shuffle","data","or","not","before","splitting","into","folds","(","default","=","False",")",":","param","shuffle_random_seed",":","seed","for","randomly","shuffling","data",":","param","effect_strength_treatment",":","C^2_T",",","list","of","plausible","sensitivity","parameters","for","effect","of","confounder","on","treatment",":","param","effect_strength_outcome",":","C^2_Y",",","list","of","plausible","sensitivity","parameters","for","effect","of","confounder","on","outcome",":","param","benchmark_common_causes",":","names","of","variables","for","bounding","strength","of","confounders",":","param","significance_level",":","confidence","interval","for","statistical","inference","(","default","=","0.05",")",":","param","frac_strength_treatment",":","strength","of","association","between","unobserved","confounder","and","treatment","compared","to","benchmark","covariate",":","param","frac_strength_outcome",":","strength","of","association","between","unobserved","confounder","and","outcome","compared","to","benchmark","covariate",":","param","g_s_estimator_list",":","list","of","estimator","objects","for","finding","g_s",".","These","objects","should","have","fit","(",")","and","predict","(",")","functions",".",":","param","g_s_estimator_param_list",":","list","of","dictionaries","with","parameters","for","tuning","respective","estimators","in","``","g_s_estimator_list","''",".",":","param","alpha_s_estimator_list",":","list","of","estimator","objects","for","finding","the","treatment","predictor","which","is","used","for","alpha_s","estimation",".","These","objects","should","have","fit","(",")","and","predict_proba","(",")","functions",".",":","param","alpha_s_estimator_param_list",":","list","of","dictionaries","with","parameters","for","tuning","respective","estimators","in","``","alpha_s_estimator_list","''",".","The","order","of","the","dictionaries","in","the","list","should","be","consistent","with","the","estimator","objects","order","in","``","g_s_estimator_list","''",":","param","observed_common_causes",":","common","causes","dataframe",":","param","outcome",":","outcome","dataframe",":","param","treatment",":","treatment","dataframe"]
docstr: Function to perform sensitivity analysis.
  
  :param plot: plot = True generates a plot of lower confidence bound of the estimate for different variations of unobserved confounding.
               plot = False overrides the setting
  
  :returns: instance of PartialLinearSensitivityAnalyzer class
docstr_tok: ["Function","to","perform","sensitivity","analysis",".",":","param","plot",":","plot","=","True","generates","a","plot","of","lower","confidence","bound","of","the","estimate","for","different","variations","of","unobserved","confounding",".","plot","=","False","overrides","the","setting",":","returns",":","instance","of","PartialLinearSensitivityAnalyzer","class"]
code: def check_sensitivity(self, plot=True):
      """
      Function to perform sensitivity analysis.
  
      :param plot: plot = True generates a plot of lower confidence bound of the estimate for different variations of unobserved confounding.
                   plot = False overrides the setting
  
      :returns: instance of PartialLinearSensitivityAnalyzer class
      """
  
      # Obtaining theta_s (the obtained estimate)
      self.point_estimate = (
          self.estimator.intercept__inference().point_estimate
      )
      self.standard_error = self.estimator.intercept__inference().stderr
      self.theta_s = self.point_estimate[0]
  
      # Creating numpy arrays
      features = self.observed_common_causes.copy()
      treatment_df = self.treatment.copy()
      X_df = pd.concat([treatment_df, features], axis=1)
      W = features.to_numpy()
      numeric_features = get_numeric_features(X_df)
      X = X_df.to_numpy()
      T = treatment_df.to_numpy()
      Y = self.outcome.copy()
      Y = Y.to_numpy()
  
      # Setting up cross-validation parameters
      cv = KFold(
          n_splits=self.num_splits,
          shuffle=self.shuffle_data,
          random_state=self.shuffle_random_seed,
      )
      num_samples = X.shape[0]
      split_indices = list(cv.split(X))
      indices = np.arange(0, num_samples, 1)
  
      # tuple of residuals from first stage estimation [0,1], and the confounders [2]
      residuals = self.estimator.residuals_
      residualized_outcome = residuals[0]  # T-E[T|W]
      residualized_treatment = residuals[1]  # Y - E[Y|W]
      W = residuals[3]
  
      n_residuals = residualized_outcome.shape[0]
      indices = np.arange(0, n_residuals, 1)
  
      residualized_outcome = residualized_outcome[indices]
      residualized_treatment = residualized_treatment[indices]
  
      # We need to estimate, sigma^2 = (Y-g_s)^2. We use the following derivation.
      # Yres = Y - E[Y|W]
      # E[Y|W] = f(x) + theta_s * E[T|W]
      # Yres = Y - f(x) - theta_s * E[T|W]
      # g(s) = theta_s * T + f(x)
      # g(s) = theta_s * (T - E[T|W]) + f(x) + theta_s * E[T|W]
      # g(s) = theta_s * Tres +f(x) + theta_s * E[T|W]
      # Y - g(s) = Y - [theta_s * Tres + f(x) + theta_s * E[T|W] )
      # Y - g(s) = ( Y - f(x) -  theta_s * E[T|W]) - theta_s * Tres
      # Y - g(s) = Yres - theta_s * Tres
      residualized_outcome_second_stage = (
          residualized_outcome - self.theta_s * residualized_treatment
      )
      self.sigma_2 = np.mean(residualized_outcome_second_stage**2)
      # nu_2 is E[alpha_s^2]
      self.nu_2 = np.mean(residualized_treatment**2)
  
      self.S2 = self.sigma_2 / self.nu_2
  
      # Now computing scores for finding the (1-a) confidence interval
      self.neyman_orthogonal_score_outcome = (
          residualized_outcome_second_stage
          * residualized_outcome_second_stage
          - self.sigma_2
      )
      self.neyman_orthogonal_score_treatment = (
          residualized_treatment * residualized_treatment - self.nu_2
      )
      self.neyman_orthogonal_score_theta = (
          (residualized_outcome_second_stage)
          * residualized_treatment
          / self.nu_2
      )
  
      # R^2 of treatment with observed common causes
      reg_function_fit = self.estimator.models_t[0][
          0
      ]  # First Stage treatment model
      treatment_model = reg_function_fit.predict(W)
      self.r2t_w = np.var(treatment_model) / np.var(T)
  
      # R^2 of outcome with treatment and observed common causes
      self.g_s = Y - residualized_outcome_second_stage
      self.r2y_tw = np.var(self.g_s) / np.var(Y)
  
      self.g_s_j = np.zeros(num_samples)
      if self.benchmarking:
          (
              delta_r2_y_wj,
              delta_r2t_wj,
          ) = self.compute_r2diff_benchmarking_covariates(
              treatment_df,
              features,
              T,
              Y,
              W,
              self.benchmark_common_causes,
              split_indices=split_indices,
              second_stage_linear=False,
              is_partial_linear=self.is_partial_linear,
          )
  
          # Partial R^2 of outcome after regressing over unobserved confounder, observed common causes and treatment
          delta_r2y_u = self.frac_strength_outcome * delta_r2_y_wj
          # Partial R^2 of treatment after regressing over unobserved confounder and observed common causes
          delta_r2t_u = self.frac_strength_treatment * delta_r2t_wj
          self.r2yu_tw = delta_r2y_u / (1 - self.r2y_tw)
          self.r2tu_w = delta_r2t_u / (1 - self.r2t_w)
          if self.r2yu_tw >= 1:
              self.r2yu_tw = 1
              self.logger.warning(
                  "Warning: r2yu_tw can not be > 1. Try a lower effect_fraction_on_outcome. Setting r2yu_tw to 1"
              )
          if self.r2tu_w >= 1:
              self.r2tu_w = 1
              self.logger.warning(
                  "Warning: r2tu_w can not be > 1. Try a lower effect_fraction_on_treatment. Setting r2tu_w to 1"
              )
          if self.r2yu_tw < 0:
              self.r2yu_tw = 0
          if self.r2tu_w < 0:
              self.r2tu_w = 0
      else:
          self.r2yu_tw = self.effect_strength_outcome
          self.r2tu_w = self.effect_strength_treatment
  
      benchmarking_results = self.perform_benchmarking(
          r2yu_tw=self.r2yu_tw,
          r2tu_w=self.r2tu_w,
          significance_level=self.significance_level,
          is_partial_linear=self.is_partial_linear,
      )
      self.results = pd.DataFrame(benchmarking_results, index=[0])
  
      self.RV = self.calculate_robustness_value(
          alpha=None, is_partial_linear=self.is_partial_linear
      )
      self.RV_alpha = self.calculate_robustness_value(
          alpha=self.significance_level,
          is_partial_linear=self.is_partial_linear,
      )
  
      if plot == True:
          self.plot()
  
      return self
  
imports: import logging
  import matplotlib.pyplot
  import numpy
  import pandas
  import scipy
  from sklearn.compose import ColumnTransformer
  from sklearn.linear_model import Lasso, LinearRegression, Ridge, RidgeCV, SGDRegressor
  from sklearn.model_selection import KFold
  from sklearn.pipeline import Pipeline
  from sklearn.preprocessing import StandardScaler
  from dowhy.causal_refuters.reisz import get_generic_regressor
  from dowhy.utils.regression import get_numeric_features
label_desc: Use image node_id 9 for calling the PartialLinearSensitivityAnalyzer obj's underlying member method code with example usage: obj.check_sensitivity(plot) and returns: self