pyAgrum-nightly 2.3.1.9.dev202512261765915415__cp310-abi3-macosx_10_15_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. pyagrum/__init__.py +165 -0
  2. pyagrum/_pyagrum.so +0 -0
  3. pyagrum/bnmixture/BNMInference.py +268 -0
  4. pyagrum/bnmixture/BNMLearning.py +376 -0
  5. pyagrum/bnmixture/BNMixture.py +464 -0
  6. pyagrum/bnmixture/__init__.py +60 -0
  7. pyagrum/bnmixture/notebook.py +1058 -0
  8. pyagrum/causal/_CausalFormula.py +280 -0
  9. pyagrum/causal/_CausalModel.py +436 -0
  10. pyagrum/causal/__init__.py +81 -0
  11. pyagrum/causal/_causalImpact.py +356 -0
  12. pyagrum/causal/_dSeparation.py +598 -0
  13. pyagrum/causal/_doAST.py +761 -0
  14. pyagrum/causal/_doCalculus.py +361 -0
  15. pyagrum/causal/_doorCriteria.py +374 -0
  16. pyagrum/causal/_exceptions.py +95 -0
  17. pyagrum/causal/_types.py +61 -0
  18. pyagrum/causal/causalEffectEstimation/_CausalEffectEstimation.py +1175 -0
  19. pyagrum/causal/causalEffectEstimation/_IVEstimators.py +718 -0
  20. pyagrum/causal/causalEffectEstimation/_RCTEstimators.py +132 -0
  21. pyagrum/causal/causalEffectEstimation/__init__.py +46 -0
  22. pyagrum/causal/causalEffectEstimation/_backdoorEstimators.py +774 -0
  23. pyagrum/causal/causalEffectEstimation/_causalBNEstimator.py +324 -0
  24. pyagrum/causal/causalEffectEstimation/_frontdoorEstimators.py +396 -0
  25. pyagrum/causal/causalEffectEstimation/_learners.py +118 -0
  26. pyagrum/causal/causalEffectEstimation/_utils.py +466 -0
  27. pyagrum/causal/notebook.py +172 -0
  28. pyagrum/clg/CLG.py +658 -0
  29. pyagrum/clg/GaussianVariable.py +111 -0
  30. pyagrum/clg/SEM.py +312 -0
  31. pyagrum/clg/__init__.py +63 -0
  32. pyagrum/clg/canonicalForm.py +408 -0
  33. pyagrum/clg/constants.py +54 -0
  34. pyagrum/clg/forwardSampling.py +202 -0
  35. pyagrum/clg/learning.py +776 -0
  36. pyagrum/clg/notebook.py +480 -0
  37. pyagrum/clg/variableElimination.py +271 -0
  38. pyagrum/common.py +60 -0
  39. pyagrum/config.py +319 -0
  40. pyagrum/ctbn/CIM.py +513 -0
  41. pyagrum/ctbn/CTBN.py +573 -0
  42. pyagrum/ctbn/CTBNGenerator.py +216 -0
  43. pyagrum/ctbn/CTBNInference.py +459 -0
  44. pyagrum/ctbn/CTBNLearner.py +161 -0
  45. pyagrum/ctbn/SamplesStats.py +671 -0
  46. pyagrum/ctbn/StatsIndepTest.py +355 -0
  47. pyagrum/ctbn/__init__.py +79 -0
  48. pyagrum/ctbn/constants.py +54 -0
  49. pyagrum/ctbn/notebook.py +264 -0
  50. pyagrum/defaults.ini +199 -0
  51. pyagrum/deprecated.py +95 -0
  52. pyagrum/explain/_ComputationCausal.py +75 -0
  53. pyagrum/explain/_ComputationConditional.py +48 -0
  54. pyagrum/explain/_ComputationMarginal.py +48 -0
  55. pyagrum/explain/_CustomShapleyCache.py +110 -0
  56. pyagrum/explain/_Explainer.py +176 -0
  57. pyagrum/explain/_Explanation.py +70 -0
  58. pyagrum/explain/_FIFOCache.py +54 -0
  59. pyagrum/explain/_ShallCausalValues.py +204 -0
  60. pyagrum/explain/_ShallConditionalValues.py +155 -0
  61. pyagrum/explain/_ShallMarginalValues.py +155 -0
  62. pyagrum/explain/_ShallValues.py +296 -0
  63. pyagrum/explain/_ShapCausalValues.py +208 -0
  64. pyagrum/explain/_ShapConditionalValues.py +126 -0
  65. pyagrum/explain/_ShapMarginalValues.py +191 -0
  66. pyagrum/explain/_ShapleyValues.py +298 -0
  67. pyagrum/explain/__init__.py +81 -0
  68. pyagrum/explain/_explGeneralizedMarkovBlanket.py +152 -0
  69. pyagrum/explain/_explIndependenceListForPairs.py +146 -0
  70. pyagrum/explain/_explInformationGraph.py +264 -0
  71. pyagrum/explain/notebook/__init__.py +54 -0
  72. pyagrum/explain/notebook/_bar.py +142 -0
  73. pyagrum/explain/notebook/_beeswarm.py +174 -0
  74. pyagrum/explain/notebook/_showShapValues.py +97 -0
  75. pyagrum/explain/notebook/_waterfall.py +220 -0
  76. pyagrum/explain/shapley.py +225 -0
  77. pyagrum/lib/__init__.py +46 -0
  78. pyagrum/lib/_colors.py +390 -0
  79. pyagrum/lib/bn2graph.py +299 -0
  80. pyagrum/lib/bn2roc.py +1026 -0
  81. pyagrum/lib/bn2scores.py +217 -0
  82. pyagrum/lib/bn_vs_bn.py +605 -0
  83. pyagrum/lib/cn2graph.py +305 -0
  84. pyagrum/lib/discreteTypeProcessor.py +1102 -0
  85. pyagrum/lib/discretizer.py +58 -0
  86. pyagrum/lib/dynamicBN.py +390 -0
  87. pyagrum/lib/explain.py +57 -0
  88. pyagrum/lib/export.py +84 -0
  89. pyagrum/lib/id2graph.py +258 -0
  90. pyagrum/lib/image.py +387 -0
  91. pyagrum/lib/ipython.py +307 -0
  92. pyagrum/lib/mrf2graph.py +471 -0
  93. pyagrum/lib/notebook.py +1821 -0
  94. pyagrum/lib/proba_histogram.py +552 -0
  95. pyagrum/lib/utils.py +138 -0
  96. pyagrum/pyagrum.py +31495 -0
  97. pyagrum/skbn/_MBCalcul.py +242 -0
  98. pyagrum/skbn/__init__.py +49 -0
  99. pyagrum/skbn/_learningMethods.py +282 -0
  100. pyagrum/skbn/_utils.py +297 -0
  101. pyagrum/skbn/bnclassifier.py +1014 -0
  102. pyagrum_nightly-2.3.1.9.dev202512261765915415.dist-info/LICENSE.md +12 -0
  103. pyagrum_nightly-2.3.1.9.dev202512261765915415.dist-info/LICENSES/LGPL-3.0-or-later.txt +304 -0
  104. pyagrum_nightly-2.3.1.9.dev202512261765915415.dist-info/LICENSES/MIT.txt +18 -0
  105. pyagrum_nightly-2.3.1.9.dev202512261765915415.dist-info/METADATA +145 -0
  106. pyagrum_nightly-2.3.1.9.dev202512261765915415.dist-info/RECORD +107 -0
  107. pyagrum_nightly-2.3.1.9.dev202512261765915415.dist-info/WHEEL +4 -0
