项目作者: IDSIA

项目描述 :
Credici: Credal Inference for Causal Inference
高级语言: Jupyter Notebook
项目地址: git://github.com/IDSIA/credici.git
创建时间: 2020-06-12T14:48:46Z
项目社区:https://github.com/IDSIA/credici

开源协议:GNU Lesser General Public License v3.0

下载


Credici

Credici is an open-source library that allows to use credal inference methods
for causal analysis:

  1. import ch.idsia.credici.inference.CredalCausalApproxLP;
  2. import ch.idsia.credici.inference.CredalCausalVE;
  3. import ch.idsia.credici.model.StructuralCausalModel;
  4. import ch.idsia.crema.IO;
  5. import ch.idsia.crema.factor.credal.linear.IntervalFactor;
  6. import ch.idsia.crema.factor.credal.vertex.VertexFactor;
  7. import ch.idsia.crema.model.graphical.specialized.BayesianNetwork;
  8. import gnu.trove.map.TIntIntMap;
  9. import gnu.trove.map.hash.TIntIntHashMap;
  10. import java.io.IOException;
  11. public class EquationlessFromFile {
  12. public static void main(String[] args) throws IOException, InterruptedException {
  13. // Load the empirical model
  14. String fileName = "./models/simple-bayes.uai";
  15. BayesianNetwork bnet = (BayesianNetwork) IO.read(fileName);
  16. // Get the markovian equationless SCM
  17. StructuralCausalModel causalModel = StructuralCausalModel.of(bnet);
  18. // Set query
  19. TIntIntMap intervention = new TIntIntHashMap();
  20. intervention.put(0,1);
  21. int target = 1;
  22. // Approx inference
  23. CredalCausalAproxLP inf = new CredalCausalAproxLP(causalModel, bnet.getFactors());
  24. IntervalFactor res = inf.doQuery(target, intervention);
  25. System.out.println(res);
  26. //Exact inference
  27. CredalCausalVE inf2 = new CredalCausalVE(causalModel, bnet.getFactors());
  28. VertexFactor res2 = inf2.doQuery(target, intervention);
  29. System.out.println(res2);
  30. }
  31. }

Installation

Add the following code in the pom.xml of your project:

  1. <repositories>
  2. <repository>
  3. <id>cremaRepo</id>
  4. <url>https://raw.github.com/idsia/crema/mvn-repo/</url>
  5. </repository>
  6. </repositories>
  7. <dependencies>
  8. <dependency>
  9. <groupId>ch.idsia</groupId>
  10. <artifactId>credici</artifactId>
  11. <version>0.1.4</version>
  12. <scope>compile</scope>
  13. </dependency>
  14. </dependencies>