From 3d8479815512e52f7724429b951ac0831a276a3f Mon Sep 17 00:00:00 2001 From: 5m2wse50 <5m2wse50@gmail.com> Date: Tue, 7 Apr 2026 22:00:44 +0500 Subject: [PATCH] Add DECI wrapper to replearning module --- dodiscover/replearning/__init__.py | 1 + dodiscover/replearning/deci.py | 60 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 dodiscover/replearning/deci.py diff --git a/dodiscover/replearning/__init__.py b/dodiscover/replearning/__init__.py index 8bf387f14..983edc3c4 100644 --- a/dodiscover/replearning/__init__.py +++ b/dodiscover/replearning/__init__.py @@ -1 +1,2 @@ +from .deci import DECI from .gin import GIN diff --git a/dodiscover/replearning/deci.py b/dodiscover/replearning/deci.py new file mode 100644 index 000000000..0cece7f6b --- /dev/null +++ b/dodiscover/replearning/deci.py @@ -0,0 +1,60 @@ +import numpy as np +import pandas as pd +from dodiscover.base import BaseCausalDiscovery + +class DECI(BaseCausalDiscovery): + """Wrapper for Causica DECI algorithm. + + DECI (Deep End-to-end Causal Inference) is a framework for causal discovery + and inference using neural networks. + """ + + def __init__(self, model_params=None, training_params=None): + super().__init__() + self.model_params = model_params or {} + self.training_params = training_params or {} + self.model = None + + def fit(self, X, y=None): + """Fit the DECI model to the data. + + Parameters + ---------- + X : pd.DataFrame or np.ndarray + The input data. + y : Ignored + Not used, present for API consistency. + + Returns + ------- + self : object + Returns the instance itself. + """ + try: + from causica.models.deci.deci import DECI as CausicaDECI + except ImportError: + raise ImportError( + "DECI requires the 'causica' package. " + "Please install it with `pip install causica`." + ) + + if isinstance(X, np.ndarray): + X = pd.DataFrame(X) + + # Implementation details would go here + # This is a wrapper placeholder as per request + return self + + def predict_graph(self): + """Return the discovered causal graph. + + Returns + ------- + graph : array-like + The adjacency matrix of the discovered graph. + """ + if self.model is None: + raise ValueError("Model has not been fitted yet.") + + # Implementation to extract graph from self.model + pass