<jupyter_start><jupyter_text>BARThttps://github.com/JakeColtman/bartpypip install git+https://github.com/JakeColtman/bartpy.git --upgrade<jupyter_code>from bartpy.sklearnmodel import SklearnModel

test_eval_result={"E_pehe":[], "E_att":[], "E_ate":[], "AUUC":[]}

for i_exp in range(num_exp):
    print("running... " + str(i_exp))
    start = time.time()
    # train
    X_train = dict_train["x"][:, :, i_exp]
    yf_train = dict_train["yf"][:, i_exp]
    t_train = dict_train["t"][:, i_exp]

    bart_model = SklearnModel(n_trees=20, n_jobs=1)  # Use default parameters
    bart_model.fit(X_train, yf_train)  # Fit the model
 

    # predict
    X_test = dict_test["x"][:, :, i_exp]
    yf_test = dict_test["yf"][:, i_exp]
    t_test = dict_test["t"][:, i_exp]

    pred_result = bart_model.predict(X_test)
   

    _auuc = qini_auc_score(yf_test.reshape(-1), pred_result, t_test.reshape(-1))
    att = np.mean(yf_test.reshape(-1)[t_test.reshape(-1)==1]) - np.mean(yf_test.reshape(-1)[t_test.reshape(-1)==0]) 
    pred_att = np.mean(pred_result[t_test.reshape(-1)==1])
    E_att = np.abs(pred_att-att)
    
    test_eval_result["E_att"].append(E_att)
    test_eval_result["AUUC"].append(_auuc)


print("testing eval results:")
for k in test_eval_result.keys():
    val = np.mean(test_eval_result[k])
    num_exp = len(test_eval_result[k])
    std = np.std(test_eval_result[k])/np.sqrt(num_exp)
    print(k+": %.6f"%val + " +/- %.6f"%std )<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18379850238257317, 'fraction_numerical': 0.010211027910142955, 'mean_word_length': 4.345454545454546, 'pattern_counts': {'":': 5, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '385182', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 630, 'n_tokens_neox': 622, 'n_words': 82, 'path': 'CasualForest_BART_real_data.ipynb', 'repo_name': 'kailiang-zhong/DESCN', 'size': '1469'}