<jupyter_start><jupyter_text>DoWhy is a Python Library that sparks causal thinking and analysis via 4-steps:1. Model a causal inference problem using assumptions that we create.2. Identify an expression for the causal effect under these assumptions (“causal estimand”).3. Estimate the expression using statistical methods such as matching or instrumental variables.4. Verify the validity of the estimate using a variety of robustness checks.If we make it more simple, the way DoWhy package done Causal Analysis is by Creating Causal Model -> Identify Effect -> Estimate the Effect -> Validate.  Hypothesis  benign cells(no cancer) tend to have less concavity than malignant cells(cancer).does high concaity cause diagnosis ?<jupyter_code>class Causal_Model:
    def __init__(self,df:pd.DataFrame,treatment:str,outcome:str)->None:
        self.df=df
        self.treatment=treatment
        self.outcome=outcome

    def dowhy_model(self):
        labelencoder = LabelEncoder()
        self.df[self.outcome] = labelencoder.fit_transform(self.df[self.outcome])
        cols=list(self.df.columns)
        if self.treatment in cols and self.outcome in cols :
            xs = self.df.drop([self.treatment,self.outcome], axis = 1)
        xs=xs.columns.tolist()
        model=CausalModel(
            data= self.df,
            treatment=self.treatment,
            outcome=self.outcome,
            common_causes=xs
        )
        model.view_model()
        estimands = model.identify_effect() 
        print(estimands)
        estimate = model.estimate_effect(estimands,method_name = "backdoor.propensity_score_weighting")
        print(estimate)
        refutel1 = model.refute_estimate(estimands,estimate, "random_common_cause")
        print(refutel1)
        refutel2 = model.refute_estimate(estimands,estimate, "data_subset_refuter")
        print(refutel2)
        refutel3 = model.refute_estimate(estimands,estimate, "placebo_treatment_refuter")
        print(refutel3)
        return estimands
    
    


data = pd.read_csv('../data/Univariate_feature_selection_best_5_features.csv')

labelencoder = LabelEncoder()
data['diagnosis'] = labelencoder.fit_transform(data['diagnosis'])
data
data['High_concavity'] = data['concavity_mean'].apply(lambda x: True if x > 0.04558 else False)
data
c=Causal_Model(data,'High_concavity','diagnosis')

c.dowhy_model()<jupyter_output>Estimand type: nonparametric-ate

### Estimand : 1
Estimand name: backdoor
Estimand expression:
        d                                                                     
─────────────────(Expectation(diagnosis|area_mean,concavity_mean,concavity_wor
d[High_concavity]                                                             

                         
st,area_se,texture_mean))
                         
Estimand assumption 1, Unconfoundedness: If U→{High_concavity} and U→diagnosis then P(diagnosis|High_concavity,area_mean,concavity_mean,concavity_worst,area_se,texture_mean,U) = P(diagnosis|High_concavity,area_mean,concavity_mean,concavity_worst,area_se,texture_mean)

### Estimand : 2
Estimand name: iv
No such variable found!

### Estimand : 3
Estimand name: frontdoor
No such variable found!

*** Causal Estimate ***

## Identified estimand
Estimand type: nonparametric-ate

### Estimand : 1
Estimand name: backdoor
Estimand expression:
        d                                       [...]
{'fraction_non_alphanumeric': 0.0897136177673875, 'fraction_numerical': 0.0070134424313267095, 'mean_word_length': 2.9572254335260117, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '410428', 'license': 'MIT', 'n_tokens_mistral': 1060, 'n_tokens_neox': 990, 'n_words': 229, 'path': 'notebooks/DOWHY.ipynb', 'repo_name': 'bereketkibru/causalty', 'size': '3422'}