Skip to content

GES Algorithm Fails: parameter graph should be Dag or np.ndarray #213

@Hennex945

Description

@Hennex945

Description
When running the GES algorithm, a type error is raised, despite the input being correctly formatted as a numpy.ndarray. The issue appears to stem from an internal type mismatch during the processing of the graph object within the GES, BOSS, and GRASP implementation.

The issue persists with both real-world and minimal synthetic datasets, indicating a potential problem in the library's handling of the GeneralGraph type.

Analysis

  • The error originates from the dag2cpdag function in the DAG2CPDAG.py file.
  • The GES implementation in GES.py passes a GeneralGraph object to dag2cpdag, but this function only accepts inputs of type Dag or np.ndarray.

Steps to Reproduce
The issue can be reproduced with the following minimal example:

from causallearn.search.ScoreBased.GES import ges
import numpy as np

data = np.array([[1, 2, 3],
                 [4, 5, 6],
                 [7, 8, 9]])

record = ges(data)  # Expected to work, but fails

Expected Behavior
The GES function should successfully execute and return a Record object containing the causal structure inferred from the input data.

Proposed Solutions

  1. Modify dag2cpdag: Update the function to handle GeneralGraph objects, converting them to Dag if necessary.
  2. Adjust GES Implementation: Convert the GeneralGraph object to Dag before calling dag2cpdag.

Environment

  • Python Version: 3.8.10
  • CausalLearn : 0.1.3.9

Thank you for looking into this, and please let me know if further details are required!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions