Skip to content

Commit e43d8ff

Browse files
committed
[FIX] BNlearn classes not accepting arguments #120
1 parent 5e094cb commit e43d8ff

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

cdt/causality/graph/bnlearn.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ class BNlearnAlgorithm(GraphModel):
118118
"""
119119

120120
def __init__(self, score='NULL', alpha=0.05, beta='NULL',
121-
optim=False, verbose=None):
121+
optim=False, verbose=None, algorithm=None):
122122
"""Init the model."""
123123
if not RPackages.bnlearn:
124124
raise ImportError("R Package bnlearn is not available.")
125125
super(BNlearnAlgorithm, self).__init__()
126126
self.arguments = {'{FOLDER}': '/tmp/cdt_bnlearn/',
127127
'{FILE}': os.sep + 'data.csv',
128128
'{SKELETON}': 'FALSE',
129-
'{ALGORITHM}': None,
129+
'{ALGORITHM}': algorithm,
130130
'{WHITELIST}': os.sep + 'whitelist.csv',
131131
'{BLACKLIST}': os.sep + 'blacklist.csv',
132132
'{SCORE}': 'NULL',
@@ -312,10 +312,11 @@ class GS(BNlearnAlgorithm):
312312
>>> plt.show()
313313
"""
314314

315-
def __init__(self):
315+
def __init__(self, score='NULL', alpha=0.05, beta='NULL',
316+
optim=False, verbose=None):
316317
"""Init the model."""
317-
super(GS, self).__init__()
318-
self.arguments['{ALGORITHM}'] = 'gs'
318+
super(GS, self).__init__(score='NULL', alpha=0.05, beta='NULL',
319+
optim=False, verbose=None, algorithm="gs")
319320

320321

321322
class IAMB(BNlearnAlgorithm):
@@ -334,7 +335,7 @@ class IAMB(BNlearnAlgorithm):
334335
with additional assumptions depending on the conditional test used.
335336
336337
.. note::
337-
Tsamardinos I, Aliferis CF, Statnikov A (2003). "Algorithms for Large Scale Markov Blanket
338+
Tsamardinos I, Aliferis CF, Statnikov A (2003). "Algorithms for Large Scale Markov Blanket
338339
Discovery". In "Proceedings of the Sixteenth International Florida Artificial Intelligence Research
339340
Society Conference", pp. 376-381. AAAI Press.
340341
@@ -357,10 +358,11 @@ class IAMB(BNlearnAlgorithm):
357358
>>> plt.show()
358359
"""
359360

360-
def __init__(self):
361+
def __init__(self, score='NULL', alpha=0.05, beta='NULL',
362+
optim=False, verbose=None):
361363
"""Init the model."""
362-
super(IAMB, self).__init__()
363-
self.arguments['{ALGORITHM}'] = 'iamb'
364+
super(IAMB, self).__init__(score='NULL', alpha=0.05, beta='NULL',
365+
optim=False, verbose=None, algorithm="iamb")
364366

365367

366368
class Fast_IAMB(BNlearnAlgorithm):
@@ -402,10 +404,11 @@ class Fast_IAMB(BNlearnAlgorithm):
402404
>>> plt.show()
403405
"""
404406

405-
def __init__(self):
407+
def __init__(self, score='NULL', alpha=0.05, beta='NULL',
408+
optim=False, verbose=None):
406409
"""Init the model."""
407-
super(Fast_IAMB, self).__init__()
408-
self.arguments['{ALGORITHM}'] = 'fast.iamb'
410+
super(Fast_IAMB, self).__init__(score='NULL', alpha=0.05, beta='NULL',
411+
optim=False, verbose=None, algorithm='fast.iamb')
409412

410413

411414
class Inter_IAMB(BNlearnAlgorithm):
@@ -446,10 +449,11 @@ class Inter_IAMB(BNlearnAlgorithm):
446449
>>> plt.show()
447450
"""
448451

449-
def __init__(self):
452+
def __init__(self, score='NULL', alpha=0.05, beta='NULL',
453+
optim=False, verbose=None):
450454
"""Init the model."""
451-
super(Inter_IAMB, self).__init__()
452-
self.arguments['{ALGORITHM}'] = 'inter.iamb'
455+
super(Inter_IAMB, self).__init__(score='NULL', alpha=0.05, beta='NULL',
456+
optim=False, verbose=None, algorithm="inter.iamb")
453457

454458

455459
class MMPC(BNlearnAlgorithm):
@@ -497,7 +501,8 @@ class MMPC(BNlearnAlgorithm):
497501
>>> plt.show()
498502
"""
499503

500-
def __init__(self):
504+
def __init__(self, score='NULL', alpha=0.05, beta='NULL',
505+
optim=False, verbose=None):
501506
"""Init the model."""
502-
super(MMPC, self).__init__()
503-
self.arguments['{ALGORITHM}'] = 'mmpc'
507+
super(MMPC, self).__init__(score='NULL', alpha=0.05, beta='NULL',
508+
optim=False, verbose=None, algorithm='mmpc')

0 commit comments

Comments
 (0)