[python] test

Viewer

  1.         valid_split = True
  2.         for i, idx in enumerate([treated_idx, control_idx]):
  3.  
  4.             # Compare the outcomes of the treated in train and test set
  5.             train = np.zeros(len(idx))
  6.             train[:len(train_idx[T_train == i])] = 1  # First sum(T_train) are from the train set, rest test set
  7.             X_subgroup = pd.DataFrame(index=X.iloc[idx].index)
  8.             X_subgroup['TRAIN'] = train
  9.             X_subgroup = X_subgroup.dropna(axis=0)
  10.             y = data.XCDER_NBEX[X_subgroup.index]
  11.             os = np.log(data.XCDER_FUTIME[X_subgroup.index])
  12.  
  13.             X_subgroup = sm.add_constant(X_subgroup)
  14.             nbr = sm.GLM(y, X_subgroup, family=sm.families.NegativeBinomial(), offset=os)
  15.             results = nbr.fit()
  16.  
  17.             if results.pvalues['TRAIN'] < p_threshold:
  18.                 valid_split = False
  19.         if valid_split:
  20.             break

Editor

You can edit this paste and save as new:


File Description
  • test
  • Paste Code
  • 24 Mar-2023
  • 906 Bytes
You can Share it: