You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defget_single_door_learnable(
graph: NxMixedGraph, data: pd.DataFrame
) ->dict[tuple[Variable, Variable], float]:
"""Estimate parameter values for a linear SCM using backdoor adjustment."""inference=graph.to_pgmpy_causal_inference()
rv= {}
forsource, targetingraph.directed.edges():
try:
adjustment_sets=inference.get_all_backdoor_adjustment_sets(source.name, target.name)
exceptValueError:
continueifnotadjustment_sets:
continue# 2 ways - learnable, or specify a prior. Interpret lower and upper# bound as range for learnable paramter OR as a prioradjustment_set=list(adjustment_sets)[0]
variables=sorted(adjustment_set| {source.name})
idx=variables.index(source.name)
model=LinearRegression()
model.fit(data[variables], data[target.name])
rv[source, target] =model.coef_[idx]
returnrv
The text was updated successfully, but these errors were encountered:
This takes some code out of #210 for later:
The text was updated successfully, but these errors were encountered: