ALICE (Automated Learning and Intelligence for Causation and Economics) is a Microsoft Research project aimed at applying Artificial Intelligence concepts to economic decision making. One of its goals is to build a toolkit that combines state-of-the-art machine learning techniques with econometrics in order to bring automation to complex causal inference problems. To date, the ALICE Python SDK (econml) implements orthogonal machine learning algorithms such as the double machine learning work of Chernozhukov et al. This toolkit is designed to measure the causal effect of some treatment variable(s) t on an outcome variable y, controlling for a set of features x.
I am new with DeepIV, and I am trying to fit a model of DeepIV, however, I get this error message: TypeError: 'NoneType' object is not subscriptable, and I don't know how to interpretate it.
y = Colombia_temp.incidence100k
y.to_numpy()
x = Colombia_temp.Code_DANE
x.to_numpy()
z = Colombia_temp.soi
z.to_numpy()
t = Colombia_temp.Temperature
t.to_numpy()
Hello,
I am new with DeepIV, and I am trying to fit a model of DeepIV, however, I get this error message: TypeError: 'NoneType' object is not subscriptable, and I don't know how to interpretate it.
Here is my code and dataset Data_DeepIV.csv
Thanks for your cooperation
`import pandas as pd import scipy.stats as stats from econml.iv.nnet import DeepIV import keras
import data
data_col = pd.read_csv("D:/clases/UDES/articulo leishmaniasis/causal_inference/dowhy/Data_DeepIV.csv", encoding='latin-1') data_col = data_col.dropna()
subset
Colombia_temp = data_col[['incidence100k', 'Temperature', 'soi', 'Code_DANE']]
transform variables to sd units
Colombia_temp.Temperature = stats.zscore(Colombia_temp.Temperature)
Colombia_temp.soi = stats.zscore(Colombia_temp.soi)
y = Colombia_temp.incidence100k y.to_numpy() x = Colombia_temp.Code_DANE x.to_numpy() z = Colombia_temp.soi z.to_numpy() t = Colombia_temp.Temperature t.to_numpy()
Defining the neural network models
treatment_model = keras.Sequential([keras.layers.Dense(128, activation='relu', input_shape=(2,)), keras.layers.Dropout(0.17), keras.layers.Dense(64, activation='relu'), keras.layers.Dropout(0.17), keras.layers.Dense(32, activation='relu'), keras.layers.Dropout(0.17)])
response_model = keras.Sequential([keras.layers.Dense(128, activation='relu', input_shape=(2,)), keras.layers.Dropout(0.17), keras.layers.Dense(64, activation='relu'), keras.layers.Dropout(0.17), keras.layers.Dense(32, activation='relu'), keras.layers.Dropout(0.17), keras.layers.Dense(1)])
Instantiate the DeepIV class using these models.
keras_fit_options = { "epochs": 30, "validation_split": 0.1, "callbacks": [keras.callbacks.EarlyStopping(patience=2, restore_best_weights=True)]}
deepIvEst = DeepIV(n_components = 10, m = lambda z, x : treatment_model(keras.layers.concatenate([z,x])), h = lambda t, x : response_model(keras.layers.concatenate([t,x])),
n_samples = 1, use_upper_bound_loss = False, n_gradient_samples = 1, optimizer='adam', first_stage_options = keras_fit_options, second_stage_options = keras_fit_options)
Fitting and predicting using the model
deepIvEst.fit(Y=y,T=t,X=x,Z=z, inference="bootstrap")
ate
deepIvEst.ate_inference()
ci ate
deepIvEst.ate_interval()
dowhy wrapper
deepIvEst = deepIvEst.dowhy
placebo
placebo_temp = deepIvEst.refute_estimate(method_name="placebo_treatment_refuter", placebo_type="permute", num_simulations=5) print(placebo_temp)
`