<jupyter_start><jupyter_text>[`input_query`] -> Input query for generating counterfactual.[`cf`] -> Counterfactual found through CounterfactaulProto.[`input_query_nn_pred`] -> Prediction value for input_query using our model.[`cf_nn_pred`] -> Predictino value for cf using our model.[`permutation_nn_pred_portion`] -> The permutation dataset label size for `[0, 1]`  Checking balance.[`input_query_tree_pred`] -> Prediction value for input_query using surrogate decision tree.[`cf_tree_pred`] -> Prediction value for cf using surrogate decision tree.[`input_query_decisions`] -> Rules extracted when predicting input query using surrogate decision tree.[`cf_decisions`] -> Rules extracted when predicting cf using surrogate decision tree.[`input_query_leaf_id`] -> decision leaf id for input_query on surrogate decision tree.[`cf_leaf_id`] -> decision leaf id for cf on surrogate decision tree.[`dot_data`] -> Dot data to plot the surrogate decision tree.  Example below[`sparsity`] -> How many features changed.[`distance`] -> L2 distance btw input_query and counterfactual.[`depth_diff`] -> Depth difference btw input_query and cf.[`has_same_input_pred`] -> Our model and surrogate decision tree has same prediction on input_query.[`has_same_cf_pred`] -> Our model and surrogate decision tree has same prediction on cf.<jupyter_code>example = df.iloc[0]
graphviz.Source(example['dot_data'], format="png") 
input_query_true = df[df['has_same_input_pred']==True]
input_query_cf_true = input_query_true[input_query_true['has_same_cf_pred']==True]
print(f"In {len(input_query_cf_true) / len(df)} % of the case, the surrogate decision have the same prediction result as our model in input query and its counterfactual.")
## Print the decision rules for input_query.
print_decisions(json.loads(example['input_query_decisions']))
print(f"End in # {example['input_query_leaf_id']}")
## Print the decision rules for cf.
print_decisions(json.loads(example['cf_decisions']))
print(f"End in # {example['cf_leaf_id']}")<jupyter_output>decision node 0 : (x [Glucose] = 77.6102294921875) <= 136.4044647216797)
decision node 1 : (x [Age] = 59.0) > 44.830915451049805)
decision node 19 : (x [BloodPressure] = 56.065574645996094) <= 91.61150360107422)
End in # 20.0
{'fraction_non_alphanumeric': 0.1151622943530458, 'fraction_numerical': 0.04224099599822143, 'mean_word_length': 6.601351351351352, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 22, 'https://': 0, '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': '70785', 'license': 'MIT', 'n_tokens_mistral': 783, 'n_tokens_neox': 690, 'n_words': 208, 'path': 'surrogate_proto_analysis.ipynb', 'repo_name': 'LeonChou5311/Counterfactual-benchmark', 'size': '2249'}