class_docstr: Implements a data generating process that returns data having linear relationship between the treatment, outcome and confounders
class_docstr_tok: ["Implements","a","data","generating","process","that","returns","data","having","linear","relationship","between","the","treatment",",","outcome","and","confounders"]
code: def generate_data(self, sample_size):
      if self.auto_gen:
          self.generation_process()
  
      control_value = np.zeros((sample_size, len(self.treatment)))
      treatment_value = np.ones((sample_size, len(self.treatment)))
      confounder = np.random.randn(sample_size, len(self.confounder))
      effect_modifier = np.zeros(
          (sample_size, len(self.effect_modifier))
      )  # random.randn
  
      treatment = (
          np.matmul(confounder, self.weights["confounder=>treatment"])
          + np.random.randn(sample_size, len(self.treatment))
          + self.bias["confounder=>treatment"]
      )
      if self.treatment_is_binary:
          treatment = self.convert_to_binary(treatment)
  
      outcome = (
          np.matmul(confounder, self.weights["confounder=>outcome"])
          + np.matmul(
              effect_modifier, self.weights["effect_modifier=>outcome"]
          )
          + np.matmul(treatment, self.weights["treatment=>outcome"])
          + self.bias["confounder=>outcome"]
      )
      y_control = (
          np.matmul(confounder, self.weights["confounder=>outcome"])
          + np.matmul(
              effect_modifier, self.weights["effect_modifier=>outcome"]
          )
          + np.matmul(control_value, self.weights["treatment=>outcome"])
          + self.bias["confounder=>outcome"]
      )
      y_treatment = (
          np.matmul(confounder, self.weights["confounder=>outcome"])
          + np.matmul(
              effect_modifier, self.weights["effect_modifier=>outcome"]
          )
          + np.matmul(
              treatment_value, self.weights["treatment=>outcome"]
          )
          + self.bias["confounder=>outcome"]
      )
      self.true_value = np.mean(y_treatment - y_control, axis=0)
  
      return pd.DataFrame(
          np.hstack((effect_modifier, confounder, treatment, outcome)),
          columns=self.effect_modifier
          + self.confounder
          + self.treatment
          + self.outcome,
      )
  
file_path: dowhy/dowhy/utils/dgps/linear_dgp.py
imports: import numpy
  import pandas
  from dowhy.utils.dgp import DataGeneratingProcess
label_desc: Use image node_id 2 for calling the LinearDataGeneratingProcess obj's underlying member method code with example usage: obj.generate_data(sample_size) and returns: pd