minor fixes to plotting graph
This commit is contained in:
Родитель
43be2b18b6
Коммит
38b3fcac5b
|
@ -2,7 +2,7 @@ DoWhy | Making causal inference easy
|
|||
====================================
|
||||
|
||||
Amit Sharma (`amshar@microsoft.com <mailto:amshar@microsoft.com>`_),
|
||||
Emre Kiciman (`emrek@micosoft.com <mailto:emrek@microsoft.com>`_)
|
||||
Emre Kiciman (`emrek@microsoft.com <mailto:emrek@microsoft.com>`_)
|
||||
|
||||
As computing systems are more frequently and more actively intervening in societally critical domains such as healthcare, education and governance, it is critical to correctly predict and understand the causal effects of these interventions. Without an A/B test, conventional machine learning methods, built on pattern recognition and correlational analyses, are insufficient for causal reasoning.
|
||||
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -30,18 +30,21 @@ class CausalGraph:
|
|||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
def view_graph(self, layout="dot"):
|
||||
out_filename="causal_model.png"
|
||||
try:
|
||||
import pygraphviz as pgv
|
||||
agraph = nx.drawing.nx_agraph.to_agraph(self._graph)
|
||||
agraph.draw("causal_model.png", format="png", prog=layout)
|
||||
agraph.draw(out_filename, format="png", prog=layout)
|
||||
except:
|
||||
print("Error in loading pygraphviz library. Ensure that graphviz and pygraphviz are installed.")
|
||||
print("Using Matplotlib for plotting")
|
||||
import matplotlib.pyplot as plt
|
||||
plt.ion()
|
||||
plt.clf()
|
||||
nx.draw_networkx(self._graph, pos=nx.shell_layout(self._graph))
|
||||
plt.axis('off')
|
||||
plt.savefig(out_filename)
|
||||
plt.draw()
|
||||
#plt.show()
|
||||
|
||||
|
||||
def build_graph(self, common_cause_names, instrument_names):
|
||||
self._graph.add_node(self.treatment_name, observed="yes")
|
||||
|
|
Загрузка…
Ссылка в новой задаче