0

How can I parallelize the hc algorithm from the package bnlearn? For example, how can I update the following code

bn_k2 <- hc(x = dTrain, score = "k2",debug = F, optimized = T)

My pc has 8 Core and when I run hc just one CPU is used. How can I make to run on all 8 Core ?

user20650
  • 24,654
  • 5
  • 56
  • 91
  • 1
    Your question is overly broad. You don't establish what problem you're actually trying to solve nor what you've tried so far. And you don't give a complete reproducible example. See: https://stackoverflow.com/help/mcve – Adam Sampson Apr 01 '19 at 19:40
  • as far as I know, only the constraint based algorithms are parallelised. – user20650 Apr 01 '19 at 23:10
  • I disagree that this question is too broad or the problem unstated; it is specific in wanting to parallelise the hc algorithm - this feature is present on other algorithms. – user20650 Apr 01 '19 at 23:18
  • @sergio; R by default runs on one core. `hc` does not currently support parallel search. If you are willing to use constraint learning, you can do the search in parallel. If you are wanting to use a parallel search because it is taking too long (many variables), you could try a hybrid search i.e. `mmhc`, which can be a lot faster in this case – user20650 Apr 02 '19 at 19:00

1 Answers1

0

Do you want to paralelize the algorithm to make it faster or to run it on multiple data sources at once? If it the first case probably you need to rewrite the function. If it's the second, just use the package parallel to handle with the loop.

Ochetski
  • 105
  • 1
  • 13
  • My CPU has 8 cores and I would like to use all but when run the bc them use just 1 CPU,.How to make all CPU use, you can show an example? – Sérgio Carvalho Apr 02 '19 at 13:25