Package: gcastle
gCastle中文版本Version 1.0.3 released.We'll release Version 1.0.3 on 2022/08/08.IntroductiongCastle is a causal structure learning toolchain developed byHuawei Noah's Ark Lab. The package contains various functionality related to causal learning and evaluation, including:Data generation and processing: data simulation, data reading operators, and data pre-processing operators（such as prior injection and variable selection).Causal structure learning: causal structure learning methods, including both classic and recently developed methods, especially gradient-based ones that can handle large problems.Evaluation metrics: various commonly used metrics for causal structure learning, including F1, SHD, FDR, TPR, FDR, NNZ, etc.Algorithm ListAlgorithmCategoryDescriptionStatusPCIID/Constraint-basedA classic causal discovery algorithm based on conditional independence testsv1.0.3ANMIID/Function-basedNonlinear causal discovery with additive noise modelsv1.0.3DirectLiNGAMIID/Function-basedA direct learning algorithm for linear non-Gaussian acyclic model (LiNGAM)v1.0.3ICALiNGAMIID/Function-basedAn ICA-based learning algorithm for linear non-Gaussian acyclic model (LiNGAM)v1.0.3GESIID/Score-basedA classical Greedy Equivalence Search algorithmv1.0.3PNLIID/Funtion-basedCausal discovery based on the post-nonlinear causal assumptionv1.0.3NOTEARSIID/Gradient-basedA gradient-based algorithm for linear data models (typically with least-squares loss)v1.0.3NOTEARS-MLPIID/Gradient-basedA gradient-based algorithm using neural network modeling for non-linear causal relationshipsv1.0.3NOTEARS-SOBIID/Gradient-basedA gradient-based algorithm using Sobolev space modeling for non-linear causal relationshipsv1.0.3NOTEARS-lOW-RANKIID/Gradient-basedAdapting NOTEARS for large problems with low-rank causal graphsv1.0.3DAG-GNNIID/Gradient-basedDAG Structure Learning with Graph Neural Networksv1.0.3GOLEMIID/Gradient-basedA more efficient version of NOTEARS that can reduce number of optimization iterationsv1.0.3GraNDAGIID/Gradient-basedA gradient-based algorithm using neural network modeling for non-linear additive noise datav1.0.3MCSLIID/Gradient-basedA gradient-based algorithm for non-linear additive noise data by learning the binary adjacency matrixv1.0.3GAEIID/Gradient-basedA gradient-based algorithm using graph autoencoder to model non-linear causal relationshipsv1.0.3RLIID/Gradient-basedA RL-based algorithm that can work with flexible score functions (including non-smooth ones)v1.0.3CORLIID/Gradient-basedA RL- and order-based algorithm that improves the efficiency and scalability of previous RL-based approachv1.0.3TTPMEventSequence/Function-basedA causal structure learning algorithm based on Topological Hawkes process for spatio-temporal event sequencesv1.0.3HPCIEventSequence/HybridA causal structure learning algorithm based on Hawkes process and CI tests for event sequencesunder development.InstallationDependenciesgCastle requires:python (>= 3.6, <=3.9)tqdm (>= 4.48.2)numpy (>= 1.19.1)pandas (>= 0.22.0)scipy (>= 1.7.3)scikit-learn (>= 0.21.1)matplotlib (>=2.1.2)networkx (>= 2.5)torch (>= 1.9.0)PIP installationpipinstallgcastle==1.0.3Usage Example (PC algorithm)fromcastle.commonimportGraphDAGfromcastle.metricsimportMetricsDAGfromcastle.datasetsimportIIDSimulation,DAGfromcastle.algorithmsimportPC# data simulation, simulate true causal dag and train_data.weighted_random_dag=DAG.erdos_renyi(n_nodes=10,n_edges=10,weight_range=(0.5,2.0),seed=1)dataset=IIDSimulation(W=weighted_random_dag,n=2000,method='linear',sem_type='gauss')true_causal_matrix,X=dataset.B,dataset.X# structure learningpc=PC()pc.learn(X)# plot predict_dag and true_dagGraphDAG(pc.causal_matrix,true_causal_matrix,'result')# calculate metricsmt=MetricsDAG(pc.causal_matrix,true_causal_matrix)print(mt.metrics)You can visitexamplesto find more examples.CitationIf you find gCastle useful in your research, please consider citing the the followingpaper:@misc{zhang2021gcastle,
  title={gCastle: A Python Toolbox for Causal Discovery}, 
  author={Keli Zhang and Shengyu Zhu and Marcus Kalander and Ignavier Ng and Junjian Ye and Zhitang Chen and Lujia Pan},
  year={2021},
  eprint={2111.15155},
  archivePrefix={arXiv},
  primaryClass={cs.LG}
}Next Up & ContributingThis is the first released version of gCastle, we'll be continuously complementing and optimizing the code and documentation. We welcome new contributors of all experience levels, the specifications about how to contribute code will be coming out soon. If you have any questions or suggestions (such as, contributing new algorithms, optimizing code, improving documentation), please submit an issue here. We will reply as soon as possible.