class_docstr: Config for the causal model evaluation.
docstr: Parameters for the causal model evaluation method. See the parameter description for more details.
  
  :param mechanism_evaluation_kfolds: Number of folds for evaluating the causal mechanisms.
  :param baseline_models_regression: Baseline models for continuous nodes. The causal mechanisms assigned to the
                                     nodes in the graph are compared against additive noise models with these
                                     baseline regression models.
  :param baseline_models_classification: Baseline models for categorical nodes. The causal mechanisms assigned to the
                                         nodes in the graph are compared against these baseline models.
  :param independence_test_invertible: A method for testing the independence between inputs and estimated noise of invertible
                                       causal mechanisms. This is used to evaluate whether the made model assumptions hold.
  :param significance_level_invertible: The significance level for rejecting the null hypothesis that inputs and residuals
                                        are independent.
  :param fdr_control_method_invertible: The false discovery rate control method when running multiple hypothesis tests. Note that
                                        we can assume that the tests are independent.
  :param bootstrap_runs_invertible: The independence tests are only run on a small subset of samples. This parameter
                                    indicates how many subsets the tests should be performed on. The resulting p-values are
                                    aggregated using a family-wise error control method.
  :param max_num_permutations_falsify: Number of permutations used for falsifying the given graph structure.
  :param independence_test_falsify: A method for testing the independence between two variables used for falsifying
                                    the given graph structure. Note that the variables can be multivariate.
  :param conditional_independence_test_falsify: A method for testing the independence between two variables given a
                                                third one used for falsifying the given graph structure. Note that
                                                the variables can be multivariate.
  :param falsify_graph_significance_level: Significance level for rejecting the given graph based on the
                                           permutation tests. The default of 0.2 here is higher than the usual
                                           0.05. Consider reducing it to be more strict about falsifying the
                                           graph.
  :param n_jobs: Number of parallel jobs. Whenever the evaluation method supports parallelization, this parameter
                 is used.
docstr_tok: ["Parameters","for","the","causal","model","evaluation","method",".","See","the","parameter","description","for","more","details",".",":","param","mechanism_evaluation_kfolds",":","Number","of","folds","for","evaluating","the","causal","mechanisms",".",":","param","baseline_models_regression",":","Baseline","models","for","continuous","nodes",".","The","causal","mechanisms","assigned","to","the","nodes","in","the","graph","are","compared","against","additive","noise","models","with","these","baseline","regression","models",".",":","param","baseline_models_classification",":","Baseline","models","for","categorical","nodes",".","The","causal","mechanisms","assigned","to","the","nodes","in","the","graph","are","compared","against","these","baseline","models",".",":","param","independence_test_invertible",":","A","method","for","testing","the","independence","between","inputs","and","estimated","noise","of","invertible","causal","mechanisms",".","This","is","used","to","evaluate","whether","the","made","model","assumptions","hold",".",":","param","significance_level_invertible",":","The","significance","level","for","rejecting","the","null","hypothesis","that","inputs","and","residuals","are","independent",".",":","param","fdr_control_method_invertible",":","The","false","discovery","rate","control","method","when","running","multiple","hypothesis","tests",".","Note","that","we","can","assume","that","the","tests","are","independent",".",":","param","bootstrap_runs_invertible",":","The","independence","tests","are","only","run","on","a","small","subset","of","samples",".","This","parameter","indicates","how","many","subsets","the","tests","should","be","performed","on",".","The","resulting","p-values","are","aggregated","using","a","family-wise","error","control","method",".",":","param","max_num_permutations_falsify",":","Number","of","permutations","used","for","falsifying","the","given","graph","structure",".",":","param","independence_test_falsify",":","A","method","for","testing","the","independence","between","two","variables","used","for","falsifying","the","given","graph","structure",".","Note","that","the","variables","can","be","multivariate",".",":","param","conditional_independence_test_falsify",":","A","method","for","testing","the","independence","between","two","variables","given","a","third","one","used","for","falsifying","the","given","graph","structure",".","Note","that","the","variables","can","be","multivariate",".",":","param","falsify_graph_significance_level",":","Significance","level","for","rejecting","the","given","graph","based","on","the","permutation","tests",".","The","default","of","0.2","here","is","higher","than","the","usual","0.05",".","Consider","reducing","it","to","be","more","strict","about","falsifying","the","graph",".",":","param","n_jobs",":","Number","of","parallel","jobs",".","Whenever","the","evaluation","method","supports","parallelization",",","this","parameter","is","used","."]
code: def __init__(
      self,
      mechanism_evaluation_kfolds: int = 5,
      baseline_models_regression: Optional[
          List[Callable[[], PredictionModel]]
      ] = None,
      baseline_models_classification: Optional[
          List[Callable[[], PredictionModel]]
      ] = None,
      independence_test_invertible: Callable[
          [np.ndarray, np.ndarray], float
      ] = partial(kernel_based, use_bootstrap=False),
      significance_level_invertible: float = 0.05,
      fdr_control_method_invertible: Optional[str] = "bonferroni",
      bootstrap_runs_invertible: int = 5,
      max_num_permutations_falsify: int = 50,
      independence_test_falsify: Callable[
          [np.ndarray, np.ndarray], float
      ] = partial(
          kernel_based, use_bootstrap=False, max_num_samples_run=500
      ),
      conditional_independence_test_falsify: Callable[
          [np.ndarray, np.ndarray, np.ndarray], float
      ] = partial(
          kernel_based, use_bootstrap=False, max_num_samples_run=500
      ),
      falsify_graph_significance_level: float = 0.2,
      n_jobs: Optional[int] = None,
  ):
      """Parameters for the causal model evaluation method. See the parameter description for more details.
  
      :param mechanism_evaluation_kfolds: Number of folds for evaluating the causal mechanisms.
      :param baseline_models_regression: Baseline models for continuous nodes. The causal mechanisms assigned to the
                                         nodes in the graph are compared against additive noise models with these
                                         baseline regression models.
      :param baseline_models_classification: Baseline models for categorical nodes. The causal mechanisms assigned to the
                                             nodes in the graph are compared against these baseline models.
      :param independence_test_invertible: A method for testing the independence between inputs and estimated noise of invertible
                                           causal mechanisms. This is used to evaluate whether the made model assumptions hold.
      :param significance_level_invertible: The significance level for rejecting the null hypothesis that inputs and residuals
                                            are independent.
      :param fdr_control_method_invertible: The false discovery rate control method when running multiple hypothesis tests. Note that
                                            we can assume that the tests are independent.
      :param bootstrap_runs_invertible: The independence tests are only run on a small subset of samples. This parameter
                                        indicates how many subsets the tests should be performed on. The resulting p-values are
                                        aggregated using a family-wise error control method.
      :param max_num_permutations_falsify: Number of permutations used for falsifying the given graph structure.
      :param independence_test_falsify: A method for testing the independence between two variables used for falsifying
                                        the given graph structure. Note that the variables can be multivariate.
      :param conditional_independence_test_falsify: A method for testing the independence between two variables given a
                                                    third one used for falsifying the given graph structure. Note that
                                                    the variables can be multivariate.
      :param falsify_graph_significance_level: Significance level for rejecting the given graph based on the
                                               permutation tests. The default of 0.2 here is higher than the usual
                                               0.05. Consider reducing it to be more strict about falsifying the
                                               graph.
      :param n_jobs: Number of parallel jobs. Whenever the evaluation method supports parallelization, this parameter
                     is used.
      """
      n_jobs = config.default_n_jobs if n_jobs is None else n_jobs
  
      if baseline_models_regression is None:
          baseline_models_regression = [
              create_linear_regressor,
              create_polynom_regressor,
              create_hist_gradient_boost_regressor,
              create_ridge_regressor,
              partial(create_lasso_regressor, max_iter=10000),
              create_random_forest_regressor,
              create_extra_trees_regressor,
              create_ada_boost_regressor,
          ]
  
      if baseline_models_classification is None:
          baseline_models_classification = [
              partial(
                  create_logistic_regression_classifier, max_iter=10000
              ),
              partial(
                  create_polynom_logistic_regression_classifier,
                  max_iter=10000,
              ),
              create_hist_gradient_boost_classifier,
              create_random_forest_classifier,
              create_gaussian_nb_classifier,
              create_knn_classifier,
              create_ada_boost_classifier,
          ]
  
      self.mechanism_evaluation_kfolds = mechanism_evaluation_kfolds
      self.baseline_models_regression = baseline_models_regression
      self.baseline_models_classification = (
          baseline_models_classification
      )
      self.independence_test_invertible = independence_test_invertible
      self.significance_level_invertible = significance_level_invertible
      self.fdr_control_method_invertible = fdr_control_method_invertible
      self.bootstrap_runs_invertible = bootstrap_runs_invertible
      self.max_num_permutations_falsify = max_num_permutations_falsify
      self.independence_test_falsify = independence_test_falsify
      self.conditional_independence_test_falsify = (
          conditional_independence_test_falsify
      )
      self.falsify_graph_significance_level = (
          falsify_graph_significance_level
      )
      self.n_jobs = n_jobs
  
