Adding background knowledge using FCI
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 274
- PR merge metrics
- No merged PRs in 30d
Description
Hi. I am using fci using the background knowledge. I have a dataframe with 287 features.
I'm doing this
cg_without_background_knowledge = fci(merged_data1.to_numpy(), node_names=merged_data1.columns).
The output of this is a tuple of two which has graphs and edges.
I then get the nodes in this way:
nodes = cg_without_background_knowledge[0].get_nodes()
I print the node names as:
for node in cg_without_background_knowledge[0].nodes:
print(node.get_name())
The output of this is X1, X2,....., X287. I want to add background knowledge. I tried the following methods
##1)
bk = BackgroundKnowledge()
for i in range(len(node_pairs)):
bk.add_forbidden_by_node(GraphNode(node_pairs[i][0]), GraphNode(node_pairs[i][1]))
##2)
bk = BackgroundKnowledge()
for i in range(len(nodes_forbidden)):
bk.add_forbidden_by_node(**nodes[nodes_forbidden[i][0]], nodes[nodes_forbidden[i][1]]**)
where node_pairs=[('feature_1', 'feature_2') ,('feature_x', 'feature_y' ).....] &
nodes_forbidden=[0, 7), (0, 14), (0, 21),(0, 28),....].
When I rerun the fci algorithm as
G, edges = fci(merged_data1.to_numpy(), background_knowledge=bk, node_names=merged_data1.columns)
and when I check the G and I can see that there is still a connection between nodes[0], nodes[7] which I try to forbid in the background knowledge. If there is a link between nodes 0 & 7, I do not want it to be like nodes[0] -> nodes[7]. However, the other way is fine but I do not see the case. I still have connection as nodes[0] -> nodes[7].
My question to you is that how can I know what X1, X2, ....X287 maps to according to my dataset? I am not getting the names of the node as per my data in spite of passing the parameter node_names = merged_data1.columns.
Please help!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the fci entry point and inspect how node_names are applied to the returned graph, then review the BackgroundKnowledge API and its forbidden-edge semantics. Reproduce the example with a small subset of the dataframe and verify both the displayed node-name mapping and the direction of the forbidden relation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100