FenTechSolutions / CausalDiscoveryToolbox

Package for causal inference in graphs and in the pairwise settings. Tools for graph structure recovery and dependencies are included.
https://fentechsolutions.github.io/CausalDiscoveryToolbox/html/index.html
MIT License
1.08k stars 198 forks source link

AcyclicGraphGenerator + SAM + precision_recall don't work together #85

Closed lagph closed 3 years ago

lagph commented 3 years ago
from cdt.data import AcyclicGraphGenerator
from cdt.causality.graph import SAM
from cdt.metrics import precision_recall

generator = AcyclicGraphGenerator("gp_mix")

data, graph = generator.generate()

sam = SAM(
        train_epochs=3000,
        test_epochs=300,
        dlr=0.001,
        dagpenalization_increase=0.01,
        gpus=1,
        nruns=1,
        njobs=2,
        verbose=True,
        lambda2=0.001,
        lambda1=10,
        nh=20,
        dnh=200,
)

prediction = sam.predict(data)

print(precision_recall(graph, prediction))

gives

(0.54, [(0.08, 1.0), (1.0, 0.0)])

The problem is that the node names are different for prediction and graph, which breaks metrics.retrieve_adjacency_matrix.

diviyank commented 3 years ago

Hello, this should be fixed with the new version of the SAM code. I'll keep you updated. Best,*Diviyan

diviyank commented 3 years ago

Hello ! The node name issue should be fixed, I'll be releasing 0.5.23 with lots of fixes ! Thanks again for bringing this issue up.

Best, Diviyan