imports: from dataclasses import dataclass
  from functools import partial
  from typing import Any, Callable, Dict, List, Optional, Tuple
  import networkx
  import numpy
  import pandas
  from joblib import Parallel, delayed
  from numpy.matlib import repmat
  from scipy.stats import mode
  from sklearn.metrics import f1_score, mean_squared_error, r2_score
  from sklearn.model_selection import KFold
  from statsmodels.stats.multitest import multipletests
  from tqdm import tqdm
  from dowhy.gcm import ClassifierFCM, PostNonlinearModel, PredictionModel, ProbabilisticCausalModel, config, draw_samples, kernel_based
  from dowhy.gcm.causal_mechanisms import AdditiveNoiseModel, ConditionalStochasticModel, InvertibleFunctionalCausalModel
  from dowhy.gcm.divergence import auto_estimate_kl_divergence
  from dowhy.gcm.falsify import EvaluationResult, falsify_graph, plot_evaluation_results
  from dowhy.gcm.ml import SklearnRegressionModel, create_hist_gradient_boost_classifier, create_hist_gradient_boost_regressor, create_lasso_regressor, create_linear_regressor, create_logistic_regression_classifier, create_random_forest_classifier, create_random_forest_regressor, create_ridge_regressor
  from dowhy.gcm.ml.classification import create_ada_boost_classifier, create_gaussian_nb_classifier, create_knn_classifier, create_polynom_logistic_regression_classifier
  from dowhy.gcm.ml.regression import create_ada_boost_regressor, create_extra_trees_regressor, create_polynom_regressor
  from dowhy.gcm.stats import quantile_based_fwer
  from dowhy.gcm.util.general import is_categorical, set_random_seed, shape_into_2d
  from dowhy.graph import get_ordered_predecessors, is_root_node
label_desc: Use image node_id 1 to create a new EvaluateCausalModelConfig object  with example: obj = EvaluateCausalModelConfig(mechanism_evaluation_kfolds, baseline_models_regression, baseline_models_classification, independence_test_invertible, significance_level_invertible, fdr_control_method_invertible, bootstrap_runs_invertible, max_num_permutations_falsify, independence_test_falsify, conditional_independence_test_falsify, falsify_graph_significance_level, n_jobs)