clinicalml / cfrnet

Counterfactual Regression
MIT License
295 stars 82 forks source link

weighting treated / controlled for reweight_sample option. #3

Closed sanghack81 closed 1 year ago

sanghack81 commented 7 years ago

Thank you for sharing the code. I am reading through the code to understand how it works. I am wondering whether there exists a bug in implementing "reweight_sample" option.

        if FLAGS.reweight_sample:
            w_t = t / (2 * p_t)
            w_c = (1 - t) / (2 * 1 - p_t)
            sample_weight = w_t + w_c
        else:
            sample_weight = 1.0

It looks like p_t is the proportion of treated instances -- so if it is 0.5, w_t and w_c would yield the same weight for the treated & controlled instances. If this is true, I think

https://github.com/clinicalml/cfrnet/blob/0377b0c8c822845d335540d4be6003024a65d3c8/cfr/cfr_net.py#L139

should be w_c = (1 - t) / (2 * (1 - p_t))

fredjoha commented 1 year ago

Fixed!