CausalDiscoveryToolbox: R Package (k)pcalg/RCIT is not available. RCIT has to be installed from

`import cdt import networkx as nx import pandas as pd import matplotlib.pyplot as plt from cdt.causality.graph import PC

data = pd.read_csv(‘http://www.causality.inf.ethz.ch/data/lucas0_train.csv’)

pc_output = PC().create_graph_from_data(data) nx.draw_networkx(pc_output) plt.show() `

when I run this code, I found this error, Traceback (most recent call last): File “test_cdt.py”, line 13, in <module> pc_output = PC().create_graph_from_data(data) File “/usr/local/lib/python3.7/site-packages/cdt/causality/graph/PC.py”, line 175, in init raise ImportError("R Package (k)pcalg/RCIT is not available. " ImportError: R Package (k)pcalg/RCIT is not available. RCIT has to be installed from https://github.com/Diviyan-Kalainathan/RCIT

I’ve already install RCIT in R, need your help image

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 29

Most upvoted comments

Hello ! The (k)pcalg dependencies are R-dependencies and not python dependencies, thus not installable with pip but rather with:

$ Rscript -e 'install.packages("BiocManager")'
$ Rscript -e 'BiocManager::install(c("CAM", "SID", "bnlearn", "pcalg", "kpcalg", "D2C"))'

Best, Diviyan

Hello again ! Can you try this ?

First using sudo, some packages needed :

apt-get install build-essential  -y --allow-unauthenticated
apt-get install libv8-dev  -y --allow-unauthenticated
apt-get  install libcurl4-openssl-dev -y --allow-unauthenticated
apt-get install libgsl-dev -y
apt-get install libxml2-dev -y --allow-unauthenticated

Then install the R packages:

Rscript -e 'install.packages(c("V8"),repos="http://cran.us.r-project.org")'
Rscript -e 'install.packages(c("sfsmisc"),repos="http://cran.us.r-project.org")'
Rscript -e 'install.packages(c("clue"),repos="http://cran.us.r-project.org")'
Rscript -e 'install.packages("https://cran.r-project.org/src/contrib/Archive/randomForest/randomForest_4.6-14.tar.gz", repos=NULL, type="source")'
Rscript -e 'install.packages(c("lattice"),repos="http://cran.us.r-project.org")'
Rscript -e 'install.packages(c("devtools"),repos="http://cran.us.r-project.org")'
Rscript -e 'install.packages(c("MASS"),repos="http://cran.us.r-project.org")'
Rscript -e 'install.packages("BiocManager")'
Rscript -e 'BiocManager::install(c("igraph"))'
Rscript -e 'install.packages("https://cran.r-project.org/src/contrib/Archive/fastICA/fastICA_1.2-2.tar.gz", repos=NULL, type="source")'
Rscript -e 'BiocManager::install(c("SID", "bnlearn", "pcalg", "kpcalg", "glmnet", "mboost"))'
Rscript -e 'install.packages("https://cran.r-project.org/src/contrib/Archive/CAM/CAM_1.0.tar.gz", repos=NULL, type="source")'
Rscript -e 'install.packages("https://cran.r-project.org/src/contrib/sparsebnUtils_0.0.8.tar.gz", repos=NULL, type="source")'
Rscript -e 'BiocManager::install(c("ccdrAlgorithm", "discretecdAlgorithm"))'

Rscript -e 'install.packages("devtools")'
Rscript -e 'library(devtools); install_github("cran/CAM"); install_github("cran/momentchi2"); install_github("Diviyan-Kalainathan/RCIT")'
Rscript -e 'install.packages("https://cran.r-project.org/src/contrib/Archive/sparsebn/sparsebn_0.1.2.tar.gz", repos=NULL, type="source")'

I’m able to run the code now after installing all the dependent R packages and creating it as a init script on the databricks cluster. Below is the packages I installed (init script) manually by finding the tar files.

%python dbutils.fs.put(“/databricks/test-scripts/install_Rpacakge.sh”,“”" #!/bin/bash #Init Script to install CAM, SID, Bnlearn, pcalg, kpcalg and D2C R pacakages sudo apt-get update -y sudo apt-get install -y libgsl-dev #pcalg and its dependencies R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/abind_1_4_3_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/BiocGenerics_0_40_0_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/graph_1_72_0_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/BH_1_78_0_0_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/RBGL_1_70_0_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/igraph_1_2_10_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/ggm_2_5_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/corpcor_1_6_10_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/DEoptimR_1_0_9_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/robustbase_0_93_9_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/zoo_1_8_9_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/lmtest_0_9_39_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/vcd_1_4_9_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/bdsmatrix_1_3_4_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/sfsmisc_1_1_11_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/fastICA_1_2_3_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/clue_0_3_60_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/RcppArmadillo_0_10_7_5_0_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/pcalg_2_7_4_tar.gz #energy and its dependencies R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/gsl_2_1_7_1_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/energy_1_7_8_tar.gz #kernlab and its dependencies R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/kernlab_0_9_29_tar.gz #rspectra and its dependencies R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/RcppEigen_0_3_3_9_1_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/RSpectra_0_16_0_tar.gz #kpcalg and its dependencies R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/kpcalg_1_0_1_tar.gz #D2C and its dependencies R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/irlba_2_3_5_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/gRbase_1_8_3_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/lazy_1_2_16_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/Rgraphviz_2_38_0_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/D2C_1_2_1_tar.gz #CAM and its dependencies R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/stabs_0_6_4_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/nnls_1_4_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/quadprog_1_5_8_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/mvtnorm_1_1_3_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/libcoin_1_0_9_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/Formula_1_2_4_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/inum_1_0_4_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/partykit_1_2_15_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/mboost_2_9_5_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/CAM_1_0_tar.gz #SID R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/SID_1_0_tar.gz #bnlearn R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/bnlearn_4_7_tar.gz #RCIT and its dependencies R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/MASS_7_3_54_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/momentchi2_0_1_5_tar.gz R CMD INSTALL --no-lock /dbfs/FileStore/tables/t/RCIT_0_1_0_tar.gz “”", True)