<jupyter_start><jupyter_text>PC dicovery test<jupyter_code>from causallearn.search.ConstraintBased.PC import pc
data = np.block([
    [X, np.reshape([i] * X.shape[0], (-1, 1))]
    for i, X in enumerate(Xs)
])
cg = pc(data, alpha=0.05 / 3, indep_test=kci)
cg.to_nx_graph()
cg.draw_nx_graph(skel=False)
from causallearn.utils.PCUtils.BackgroundKnowledge import BackgroundKnowledge
from causallearn.graph.GraphNode import GraphNode
from causallearn.utils.PCUtils.BackgroundKnowledgeOrientUtils import \
    orient_by_background_knowledge

node1 = GraphNode('X1')
node2 = GraphNode('X2')
node3 = GraphNode('X3')
node4 = GraphNode('X4')

bk = BackgroundKnowledge() \
            .add_required_by_node(node4, node1) \
            .add_required_by_node(node4, node2) \
            .add_required_by_node(node4, node3)
#             .add_required_by_node(node1, node2) \
#             .add_required_by_node(node2, node3) \
#             .add_required_by_node(node1, node3) \
            
data = np.block([
    [X, np.reshape([i] * X.shape[0], (-1, 1))]
    for i, X in enumerate(Xs)
])
# data = Xs[1]
cg = pc(data, alpha=0.05 /3 , indep_test=kci)#, background_knowledge=bk)
cg.to_nx_graph()
cg.draw_nx_graph(skel=False)
orient_by_background_knowledge(cg, bk)
cg.to_nx_graph()
cg.draw_nx_graph(skel=False)<jupyter_output>Green: undirected; Blue: directed; Red: bi-directed
{'fraction_non_alphanumeric': 0.13499633162142333, 'fraction_numerical': 0.025678650036683785, 'mean_word_length': 4.108614232209738, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '328527', 'license': 'MIT', 'n_tokens_mistral': 540, 'n_tokens_neox': 520, 'n_words': 90, 'path': 'notebooks/06-rp-causal_learn_tests.ipynb', 'repo_name': 'rflperry/sparse_shift', 'size': '1363'}