[python] test
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- valid_split = True
- for i, idx in enumerate([treated_idx, control_idx]):
- # Compare the outcomes of the treated in train and test set
- train = np.zeros(len(idx))
- train[:len(train_idx[T_train == i])] = 1 # First sum(T_train) are from the train set, rest test set
- X_subgroup = pd.DataFrame(index=X.iloc[idx].index)
- X_subgroup['TRAIN'] = train
- X_subgroup = X_subgroup.dropna(axis=0)
- y = data.XCDER_NBEX[X_subgroup.index]
- os = np.log(data.XCDER_FUTIME[X_subgroup.index])
- X_subgroup = sm.add_constant(X_subgroup)
- nbr = sm.GLM(y, X_subgroup, family=sm.families.NegativeBinomial(), offset=os)
- results = nbr.fit()
- if results.pvalues['TRAIN'] < p_threshold:
- valid_split = False
- if valid_split:
- break
Editor
You can edit this paste and save as new: