diff --git a/README.md b/README.md
index ae9e9db..be7cd2b 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,10 @@ pip install pywhyllm
PyWhy-LLM seamlessly integrates into your existing causal inference process. Import the necessary classes and start exploring the power of LLM-augmented causal analysis.
```python
-from pywhyllm import ModelSuggester, IdentificationSuggester, ValidationSuggester
+from pywhyllm.suggesters.model_suggester import ModelSuggester
+from pywhyllm.suggesters.identification_suggester import IdentificationSuggester
+from pywhyllm.suggesters.validation_suggester import ValidationSuggester
+from pywhyllm import RelationshipStrategy
```
@@ -34,17 +37,20 @@ from pywhyllm import ModelSuggester, IdentificationSuggester, ValidationSuggeste
```python
# Create instance of Modeler
-modeler = Modeler()
+modeler = ModelSuggester('gpt-4')
+
+all_factors = ["smoking", "lung cancer", "exercise habits", "air pollution exposure"]
+treatment = "smoking"
+outcome = "lung cancer"
+
+# Suggest a list of domain expertises
+domain_expertises = modeler.suggest_domain_expertises(all_factors)
# Suggest a set of potential confounders
-suggested_confounders = modeler.suggest_confounders(variables=_variables, treatment=treatment, outcome=outcome, llm=gpt4)
+suggested_confounders = modeler.suggest_confounders(treatment, outcome, all_factors, domain_expertises)
# Suggest pair-wise relationship between variables
-suggested_dag = modeler.suggest_relationships(variables=selected_variables, llm=gpt4)
-
-plt.figure(figsize=(10, 5))
-nx.draw(suggested_dag, with_labels=True, node_color='lightblue')
-plt.show()
+suggested_dag = modeler.suggest_relationships(treatment, outcome, all_factors, domain_expertises, RelationshipStrategy.Pairwise)
```
@@ -54,15 +60,13 @@ plt.show()
```python
# Create instance of Identifier
-identifier = Identifier()
+identifier = IdentificationSuggester('gpt-4')
-# Suggest a backdoor set, front door set, and iv set
-suggested_backdoor = identifier.suggest_backdoor(llm=gpt4, treatment=treatment, outcome=outcome, confounders=suggested_confounders)
-suggested_frontdoor = identifier.suggest_frontdoor(llm=gpt4, treatment=treatment, outcome=outcome, confounders=suggested_confounders)
-suggested_iv = identifier.suggest_iv(llm=gpt4, treatment=treatment, outcome=outcome, confounders=suggested_confounders)
+# Suggest a backdoor set, mediator set, and iv set
+suggested_backdoor = identifier.suggest_backdoor(treatment, outcome, all_factors, domain_expertises)
+suggested_mediators = identifier.suggest_mediators(treatment, outcome, all_factors, domain_expertises)
+suggested_iv = identifier.suggest_ivs(treatment, outcome, all_factors, domain_expertises)
-# Suggest an estimand based on the suggester backdoor set, front door set, and iv set
-estimand = identifier.suggest_estimand(confounders=suggested_confounders, treatment=treatment, outcome=outcome, backdoor=suggested_backdoor, frontdoor=suggested_frontdoor, iv=suggested_iv, llm=gpt4)
```
@@ -72,20 +76,16 @@ estimand = identifier.suggest_estimand(confounders=suggested_confounders, treatm
```python
# Create instance of Validator
-validator = Validator()
+validator = ValidationSuggester('gpt-4')
-# Suggest a critique of the provided DAG
-suggested_critiques_dag = validator.critique_graph(graph=suggested_dag, llm=gpt4)
+# Suggest a critique of the edges in provided DAG
+suggested_critiques_dag = validator.critique_graph(all_factors, suggested_dag, domain_expertises, RelationshipStrategy.Pairwise)
# Suggest latent confounders
-suggested_latent_confounders = validator.suggest_latent_confounders(treatment=treatment, outcome=outcome, llm=gpt4)
+suggested_latent_confounders = validator.suggest_latent_confounders(treatment, outcome, all_factors, domain_expertises)
# Suggest negative controls
-suggested_negative_controls = validator.suggest_negative_controls(variables=selected_variables, treatment=treatment, outcome=outcome, llm=gpt4)
-
-plt.figure(figsize=(10, 5))
-nx.draw(suggested_critiques_dag, with_labels=True, node_color='lightblue')
-plt.show()
+suggested_negative_controls = validator.suggest_negative_controls(treatment, outcome, all_factors, domain_expertises)
```
diff --git a/pywhyllm/suggesters/identification_suggester.py b/pywhyllm/suggesters/identification_suggester.py
index 78a513a..5cd0d15 100644
--- a/pywhyllm/suggesters/identification_suggester.py
+++ b/pywhyllm/suggesters/identification_suggester.py
@@ -19,7 +19,7 @@ def __init__(self, llm=None):
# self,
# treatment: str,
# outcome: str,
- # factors_list: list(),
+ # all_factors: list(),
# llm: guidance.models,
# backdoor: Set[str] = None,
# frontdoor: Set[str] = None,
@@ -41,7 +41,7 @@ def __init__(self, llm=None):
# backdoor_edges, backdoor_set = self.suggest_backdoor(
# treatment=treatment,
# outcome=outcome,
- # factors_list=factors_list,
+ # all_factors=all_factors,
# llm=llm,
# experts=experts,
# analysis_context=analysis_context,
@@ -66,7 +66,7 @@ def __init__(self, llm=None):
# frontdoor_edges, frontdoor_set = self.suggest_frontdoor(
# treatment=treatment,
# outcome=outcome,
- # factors_list=factors_list,
+ # all_factors=all_factors,
# llm=llm,
# experts=experts,
# analysis_context=analysis_context,
@@ -87,7 +87,7 @@ def __init__(self, llm=None):
# ivs_edges, ivs_set = self.suggest_ivs(
# treatment=treatment,
# outcome=outcome,
- # factors_list=factors_list,
+ # all_factors=all_factors,
# llm=llm,
# experts=experts,
# analysis_context=analysis_context,
@@ -116,15 +116,15 @@ def suggest_backdoor(
self,
treatment: str,
outcome: str,
- factors_list: list(),
+ all_factors: list(),
expertise_list: list(),
- analysis_context=CONTEXT,
+ analysis_context: str = CONTEXT,
stakeholders: list() = None
):
backdoor_set = self.model_suggester.suggest_confounders(
treatment=treatment,
outcome=outcome,
- factors_list=factors_list,
+ all_factors=all_factors,
expertise_list=expertise_list,
analysis_context=analysis_context,
stakeholders=stakeholders
@@ -136,9 +136,9 @@ def suggest_frontdoor(
self,
treatment: str,
outcome: str,
- factors_list: list(),
+ all_factors: list(),
expertise_list: list(),
- analysis_context=CONTEXT,
+ analysis_context: str = CONTEXT,
stakeholders: list() = None
):
pass
@@ -147,9 +147,9 @@ def suggest_mediators(
self,
treatment: str,
outcome: str,
- factors_list: list(),
+ all_factors: list(),
expertise_list: list(),
- analysis_context=CONTEXT,
+ analysis_context: str = CONTEXT,
stakeholders: list() = None
):
expert_list: List[str] = list()
@@ -164,16 +164,16 @@ def suggest_mediators(
mediators_edges[(treatment, outcome)] = 1
edited_factors_list: List[str] = []
- for i in range(len(factors_list)):
- if factors_list[i] != treatment and factors_list[i] != outcome:
- edited_factors_list.append(factors_list[i])
+ for i in range(len(all_factors)):
+ if all_factors[i] != treatment and all_factors[i] != outcome:
+ edited_factors_list.append(all_factors[i])
for expert in expert_list:
mediators_edges, mediators_list = self.request_mediators(
treatment=treatment,
outcome=outcome,
domain_expertise=expert,
- factors_list=edited_factors_list,
+ all_factors=edited_factors_list,
mediators_edges=mediators_edges,
analysis_context=analysis_context
)
@@ -187,9 +187,9 @@ def request_mediators(
treatment,
outcome,
domain_expertise,
- factors_list,
+ all_factors,
mediators_edges,
- analysis_context=CONTEXT
+ analysis_context: str = CONTEXT
):
mediators: List[str] = list()
@@ -218,7 +218,7 @@ def request_mediators(
on the causal chain that links the {treatment} to the {outcome}? From your perspective as an expert in
{domain_expertise}, which factor(s) of the following factors, if any at all, mediates, is/are on the causal
chain, that links the {treatment} to the {outcome}? Then provide your step by step chain of thoughts within
- the tags . factor_names : {factors_list} Wrap the name of the factor(s), if any at all,
+ the tags . factor_names : {all_factors} Wrap the name of the factor(s), if any at all,
that has/have a high likelihood of directly influencing and causing the assignment of the {outcome} and also
has/have a high likelihood of being directly influenced and caused by the assignment of the {treatment} within
the tags factor_name. Where factor_name is one of the items within the
@@ -237,7 +237,7 @@ def request_mediators(
if mediating_factor:
for factor in mediating_factor:
# to not add it twice into the list
- if factor in factors_list and factor not in mediators:
+ if factor in all_factors and factor not in mediators:
mediators.append(factor)
success = True
@@ -262,9 +262,9 @@ def suggest_ivs(
self,
treatment: str,
outcome: str,
- factors_list: list(),
+ all_factors: list(),
expertise_list: list(),
- analysis_context=CONTEXT,
+ analysis_context: str = CONTEXT,
stakeholders: list() = None
):
expert_list: List[str] = list()
@@ -279,9 +279,9 @@ def suggest_ivs(
iv_edges[(treatment, outcome)] = 1
edited_factors_list: List[str] = []
- for i in range(len(factors_list)):
- if factors_list[i] != treatment and factors_list[i] != outcome:
- edited_factors_list.append(factors_list[i])
+ for i in range(len(all_factors)):
+ if all_factors[i] != treatment and all_factors[i] != outcome:
+ edited_factors_list.append(all_factors[i])
for expert in expert_list:
iv_edges, iv_list = self.request_ivs(
@@ -289,7 +289,7 @@ def suggest_ivs(
outcome=outcome,
analysis_context=analysis_context,
domain_expertise=expert,
- factors_list=edited_factors_list,
+ all_factors=edited_factors_list,
iv_edges=iv_edges,
)
@@ -305,7 +305,7 @@ def request_ivs(
outcome,
analysis_context,
domain_expertise,
- factors_list,
+ all_factors,
iv_edges
):
ivs: List[str] = list()
@@ -338,7 +338,7 @@ def request_ivs(
the {outcome}? Which factor(s) of the following factors, if any at all, are (an) instrumental variable(s)
to the causal relationship of the {treatment} causing the {outcome}? Be concise and keep your thinking
within two paragraphs. Then provide your step by step chain of thoughts within the tags
- . factor_names : {factors_list} Wrap the name of the factor(s), if there are any at
+ . factor_names : {all_factors} Wrap the name of the factor(s), if there are any at
all, that both has/have a high likelihood of influecing and causing the {treatment} and has/have a very low
likelihood of influencing and causing the {outcome}, within the tags factor_name.
Where factor_name is one of the items within the factor_names list. If a factor does not have a high
@@ -353,7 +353,7 @@ def request_ivs(
if iv_factors:
for factor in iv_factors:
- if factor in factors_list and factor not in ivs:
+ if factor in all_factors and factor not in ivs:
ivs.append(factor)
success = True
diff --git a/pywhyllm/suggesters/model_suggester.py b/pywhyllm/suggesters/model_suggester.py
index 7d5fc33..b7b9df2 100644
--- a/pywhyllm/suggesters/model_suggester.py
+++ b/pywhyllm/suggesters/model_suggester.py
@@ -17,9 +17,9 @@ def __init__(self, llm=None):
def suggest_domain_expertises(
self,
- factors_list,
+ all_factors,
n_experts: int = 1,
- analysis_context=CONTEXT
+ analysis_context: str = CONTEXT
):
expertise_list: List[str] = list()
@@ -34,7 +34,7 @@ def suggest_domain_expertises(
with user():
prompt_str = f"""What domain expertises have the knowledge and experience needed to identify causal
relationships and causal influences between the {analysis_context}? What domain expertises are needed
- to work with and reason about the causal influence between {factors_list}? What domain expertises
+ to work with and reason about the causal influence between {all_factors}? What domain expertises
have the knowledge and experience to reason and answer questions about influence and cause between
such factors? Think about this in a step by step manner and recommend {n_experts} expertises and
provide each one wrapped within the tags, , along with the
@@ -61,9 +61,9 @@ def suggest_domain_expertises(
def suggest_domain_experts(
self,
- factors_list,
+ all_factors,
n_experts: int = 5,
- analysis_context=CONTEXT
+ analysis_context: str = CONTEXT
):
experts_list: Set[str] = set()
@@ -77,7 +77,7 @@ def suggest_domain_experts(
with user():
prompt_str = f"""What domain experts have the knowledge and experience needed to identify causal relationships
and causal influences between the {analysis_context}? What experts are needed to work with and
- reason about the causal influence between {factors_list}? What domain experts have the knowledge
+ reason about the causal influence between {all_factors}? What domain experts have the knowledge
and experience to reason and answer questions about influence and cause between such factors? Think
about this in a step by step manner and recommend {n_experts} domain experts and provide each one
wrapped within the tags, , along with the reasoning and explanation
@@ -104,9 +104,9 @@ def suggest_domain_experts(
def suggest_stakeholders(
self,
- factors_list,
+ all_factors,
n_stakeholders: int = 5, # must be > 1
- analysis_context=CONTEXT
+ analysis_context: str = CONTEXT
):
stakeholder_list: List[str] = list()
@@ -122,7 +122,7 @@ def suggest_stakeholders(
with user():
prompt_str = f"""What stakeholders have knowledge and experience in and about {analysis_context}?
What stakeholders can work best with and reason well about the causal influence between
- {factors_list}? What stakeholders have the knowledge and experience useful to reason within this context? Think about
+ {all_factors}? What stakeholders have the knowledge and experience useful to reason within this context? Think about
this in a step by step manner and recommend {n_stakeholders} stakeholders. Then provide each useful stakeholder
wrapped within the tags, , along with the reasoning and explanation wrapped between the tags
."""
@@ -152,7 +152,7 @@ def suggest_confounders(
self,
treatment: str,
outcome: str,
- factors_list: list,
+ all_factors: list,
expertise_list: list,
analysis_context: str = CONTEXT,
stakeholders: list = None
@@ -170,9 +170,9 @@ def suggest_confounders(
confounders: List[str] = list()
edited_factors_list: List[str] = []
- for i in range(len(factors_list)):
- if factors_list[i] != treatment and factors_list[i] != outcome:
- edited_factors_list.append(factors_list[i])
+ for i in range(len(all_factors)):
+ if all_factors[i] != treatment and all_factors[i] != outcome:
+ edited_factors_list.append(all_factors[i])
for expert in expertise_list:
confounders_edges, confounders_list = self.request_confounders(
@@ -180,7 +180,7 @@ def suggest_confounders(
outcome=outcome,
analysis_context=analysis_context,
domain_expertise=expert,
- factors_list=edited_factors_list,
+ all_factors=edited_factors_list,
confounders_edges=confounders_edges
)
@@ -195,9 +195,9 @@ def request_confounders(
treatment,
outcome,
domain_expertise,
- factors_list,
+ all_factors,
confounders_edges,
- analysis_context=CONTEXT
+ analysis_context: str = CONTEXT
):
confounders: List[str] = list()
@@ -229,7 +229,7 @@ def request_confounders(
keep your
thinking within two paragraphs. Then provide your step by step chain of thoughts within the tags
. \n factor_names :
- {factors_list} Wrap the name of the factor(s), if any at all, that has/have a high likelihood of directly influencing
+ {all_factors} Wrap the name of the factor(s), if any at all, that has/have a high likelihood of directly influencing
and causing both the {treatment} and the {outcome}, within the tags
factor_name where
factor_name is one of the items within the factor_names list. If a factor does not have a high likelihood of directly
@@ -244,7 +244,7 @@ def request_confounders(
if confounding_factors:
for factor in confounding_factors:
# to not add it twice into the list
- if factor in factors_list and factor not in confounders:
+ if factor in all_factors and factor not in confounders:
confounders.append(factor)
success = True
@@ -269,14 +269,14 @@ def suggest_parents(
self,
domain_expertise,
factor,
- factors_list,
- analysis_context=CONTEXT
+ all_factors,
+ analysis_context: str = CONTEXT
):
parent_candidates: List[str] = []
- for i in range(len(factors_list)):
- if factors_list[i] != factor:
- parent_candidates.append(factors_list[i])
+ for i in range(len(all_factors)):
+ if all_factors[i] != factor:
+ parent_candidates.append(all_factors[i])
parents: List[str] = list()
@@ -303,7 +303,7 @@ def suggest_parents(
(2) From your perspective as an expert in {domain_expertise} which of the following
factors has
a high likelihood of directly influencing and causing the {factor}? factors list: [
-{factors_list}]
+{all_factors}]
For any factors within the list with a high likelihood of directly influencing and causing
the {factor} wrap the name of the factor with the tags
factor_name.
@@ -335,15 +335,15 @@ def suggest_children(
self,
domain_expertise,
factor,
- factors_list,
- analysis_context=CONTEXT
+ all_factors,
+ analysis_context: str = CONTEXT
):
children_candidates: List[str] = []
- for i in range(len(factors_list)):
- if factors_list[i] != factor:
- children_candidates.append(factors_list[i])
+ for i in range(len(all_factors)):
+ if all_factors[i] != factor:
+ children_candidates.append(all_factors[i])
children: List[str] = list()
@@ -373,7 +373,7 @@ def suggest_children(
list,
if any at all, has/have a high likelihood of being directly influenced and caused by the {factor}? What
factor(
- s) from the factors list, if any at all, is/are affected by the {factor}? factors list: [{factors_list}]
+ s) from the factors list, if any at all, is/are affected by the {factor}? factors list: [{all_factors}]
For
any factors within the list with a high likelihood of being directly influenced and caused by the {factor},
wrap the name of the factor with the tags factor_name. If a factor
@@ -467,9 +467,9 @@ def suggest_relationships(
self,
treatment: str,
outcome: str,
- factors_list: list,
+ all_factors: list,
expertise_list: list,
- relationship_strategy: RelationshipStrategy = RelationshipStrategy.Parent,
+ relationship_strategy: RelationshipStrategy = RelationshipStrategy.Pairwise,
analysis_context: str = CONTEXT,
stakeholders: list = None,
):
@@ -483,19 +483,19 @@ def suggest_relationships(
if relationship_strategy == RelationshipStrategy.Parent:
"loop asking parents program"
parent_edges: Dict[Tuple[str, str], int] = dict()
- for factor in factors_list:
+ for factor in all_factors:
for expert in expert_list:
suggested_parent = self.suggest_parents(
domain_expertise=expert,
factor=factor,
- factors_list=factors_list,
+ all_factors=all_factors,
analysis_context=analysis_context
)
for element in suggested_parent:
if (
element,
factor,
- ) in parent_edges and element in factors_list:
+ ) in parent_edges and element in all_factors:
parent_edges[(element, factor)] += 1
else:
parent_edges[(element, factor)] = 1
@@ -507,19 +507,19 @@ def suggest_relationships(
children_edges: Dict[Tuple[str, str], int] = dict()
- for factor in factors_list:
+ for factor in all_factors:
for expert in expert_list:
suggested_children = self.suggest_children(
domain_expertise=expert,
factor=factor,
- factors_list=factors_list,
+ all_factors=all_factors,
analysis_context=analysis_context
)
for element in suggested_children:
if (
element,
factor,
- ) in children_edges and element in factors_list:
+ ) in children_edges and element in all_factors:
children_edges[(element, factor)] += 1
else:
children_edges[(element, factor)] = 1
@@ -531,7 +531,7 @@ def suggest_relationships(
pairwise_edges: Dict[Tuple[str, str], int] = dict()
- for (factor_a, factor_b) in itertools.combinations(factors_list, 2):
+ for (factor_a, factor_b) in itertools.combinations(all_factors, 2):
for expert in expert_list:
suggested_edge = self.suggest_pairwise_relationship(
domain_expertise=expert,
@@ -554,7 +554,7 @@ def suggest_relationships(
confounders_counter, confounders = self.suggest_confounders(
treatment=treatment,
outcome=outcome,
- factors_list=factors_list,
+ all_factors=all_factors,
expertise_list=expertise_list,
analysis_context=analysis_context
)
diff --git a/pywhyllm/suggesters/validation_suggester.py b/pywhyllm/suggesters/validation_suggester.py
index 337fbd7..dcd0cc5 100644
--- a/pywhyllm/suggesters/validation_suggester.py
+++ b/pywhyllm/suggesters/validation_suggester.py
@@ -23,9 +23,9 @@ def suggest_negative_controls(
self,
treatment: str,
outcome: str,
- factors_list: list(),
+ all_factors: list(),
expertise_list: list(),
- analysis_context=CONTEXT,
+ analysis_context: str = CONTEXT,
stakeholders: list() = None
):
expert_list: List[str] = list()
@@ -39,16 +39,16 @@ def suggest_negative_controls(
negative_controls: List[str] = list()
edited_factors_list: List[str] = []
- for i in range(len(factors_list)):
- if factors_list[i] != treatment and factors_list[i] != outcome:
- edited_factors_list.append(factors_list[i])
+ for i in range(len(all_factors)):
+ if all_factors[i] != treatment and all_factors[i] != outcome:
+ edited_factors_list.append(all_factors[i])
for expert in expert_list:
negative_controls_counter,
negative_controls_list = self.request_negative_controls(
treatment=treatment,
outcome=outcome,
- factors_list=edited_factors_list,
+ all_factors=edited_factors_list,
negative_controls_counter=negative_controls_counter,
domain_expertise=expert,
analysis_context=analysis_context
@@ -63,10 +63,10 @@ def request_negative_controls(
self,
treatment: str,
outcome: str,
- factors_list: list(),
+ all_factors: list(),
negative_controls_counter: list(),
domain_expertise: str,
- analysis_context=CONTEXT
+ analysis_context: str = CONTEXT
):
negative_controls_list: List[str] = list()
@@ -84,7 +84,7 @@ def request_negative_controls(
lm += cleandoc(prompt_str)
with user():
- prompt_str = f"""factor_names: {factors_list} From your perspective as an expert in the {domain_expertise}, what factor(s) from the list of factors, relevant to
+ prompt_str = f"""factor_names: {all_factors} From your perspective as an expert in the {domain_expertise}, what factor(s) from the list of factors, relevant to
the {analysis_context}, should see zero treatment effect when changing the {treatment}? Which factor(s)
from the list of factors, if any at all, relevant to the {analysis_context}, are negative controls on the
causal mechanisms that affect the {outcome} when changing {treatment}? Using your domain knowledge,
@@ -113,7 +113,7 @@ def request_negative_controls(
for factor in negative_controls:
# to not add it twice into the list
if (
- factor in factors_list
+ factor in all_factors
and factor not in negative_controls_list
):
negative_controls_list.append(factor)
@@ -135,7 +135,7 @@ def suggest_latent_confounders(
treatment: str,
outcome: str,
expertise_list: list(),
- analysis_context=CONTEXT,
+ analysis_context: str = CONTEXT,
stakeholders: list() = None
):
expert_list: List[str] = list()
@@ -169,7 +169,7 @@ def request_latent_confounders(
outcome: str,
latent_confounders_counter: list(),
domain_expertise: str,
- analysis_context=CONTEXT
+ analysis_context: str = CONTEXT
):
latent_confounders_list: List[str] = list()
@@ -227,15 +227,15 @@ def request_latent_confounders(
def request_parent_critique(
self,
factor,
- factors_list,
+ all_factors,
domain_expertise,
- analysis_context=CONTEXT
+ analysis_context: str = CONTEXT
):
edited_factors_list: List[str] = []
- for i in range(len(factors_list)):
- if factors_list[i] not in factor:
- edited_factors_list.append(factors_list[i])
+ for i in range(len(all_factors)):
+ if all_factors[i] not in factor:
+ edited_factors_list.append(all_factors[i])
parents: List[str] = list()
@@ -250,10 +250,10 @@ def request_parent_critique(
lm += cleandoc(prompt_str)
with user():
prompt_str = f"""Steps: (1)
- Analyze potential factors [{factors_list}] for factors directly influencing/causing/affecting {
+ Analyze potential factors [{all_factors}] for factors directly influencing/causing/affecting {
factor}. Is relationship direct? Ignore feedback mechanisms/factors not in list. Keep thoughts within
tags. (2) Use prior thoughts to answer: how {factor} influenced/caused/affected by [
- {factors_list}]? Is relationship direct? Ignore feedback mechanisms/factors not in list. Wrap
+ {all_factors}]? Is relationship direct? Ignore feedback mechanisms/factors not in list. Wrap
factors highly likely directly influencing/causing/affecting {factor} in
tags. No tags for low likelihood factors. Ignore feedback
mechanisms/factors not in list. Answer as {domain_expertise} expert."""
@@ -280,15 +280,15 @@ def request_parent_critique(
def request_children_critique(
self,
factor,
- factors_list,
+ all_factors,
domain_expertise,
- analysis_context=CONTEXT
+ analysis_context: str = CONTEXT
):
edited_factors_list: List[str] = []
- for i in range(len(factors_list)):
- if factors_list[i] not in factor:
- edited_factors_list.append(factors_list[i])
+ for i in range(len(all_factors)):
+ if all_factors[i] not in factor:
+ edited_factors_list.append(all_factors[i])
children: List[str] = list()
@@ -305,10 +305,10 @@ def request_children_critique(
with user():
prompt_str = f"""Steps: (
- 1) Analyze potential factors [{factors_list}] for factors directly influenced/caused/affected by
+ 1) Analyze potential factors [{all_factors}] for factors directly influenced/caused/affected by
{factor}. Is relationship direct? Ignore feedback mechanisms/factors not in list. Keep thoughts within
tags. (2) Use prior thoughts to answer: how {factor} influences/causes/affects [{
- factors_list}]? Is relationship direct? Ignore feedback mechanisms/factors not in list. Wrap
+ all_factors}]? Is relationship direct? Ignore feedback mechanisms/factors not in list. Wrap
factors highly likely directly influenced/caused/affected by {factor} in
tags. No tags for low likelihood factors. Ignore feedback
mechanisms/factors not in list. Answer as {domain_expertise} expert."""
@@ -389,10 +389,10 @@ def request_pairwise_critique(
def critique_graph(
self,
- factors_list: List[str],
+ all_factors: List[str],
edges: Dict[Tuple[str, str], int],
experts: list(),
- relationship_strategy: RelationshipStrategy = RelationshipStrategy.Parent,
+ relationship_strategy: RelationshipStrategy = RelationshipStrategy.Pairwise,
analysis_context: str = CONTEXT,
stakeholders: list() = None,
):
@@ -408,19 +408,19 @@ def critique_graph(
parent_edges: Dict[Tuple[str, str], int] = dict()
- for factor in factors_list:
+ for factor in all_factors:
for expert in expert_list:
suggested_parent = self.request_parent_critique(
analysis_context=analysis_context,
factor=factor,
- factors_list=factors_list,
+ all_factors=all_factors,
domain_expertise=expert
)
for element in suggested_parent:
if (
element,
factor,
- ) in parent_edges and element in factors_list:
+ ) in parent_edges and element in all_factors:
parent_edges[(element, factor)] += 1
else:
parent_edges[(element, factor)] = 1
@@ -432,16 +432,16 @@ def critique_graph(
critiqued_children_edges: Dict[Tuple[str, str], int] = dict()
- for factor in factors_list:
+ for factor in all_factors:
for expert in expert_list:
suggested_children = self.request_children_critique(
factor=factor,
- factors_list=factors_list,
+ all_factors=all_factors,
domain_expertise=expert,
analysis_context=analysis_context
)
for element in suggested_children:
- if (element, factor) in critiqued_children_edges and element in factors_list:
+ if (element, factor) in critiqued_children_edges and element in all_factors:
critiqued_children_edges[(element, factor)] += 1
else:
critiqued_children_edges[(element, factor)] = 1
@@ -453,7 +453,7 @@ def critique_graph(
critiqued_pairwise_edges: Dict[Tuple[str, str], int] = dict()
- for (factor_a, factor_b) in itertools.combinations(factors_list, 2):
+ for (factor_a, factor_b) in itertools.combinations(all_factors, 2):
for expert in expert_list:
suggested_edge = self.request_pairwise_critique(
factor_a=factor_a,
diff --git a/pywhyllm/tests/__init__.py b/tests/__init__.py
similarity index 100%
rename from pywhyllm/tests/__init__.py
rename to tests/__init__.py
diff --git a/pywhyllm/tests/model_suggester/__init__.py b/tests/model_suggester/__init__.py
similarity index 100%
rename from pywhyllm/tests/model_suggester/__init__.py
rename to tests/model_suggester/__init__.py
diff --git a/pywhyllm/tests/model_suggester/data_providers/__init__.py b/tests/model_suggester/data_providers/__init__.py
similarity index 100%
rename from pywhyllm/tests/model_suggester/data_providers/__init__.py
rename to tests/model_suggester/data_providers/__init__.py
diff --git a/pywhyllm/tests/model_suggester/data_providers/identification_suggester_data_provider.py b/tests/model_suggester/data_providers/identification_suggester_data_provider.py
similarity index 100%
rename from pywhyllm/tests/model_suggester/data_providers/identification_suggester_data_provider.py
rename to tests/model_suggester/data_providers/identification_suggester_data_provider.py
diff --git a/pywhyllm/tests/model_suggester/data_providers/model_suggester_data_provider.py b/tests/model_suggester/data_providers/model_suggester_data_provider.py
similarity index 100%
rename from pywhyllm/tests/model_suggester/data_providers/model_suggester_data_provider.py
rename to tests/model_suggester/data_providers/model_suggester_data_provider.py
diff --git a/pywhyllm/tests/model_suggester/data_providers/simple_identification_suggester_data_provider.py b/tests/model_suggester/data_providers/simple_identification_suggester_data_provider.py
similarity index 100%
rename from pywhyllm/tests/model_suggester/data_providers/simple_identification_suggester_data_provider.py
rename to tests/model_suggester/data_providers/simple_identification_suggester_data_provider.py
diff --git a/pywhyllm/tests/model_suggester/data_providers/simple_model_suggester_data_provider.py b/tests/model_suggester/data_providers/simple_model_suggester_data_provider.py
similarity index 100%
rename from pywhyllm/tests/model_suggester/data_providers/simple_model_suggester_data_provider.py
rename to tests/model_suggester/data_providers/simple_model_suggester_data_provider.py
diff --git a/pywhyllm/tests/model_suggester/data_providers/tuebingen_model_suggester_data_provider.py b/tests/model_suggester/data_providers/tuebingen_model_suggester_data_provider.py
similarity index 100%
rename from pywhyllm/tests/model_suggester/data_providers/tuebingen_model_suggester_data_provider.py
rename to tests/model_suggester/data_providers/tuebingen_model_suggester_data_provider.py
diff --git a/pywhyllm/tests/model_suggester/data_providers/validation_suggester_data_provider.py b/tests/model_suggester/data_providers/validation_suggester_data_provider.py
similarity index 100%
rename from pywhyllm/tests/model_suggester/data_providers/validation_suggester_data_provider.py
rename to tests/model_suggester/data_providers/validation_suggester_data_provider.py
diff --git a/pywhyllm/tests/model_suggester/test_identification_suggester.py b/tests/model_suggester/test_identification_suggester.py
similarity index 91%
rename from pywhyllm/tests/model_suggester/test_identification_suggester.py
rename to tests/model_suggester/test_identification_suggester.py
index 5515db4..d60203d 100644
--- a/pywhyllm/tests/model_suggester/test_identification_suggester.py
+++ b/tests/model_suggester/test_identification_suggester.py
@@ -4,8 +4,9 @@
from pywhyllm.suggesters.identification_suggester import IdentificationSuggester
from pywhyllm.suggesters.model_suggester import ModelSuggester
-from pywhyllm.tests.model_suggester.data_providers.model_suggester_data_provider import *
-from pywhyllm.tests.model_suggester.data_providers.identification_suggester_data_provider import *
+from tests.model_suggester.data_providers.identification_suggester_data_provider import *
+from tests.model_suggester.data_providers.model_suggester_data_provider import *
+
class TestIdentificationSuggester(unittest.TestCase):
def test_suggest_backdoor(self):
diff --git a/pywhyllm/tests/model_suggester/test_model_suggester.py b/tests/model_suggester/test_model_suggester.py
similarity index 98%
rename from pywhyllm/tests/model_suggester/test_model_suggester.py
rename to tests/model_suggester/test_model_suggester.py
index 98292fe..38c0ef6 100644
--- a/pywhyllm/tests/model_suggester/test_model_suggester.py
+++ b/tests/model_suggester/test_model_suggester.py
@@ -3,8 +3,8 @@
from guidance.models._openai import OpenAI
from pywhyllm.suggesters.model_suggester import ModelSuggester
-from pywhyllm.tests.model_suggester.data_providers.model_suggester_data_provider import *
from pywhyllm.helpers import RelationshipStrategy
+from tests.model_suggester.data_providers.model_suggester_data_provider import *
class TestModelSuggester(unittest.TestCase):
diff --git a/pywhyllm/tests/model_suggester/test_simple_identification_suggester.py b/tests/model_suggester/test_simple_identification_suggester.py
similarity index 93%
rename from pywhyllm/tests/model_suggester/test_simple_identification_suggester.py
rename to tests/model_suggester/test_simple_identification_suggester.py
index 2e87809..a7d91e3 100644
--- a/pywhyllm/tests/model_suggester/test_simple_identification_suggester.py
+++ b/tests/model_suggester/test_simple_identification_suggester.py
@@ -3,7 +3,7 @@
from guidance.models._openai import OpenAI
from pywhyllm.suggesters.simple_identification_suggester import SimpleIdentificationSuggester
-from pywhyllm.tests.model_suggester.data_providers.simple_identification_suggester_data_provider import *
+from tests.model_suggester.data_providers.simple_identification_suggester_data_provider import *
class TestSimpleIdentificationSuggester(unittest.TestCase):
diff --git a/pywhyllm/tests/model_suggester/test_simple_model_suggester.py b/tests/model_suggester/test_simple_model_suggester.py
similarity index 97%
rename from pywhyllm/tests/model_suggester/test_simple_model_suggester.py
rename to tests/model_suggester/test_simple_model_suggester.py
index 70bd3ef..bfe5973 100644
--- a/pywhyllm/tests/model_suggester/test_simple_model_suggester.py
+++ b/tests/model_suggester/test_simple_model_suggester.py
@@ -3,7 +3,7 @@
from guidance.models._openai import OpenAI
from pywhyllm.suggesters.simple_model_suggester import SimpleModelSuggester
-from pywhyllm.tests.model_suggester.data_providers.simple_model_suggester_data_provider import *
+from tests.model_suggester.data_providers.simple_model_suggester_data_provider import *
class TestSimpleModelSuggester(unittest.TestCase):
diff --git a/pywhyllm/tests/model_suggester/test_tuebingen_model_suggester.py b/tests/model_suggester/test_tuebingen_model_suggester.py
similarity index 97%
rename from pywhyllm/tests/model_suggester/test_tuebingen_model_suggester.py
rename to tests/model_suggester/test_tuebingen_model_suggester.py
index c90e308..9d2bb25 100644
--- a/pywhyllm/tests/model_suggester/test_tuebingen_model_suggester.py
+++ b/tests/model_suggester/test_tuebingen_model_suggester.py
@@ -3,8 +3,7 @@
from guidance.models._openai import OpenAI
from pywhyllm.suggesters.tuebingen_model_suggester import TuebingenModelSuggester, Strategy
-from pywhyllm.tests.model_suggester.data_providers.tuebingen_model_suggester_data_provider import *
-
+from tests.model_suggester.data_providers.tuebingen_model_suggester_data_provider import *
class TestTuebingenModelSuggester(unittest.TestCase):
def test_suggest_description(self):
diff --git a/pywhyllm/tests/model_suggester/test_validation_suggester.py b/tests/model_suggester/test_validation_suggester.py
similarity index 96%
rename from pywhyllm/tests/model_suggester/test_validation_suggester.py
rename to tests/model_suggester/test_validation_suggester.py
index dd3a014..106ec5b 100644
--- a/pywhyllm/tests/model_suggester/test_validation_suggester.py
+++ b/tests/model_suggester/test_validation_suggester.py
@@ -4,10 +4,9 @@
from guidance.models._openai import OpenAI
from pywhyllm.suggesters.validation_suggester import ValidationSuggester
-from pywhyllm.tests.model_suggester.data_providers.validation_suggester_data_provider import *
-from pywhyllm.tests.model_suggester.data_providers.model_suggester_data_provider import *
from pywhyllm.helpers import RelationshipStrategy
-
+from tests.model_suggester.data_providers.model_suggester_data_provider import *
+from tests.model_suggester.data_providers.validation_suggester_data_provider import *
class TestValidationSuggester(unittest.TestCase):
def test_suggest_latent_confounders(self):
diff --git a/pywhyllm/tests/test_notebooks.py b/tests/test_notebooks.py
similarity index 100%
rename from pywhyllm/tests/test_notebooks.py
rename to tests/test_notebooks.py