Hi,
I believe there is a mistake in the calculation of outcomes in IPW.
The code is using np.average to compute the expected outcome across treatment groups. This computation sums the weighted outcomes and normalizes by the sum of the weights which is incorrect for IPW:
sum(weights*y)/sum(weights)
Instead it should be the mean of the weighted outcomes:
sum(weights*y)/len(y)
This is an easy but important fix.