<jupyter_start><jupyter_text>Causal direction: 1 means that X -> Y; and 0 the other way around.<jupyter_code>x, y, target, _ = data[idx]
print('Causal direction:', target)
print('nb samples:', len(x))
viz.pretty_scatter(x, y)
X_, Y_, _ = intest.partition_data(x, y)
viz.plot_scatters(X_, Y_)
residuals, X_, Y_, models = intest.estimate_partitioned_models(x, y)
score, pairs = intest.find_max_discrp(residuals)
score
viz.plot_models(X_, Y_, models)
viz.plot_residuals(residuals)
X_r, Y_r, _ = intest.partition_data(y, x)
viz.plot_scatters(X_r, Y_r)
residualsr, Y_r, X_r, modelsr = intest.estimate_partitioned_models(y, x)
scorer, pairsr = intest.find_max_discrp(residualsr)
scorer
viz.plot_models(Y_r, X_r, modelsr)
viz.plot_residuals(residualsr)
viz.plot_residuals(residualsr, res_filter=pairsr, title='Maximum l1 distance densities')
print('X -> Y', score)
print('X <- Y', scorer)
# avg dist to avg
# can use models to easily compute an estimate cheaply (add point and degree-> regress)
# var / moment est for low sample regime

# discretise based on largest support (min, max) , see hist param
print('predicted:', int(score < scorer))
print('Truth:', target)<jupyter_output>Truth: 1
{'fraction_non_alphanumeric': 0.12922297297297297, 'fraction_numerical': 0.0033783783783783786, 'mean_word_length': 6.5, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, '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': '10078', 'license': 'MIT', 'n_tokens_mistral': 478, 'n_tokens_neox': 461, 'n_words': 117, 'path': 'benchmark/evaluate single dataset.ipynb', 'repo_name': 'Nacho114/bivariate-causal-inference', 'size': '1184'}