@@ -0,0 +1,480 @@
1
+ ############################################################################
2
+ # This file is part of the aGrUM/pyAgrum library. #
3
+ # #
4
+ # Copyright (c) 2005-2025 by #
5
+ # - Pierre-Henri WUILLEMIN(_at_LIP6) #
6
+ # - Christophe GONZALES(_at_AMU) #
7
+ # #
8
+ # The aGrUM/pyAgrum library is free software; you can redistribute it #
9
+ # and/or modify it under the terms of either : #
10
+ # #
11
+ # - the GNU Lesser General Public License as published by #
12
+ # the Free Software Foundation, either version 3 of the License, #
13
+ # or (at your option) any later version, #
14
+ # - the MIT license (MIT), #
15
+ # - or both in dual license, as here. #
16
+ # #
17
+ # (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) #
18
+ # #
19
+ # This aGrUM/pyAgrum library is distributed in the hope that it will be #
20
+ # useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, #
21
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS #
22
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
23
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
24
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, #
25
+ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #
26
+ # OTHER DEALINGS IN THE SOFTWARE. #
27
+ # #
28
+ # See LICENCES for more details. #
29
+ # #
30
+ # SPDX-FileCopyrightText: Copyright 2005-2025 #
31
+ # - Pierre-Henri WUILLEMIN(_at_LIP6) #
32
+ # - Christophe GONZALES(_at_AMU) #
33
+ # SPDX-License-Identifier: LGPL-3.0-or-later OR MIT #
34
+ # #
35
+ # Contact : info_at_agrum_dot_org #
36
+ # homepage : http://agrum.gitlab.io #
37
+ # gitlab : https://gitlab.com/agrumery/agrum #
38
+ # #
39
+ ############################################################################
40
+
41
+ """
42
+ The purpose of this module is to provide tools for mapping Conditional Linear Gaussian in dot language in order to
43
+ be displayed/saved as image.
44
+ """
45
+
46
+ import matplotlib.pyplot as plt
47
+ import pyagrum as gum
48
+ import pydot as dot
49
+
50
+ import pyagrum.lib._colors as gumcols
51
+ import pyagrum.lib.image as gimg
52
+
53
+ import pyagrum.clg.CLG as CLG
54
+ import pyagrum.clg.variableElimination as clginference
55
+ import pyagrum.lib.notebook as gnb
56
+
57
+
58
+ def CLG2dot(clg, *, size=None, nodeColor=None, arcWidth=None, arcColor=None, cmapNode=None, cmapArc=None, showMsg=None):
59
+ """
60
+ create a pydot representation of the CLG
61
+
62
+ Parameters
63
+ ----------
64
+ clg : CLG
65
+ Conditional Linear Gaussian.
66
+ size: str
67
+ Size of the rendered graph.
68
+ nodeColor: dict[Tuple(int,int),float]
69
+ A nodeMap of values to be shown as color nodes (with special color for 0 and 1).
70
+ arcWidth: dict[Tuple(int,int),float]
71
+ An arcMap of values to be shown as bold arcs.
72
+ arcColor: dict[Tuple(int,int),float]
73
+ An arcMap of values (between 0 and 1) to be shown as color of arcs.
74
+ cmapNode: ColorMap
75
+ Color map to show the vals of Nodes.
76
+ cmapArc: ColorMap
77
+ Color map to show the vals of Arcs.
78
+ showMsg: dict
79
+ A nodeMap of values to be shown as tooltip.
80
+
81
+ Returns
82
+ -------
83
+ pydot.Dot
84
+ The desired representation of the Conditional Linear Gaussian.
85
+ """
86
+ arcLabel = {arc: clg.coefArc(*arc) for arc in clg.arcs()}
87
+
88
+ if cmapNode is None:
89
+ cmapNode = plt.get_cmap(gum.config["notebook", "default_node_cmap"])
90
+
91
+ if cmapArc is None:
92
+ cmapArc = plt.get_cmap(gum.config["notebook", "default_arc_cmap"])
93
+
94
+ # default
95
+ maxarcs = 100
96
+ minarcs = 0
97
+
98
+ if arcWidth is not None:
99
+ minarcs = min(arcWidth.values())
100
+ maxarcs = max(arcWidth.values())
101
+
102
+ dotobj = dot.Dot(graph_type="digraph", bgcolor="transparent")
103
+
104
+ for n in clg.names():
105
+ if nodeColor is None or n not in nodeColor:
106
+ bgcol = gum.config["notebook", "default_node_bgcolor"]
107
+ fgcol = gum.config["notebook", "default_node_fgcolor"]
108
+ res = ""
109
+ else:
110
+ bgcol = gumcols.proba2bgcolor(nodeColor[n], cmapNode)
111
+ fgcol = gumcols.proba2fgcolor(nodeColor[n], cmapNode)
112
+ res = f" : {nodeColor[n] if showMsg is None else showMsg[n]:2.5f}"
113
+ node = dot.Node(
114
+ '"' + n + '"',
115
+ style="filled",
116
+ fillcolor=bgcol,
117
+ fontcolor=fgcol,
118
+ tooltip=f'"({clg.idFromName(n)}) {n}{res}"',
119
+ label=f"{{{n}|{{μ={clg.variable(n).mu():.3f}|σ={clg.variable(n).sigma():.3f}}}}}",
120
+ shape="Mrecord",
121
+ )
122
+ dotobj.add_node(node)
123
+
124
+ for a in clg.arcs():
125
+ if arcWidth is None:
126
+ pw = 1
127
+ av = ""
128
+ else:
129
+ if a in arcWidth:
130
+ if maxarcs == minarcs:
131
+ pw = 1
132
+ else:
133
+ pw = 0.1 + 5 * (arcWidth[a] - minarcs) / (maxarcs - minarcs)
134
+ av = arcWidth[a]
135
+ else:
136
+ pw = 1
137
+ av = 1
138
+
139
+ if arcColor is None:
140
+ col = gumcols.getBlackInTheme()
141
+ else:
142
+ if a in arcColor:
143
+ col = gumcols.proba2color(arcColor[a], cmapArc)
144
+ else:
145
+ col = gumcols.getBlackInTheme()
146
+
147
+ if arcLabel is None:
148
+ lb = ""
149
+ else:
150
+ if a in arcLabel:
151
+ lb = "%.2f" % (arcLabel[a])
152
+ else:
153
+ lb = ""
154
+
155
+ edge = dot.Edge(
156
+ '"' + clg.variable(a[0]).name() + '"',
157
+ '"' + clg.variable(a[1]).name() + '"',
158
+ label=lb,
159
+ fontsize="15",
160
+ penwidth=pw,
161
+ color=col,
162
+ tooltip=f"{a} : {av}",
163
+ )
164
+ dotobj.add_edge(edge)
165
+
166
+ if size is None:
167
+ size = gum.config["notebook", "default_graph_size"]
168
+
169
+ # dynamic member makes pylink unhappy
170
+ # pylint: disable=no-member
171
+ dotobj.set_size(size)
172
+
173
+ return dotobj
174
+
175
+
176
+ def CLGInference2dot(
177
+ clg, *, evs=None, size=None, nodeColor=None, arcWidth=None, arcColor=None, cmapNode=None, cmapArc=None, showMsg=None
178
+ ):
179
+ """
180
+ create a pydot representation of the CLG
181
+
182
+ Parameters
183
+ ----------
184
+ clg : CLG
185
+ Conditional Linear Gaussian.
186
+ evs : dict[str,float]
187
+ A dictionary of evidence.
188
+ size: str
189
+ Size of the rendered graph.
190
+ nodeColor: dict[Tuple(int,int),float]
191
+ A nodeMap of values to be shown as color nodes (with special color for 0 and 1).
192
+ arcWidth: dict[Tuple(int,int),float]
193
+ An arcMap of values to be shown as bold arcs.
194
+ arcColor: dict[Tuple(int,int),float]
195
+ An arcMap of values (between 0 and 1) to be shown as color of arcs.
196
+ cmapNode: ColorMap
197
+ Color map to show the vals of Nodes.
198
+ cmapArc: ColorMap
199
+ Color map to show the vals of Arcs.
200
+ showMsg: dict
201
+ A nodeMap of values to be shown as tooltip.
202
+
203
+ Returns
204
+ -------
205
+ pydot.Dot
206
+ The desired representation of the Conditional Linear Gaussian.
207
+ """
208
+ ie = clginference.CLGVariableElimination(clg)
209
+ ie.updateEvidence(evs)
210
+
211
+ if cmapNode is None:
212
+ cmapNode = plt.get_cmap(gum.config["notebook", "default_node_cmap"])
213
+
214
+ if cmapArc is None:
215
+ cmapArc = plt.get_cmap(gum.config["notebook", "default_arc_cmap"])
216
+
217
+ # default
218
+ maxarcs = 100
219
+ minarcs = 0
220
+
221
+ if arcWidth is not None:
222
+ minarcs = min(arcWidth.values())
223
+ maxarcs = max(arcWidth.values())
224
+
225
+ dotobj = dot.Dot(graph_type="digraph", bgcolor="transparent")
226
+
227
+ for n in clg.names():
228
+ if n in evs:
229
+ bgcol = gum.config["notebook", "evidence_bgcolor"]
230
+ fgcol = gum.config["notebook", "evidence_fgcolor"]
231
+ res = ""
232
+ else:
233
+ if nodeColor is None or n not in nodeColor:
234
+ bgcol = gum.config["notebook", "histogram_color"]
235
+ fgcol = gumcols.rgb2brightness(*gumcols.hex2rgb(bgcol))
236
+ res = ""
237
+ else:
238
+ bgcol = gumcols.proba2bgcolor(nodeColor[n], cmapNode)
239
+ fgcol = gumcols.proba2fgcolor(nodeColor[n], cmapNode)
240
+ res = f" : {nodeColor[n] if showMsg is None else showMsg[n]:2.5f}"
241
+ v = ie.posterior(n)
242
+ node = dot.Node(
243
+ '"' + n + '"',
244
+ style="filled",
245
+ fillcolor=bgcol,
246
+ fontcolor=fgcol,
247
+ tooltip=f'"({clg.idFromName(n)}) {n}{res}"',
248
+ label=f"{{{n}|{{μ={v.mu():.3f}|σ={v.sigma():.3f}}}}}",
249
+ shape="Mrecord",
250
+ )
251
+ dotobj.add_node(node)
252
+
253
+ for a in clg.arcs():
254
+ if arcWidth is None:
255
+ pw = 1
256
+ av = ""
257
+ else:
258
+ if a in arcWidth:
259
+ if maxarcs == minarcs:
260
+ pw = 1
261
+ else:
262
+ pw = 0.1 + 5 * (arcWidth[a] - minarcs) / (maxarcs - minarcs)
263
+ av = arcWidth[a]
264
+ else:
265
+ pw = 1
266
+ av = 1
267
+ if arcColor is None:
268
+ col = gumcols.getBlackInTheme()
269
+ else:
270
+ if a in arcColor:
271
+ col = gumcols.proba2color(arcColor[a], cmapArc)
272
+ else:
273
+ col = gumcols.getBlackInTheme()
274
+
275
+ edge = dot.Edge(
276
+ '"' + clg.variable(a[0]).name() + '"',
277
+ '"' + clg.variable(a[1]).name() + '"',
278
+ penwidth=pw,
279
+ color=col,
280
+ tooltip=f"{a} : {av}",
281
+ )
282
+ dotobj.add_edge(edge)
283
+
284
+ if size is None:
285
+ size = gum.config["notebook", "default_graph_size"]
286
+
287
+ # dynamic member makes pylink unhappy
288
+ # pylint: disable=no-member
289
+ dotobj.set_size(size)
290
+
291
+ return dotobj
292
+
293
+
294
+ def getInference(
295
+ clg, *, evs=None, size=None, nodeColor=None, arcWidth=None, arcColor=None, cmapNode=None, cmapArc=None, showMsg=None
296
+ ):
297
+ """
298
+ return a pydot representation of the CLG
299
+
300
+ Parameters
301
+ ----------
302
+ clg : CLG
303
+ Conditional Linear Gaussian.
304
+ evs : dict[str,float]
305
+ A dictionary of evidence.
306
+ size: str
307
+ Size of the rendered graph.
308
+ nodeColor: dict[Tuple(int,int),float]
309
+ A nodeMap of values to be shown as color nodes (with special color for 0 and 1).
310
+ arcWidth: dict[Tuple(int,int),float]
311
+ An arcMap of values to be shown as bold arcs.
312
+ arcColor: dict[Tuple(int,int),float]
313
+ An arcMap of values (between 0 and 1) to be shown as color of arcs.
314
+ cmapNode: ColorMap
315
+ Color map to show the vals of Nodes.
316
+ cmapArc: ColorMap
317
+ Color map to show the vals of Arcs.
318
+ showMsg: dict
319
+ A nodeMap of values to be shown as tooltip.
320
+
321
+ Returns
322
+ -------
323
+ pydot.Dot
324
+ The desired representation of the Conditional Linear Gaussian.
325
+ """
326
+ return CLGInference2dot(
327
+ clg,
328
+ evs=evs,
329
+ size=size,
330
+ nodeColor=nodeColor,
331
+ arcWidth=arcWidth,
332
+ arcColor=arcColor,
333
+ cmapNode=cmapNode,
334
+ cmapArc=cmapArc,
335
+ showMsg=showMsg,
336
+ )
337
+
338
+
339
+ def showInference(
340
+ clg, *, evs=None, size=None, nodeColor=None, arcWidth=None, arcColor=None, cmapNode=None, cmapArc=None, showMsg=None
341
+ ):
342
+ """
343
+ display a pydot representation of the CLG
344
+
345
+ Parameters
346
+ ----------
347
+ clg : CLG
348
+ Conditional Linear Gaussian.
349
+ evs : dict[str,float]
350
+ A dictionary of evidence.
351
+ size: str
352
+ Size of the rendered graph.
353
+ nodeColor: dict[Tuple(int,int),float]
354
+ A nodeMap of values to be shown as color nodes (with special color for 0 and 1).
355
+ arcWidth: dict[Tuple(int,int),float]
356
+ An arcMap of values to be shown as bold arcs.
357
+ arcColor: dict[Tuple(int,int),float]
358
+ An arcMap of values (between 0 and 1) to be shown as color of arcs.
359
+ cmapNode: ColorMap
360
+ Color map to show the vals of Nodes.
361
+ cmapArc: ColorMap
362
+ Color map to show the vals of Arcs.
363
+ showMsg: dict
364
+ A nodeMap of values to be shown as tooltip.
365
+ """
366
+ gnb.showDot(
367
+ CLGInference2dot(
368
+ clg,
369
+ evs=evs,
370
+ size=size,
371
+ nodeColor=nodeColor,
372
+ arcWidth=arcWidth,
373
+ arcColor=arcColor,
374
+ cmapNode=cmapNode,
375
+ cmapArc=cmapArc,
376
+ showMsg=showMsg,
377
+ )
378
+ )
379
+
380
+
381
+ def exportCLG(
382
+ clg, filename, *, size=None, nodeColor=None, arcWidth=None, arcColor=None, cmapNode=None, cmapArc=None, showMsg=None
383
+ ):
384
+ """
385
+ Export the clg as a picture.
386
+
387
+ Parameters
388
+ ----------
389
+ clgdot : pydot.Dot
390
+ pydot representation of the CLG.
391
+ filename : str
392
+ The filename of the exported file.
393
+ size: str
394
+ Size of the rendered graph.
395
+ nodeColor: dict[Tuple(int,int),float]
396
+ A nodeMap of values to be shown as color nodes (with special color for 0 and 1).
397
+ arcWidth: dict[Tuple(int,int),float]
398
+ An arcMap of values to be shown as bold arcs.
399
+ arcColor: dict[Tuple(int,int),float]
400
+ An arcMap of values (between 0 and 1) to be shown as color of arcs.
401
+ cmapNode: ColorMap
402
+ Color map to show the vals of Nodes.
403
+ cmapArc: ColorMap
404
+ Color map to show the vals of Arcs.
405
+ showMsg: dict
406
+ A nodeMap of values to be shown as tooltip.
407
+ """
408
+ clgdot = CLG2dot(
409
+ clg,
410
+ size=size,
411
+ nodeColor=nodeColor,
412
+ arcWidth=arcWidth,
413
+ arcColor=arcColor,
414
+ cmapNode=cmapNode,
415
+ cmapArc=cmapArc,
416
+ showMsg=showMsg,
417
+ )
418
+ gimg.export(clgdot, filename)
419
+
420
+
421
+ def exportInference(
422
+ clg,
423
+ filename: str,
424
+ *,
425
+ evs=None,
426
+ size=None,
427
+ nodeColor=None,
428
+ arcWidth=None,
429
+ arcColor=None,
430
+ cmapNode=None,
431
+ cmapArc=None,
432
+ showMsg=None,
433
+ ):
434
+ """
435
+ export a representation of a CLG inference as a picture
436
+
437
+ Parameters
438
+ ----------
439
+ clg : CLG
440
+ Conditional Linear Gaussian.
441
+ filename : str
442
+ The filename of the exported file.
443
+ evs : dict[str,float]
444
+ A dictionary of evidence.
445
+ size: str
446
+ Size of the rendered graph.
447
+ nodeColor: dict[Tuple(int,int),float]
448
+ A nodeMap of values to be shown as color nodes (with special color for 0 and 1).
449
+ arcWidth: dict[Tuple(int,int),float]
450
+ An arcMap of values to be shown as bold arcs.
451
+ arcColor: dict[Tuple(int,int),float]
452
+ An arcMap of values (between 0 and 1) to be shown as color of arcs.
453
+ cmapNode: ColorMap
454
+ Color map to show the vals of Nodes.
455
+ cmapArc: ColorMap
456
+ Color map to show the vals of Arcs.
457
+ showMsg: dict
458
+ A nodeMap of values to be shown as tooltip.
459
+
460
+ Returns
461
+ -------
462
+ pydot.Dot
463
+ The desired representation of the Conditional Linear Gaussian.
464
+ """
465
+ clgdot = CLGInference2dot(
466
+ clg,
467
+ evs=evs,
468
+ size=size,
469
+ nodeColor=nodeColor,
470
+ arcWidth=arcWidth,
471
+ arcColor=arcColor,
472
+ cmapNode=cmapNode,
473
+ cmapArc=cmapArc,
474
+ showMsg=showMsg,
475
+ )
476
+ gimg.export(clgdot, filename)
477
+
478
+
479
+ CLG.toDot = lambda self: str(CLG2dot(self))
480
+ CLG._repr_html_ = lambda self: gnb.getDot(self.toDot())