Skip to content

Commit

Permalink
minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
amaiya committed Oct 20, 2021
1 parent af77750 commit c21406f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- Sensitivity analysis to [assess robustness of causal estimates](https://amaiya.github.io/causalnlp/causalinference.html#CausalInferenceModel.evaluate_robustness)
- Quick and simple [key driver analysis](https://amaiya.github.io/causalnlp/key_driver_analysis.html) to yield clues on potential drivers of an outcome based on predictive power, correlations, etc.
- Can easily be applied to ["traditional" tabular datasets without text](https://amaiya.github.io/causalnlp/examples.html#What-is-the-causal-impact-of-having-a-PhD-on-making-over-$50K?) (i.e., datasets with only numerical and categorical variables)
- Includes an experimental PyTorch implementation of [CausalBert](https://arxiv.org/abs/1905.12741) by Veitch, Sridar, and Blei (based on [reference implementation](https://github.com/rpryzant/causal-bert-pytorch) by R. Pryzant)
- Includes an experimental [PyTorch implementation](https://amaiya.github.io/causalnlp/core.causalbert.html) of [CausalBert](https://arxiv.org/abs/1905.12741) by Veitch, Sridar, and Blei (based on [reference implementation](https://github.com/rpryzant/causal-bert-pytorch) by R. Pryzant)

## Install

Expand Down
9 changes: 8 additions & 1 deletion docs/core.causalbert.html
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ <h4 id="CausalBertModel.inference" class="doc_header"><code>CausalBertModel.infe

<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Example">Example<a class="anchor-link" href="#Example"> </a></h3><p>This implementation of <a href="/causalnlp/core.causalbert.html#CausalBert"><code>CausalBert</code></a> was adapted from <a href="https://arxiv.org/abs/2010.12919">Causal Effects of Linguistic Properties</a> by Pryzant et al. <a href="/causalnlp/core.causalbert.html#CausalBert"><code>CausalBert</code></a> is essentially an <a href="https://arxiv.org/abs/1706.03461">S-Learner</a> that uses a DistilBert sequence classification model as the base learner.</p>
<h3 id="Example">Example<a class="anchor-link" href="#Example"> </a></h3><p>This implementation of <a href="/causalnlp/core.causalbert.html#CausalBert"><code>CausalBert</code></a> was adapted from <a href="https://arxiv.org/abs/2010.12919">Causal Effects of Linguistic Properties</a> by Pryzant et al. <a href="/causalnlp/core.causalbert.html#CausalBert"><code>CausalBert</code></a> is essentially a kind of <a href="https://arxiv.org/abs/1706.03461">S-Learner</a> that uses a DistilBert sequence classification model as the base learner.</p>

</div>
</div>
Expand Down Expand Up @@ -302,6 +302,13 @@ <h3 id="Example">Example<a class="anchor-link" href="#Example"> </a></h3><p>This
</div>
{% endraw %}

<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>(Reduce the <code>batch_size</code> if you receive an Out-Of-Memory error when running the code above.)</p>

</div>
</div>
</div>
</div>


2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h2 id="Features">Features<a class="anchor-link" href="#Features"> </a></h2><ul>
<li>Sensitivity analysis to <a href="https://amaiya.github.io/causalnlp/causalinference.html#CausalInferenceModel.evaluate_robustness">assess robustness of causal estimates</a></li>
<li>Quick and simple <a href="https://amaiya.github.io/causalnlp/key_driver_analysis.html">key driver analysis</a> to yield clues on potential drivers of an outcome based on predictive power, correlations, etc.</li>
<li>Can easily be applied to <a href="https://amaiya.github.io/causalnlp/examples.html#What-is-the-causal-impact-of-having-a-PhD-on-making-over-$50K?">"traditional" tabular datasets without text</a> (i.e., datasets with only numerical and categorical variables)</li>
<li>Includes an experimental PyTorch implementation of <a href="https://arxiv.org/abs/1905.12741">CausalBert</a> by Veitch, Sridar, and Blei (based on <a href="https://github.com/rpryzant/causal-bert-pytorch">reference implementation</a> by R. Pryzant)</li>
<li>Includes an experimental <a href="https://amaiya.github.io/causalnlp/core.causalbert.html">PyTorch implementation</a> of <a href="https://arxiv.org/abs/1905.12741">CausalBert</a> by Veitch, Sridar, and Blei (based on <a href="https://github.com/rpryzant/causal-bert-pytorch">reference implementation</a> by R. Pryzant)</li>
</ul>

</div>
Expand Down
6 changes: 3 additions & 3 deletions docs/meta.utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ <h4 id="gini" class="doc_header"><code>gini</code><a href="https://github.com/am


<div class="output_markdown rendered_html output_subarea ">
<h4 id="regression_metrics" class="doc_header"><code>regression_metrics</code><a href="https://github.com/amaiya/causalnlp/tree/main/causalnlp/meta/utils.py#L235" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>regression_metrics</code>(<strong><code>y</code></strong>, <strong><code>p</code></strong>, <strong><code>w</code></strong>=<em><code>None</code></em>, <strong><code>metrics</code></strong>=<em><code>{'RMSE': &lt;function rmse at 0x7fbf81afa598&gt;, 'sMAPE': &lt;function smape at 0x7fbf81afa510&gt;, 'Gini': &lt;function gini at 0x7fbf81afa620&gt;}</code></em>)</p>
<h4 id="regression_metrics" class="doc_header"><code>regression_metrics</code><a href="https://github.com/amaiya/causalnlp/tree/main/causalnlp/meta/utils.py#L235" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>regression_metrics</code>(<strong><code>y</code></strong>, <strong><code>p</code></strong>, <strong><code>w</code></strong>=<em><code>None</code></em>, <strong><code>metrics</code></strong>=<em><code>{'RMSE': &lt;function rmse at 0x7f3dc9fc9598&gt;, 'sMAPE': &lt;function smape at 0x7f3dc9fc9510&gt;, 'Gini': &lt;function gini at 0x7f3dc9fc9620&gt;}</code></em>)</p>
</blockquote>
<p>Log metrics for regressors.</p>
<p>Args:
Expand Down Expand Up @@ -424,7 +424,7 @@ <h4 id="logloss" class="doc_header"><code>logloss</code><a href="https://github.


<div class="output_markdown rendered_html output_subarea ">
<h4 id="classification_metrics" class="doc_header"><code>classification_metrics</code><a href="https://github.com/amaiya/causalnlp/tree/main/causalnlp/meta/utils.py#L279" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>classification_metrics</code>(<strong><code>y</code></strong>, <strong><code>p</code></strong>, <strong><code>w</code></strong>=<em><code>None</code></em>, <strong><code>metrics</code></strong>=<em><code>{'AUC': &lt;function roc_auc_score at 0x7fbfb1f95950&gt;, 'Log Loss': &lt;function logloss at 0x7fbf81afa730&gt;}</code></em>)</p>
<h4 id="classification_metrics" class="doc_header"><code>classification_metrics</code><a href="https://github.com/amaiya/causalnlp/tree/main/causalnlp/meta/utils.py#L279" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>classification_metrics</code>(<strong><code>y</code></strong>, <strong><code>p</code></strong>, <strong><code>w</code></strong>=<em><code>None</code></em>, <strong><code>metrics</code></strong>=<em><code>{'AUC': &lt;function roc_auc_score at 0x7f3dfa465950&gt;, 'Log Loss': &lt;function logloss at 0x7f3dc9fc9730&gt;}</code></em>)</p>
</blockquote>
<p>Log metrics for classifiers.</p>
<p>Args:
Expand Down Expand Up @@ -566,7 +566,7 @@ <h2 id="NearestNeighborMatch" class="doc_header"><code>class</code> <code>Neares


<div class="output_markdown rendered_html output_subarea ">
<h2 id="MatchOptimizer" class="doc_header"><code>class</code> <code>MatchOptimizer</code><a href="https://github.com/amaiya/causalnlp/tree/main/causalnlp/meta/utils.py#L501" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>MatchOptimizer</code>(<strong><code>treatment_col</code></strong>=<em><code>'is_treatment'</code></em>, <strong><code>ps_col</code></strong>=<em><code>'pihat'</code></em>, <strong><code>user_col</code></strong>=<em><code>None</code></em>, <strong><code>matching_covariates</code></strong>=<em><code>['pihat']</code></em>, <strong><code>max_smd</code></strong>=<em><code>0.1</code></em>, <strong><code>max_deviation</code></strong>=<em><code>0.1</code></em>, <strong><code>caliper_range</code></strong>=<em><code>(0.01, 0.5)</code></em>, <strong><code>max_pihat_range</code></strong>=<em><code>(0.95, 0.999)</code></em>, <strong><code>max_iter_per_param</code></strong>=<em><code>5</code></em>, <strong><code>min_users_per_group</code></strong>=<em><code>1000</code></em>, <strong><code>smd_cols</code></strong>=<em><code>['pihat']</code></em>, <strong><code>dev_cols_transformations</code></strong>=<em><code>{'pihat': &lt;function mean at 0x7fc0245b52f0&gt;}</code></em>, <strong><code>dev_factor</code></strong>=<em><code>1.0</code></em>, <strong><code>verbose</code></strong>=<em><code>True</code></em>)</p>
<h2 id="MatchOptimizer" class="doc_header"><code>class</code> <code>MatchOptimizer</code><a href="https://github.com/amaiya/causalnlp/tree/main/causalnlp/meta/utils.py#L501" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>MatchOptimizer</code>(<strong><code>treatment_col</code></strong>=<em><code>'is_treatment'</code></em>, <strong><code>ps_col</code></strong>=<em><code>'pihat'</code></em>, <strong><code>user_col</code></strong>=<em><code>None</code></em>, <strong><code>matching_covariates</code></strong>=<em><code>['pihat']</code></em>, <strong><code>max_smd</code></strong>=<em><code>0.1</code></em>, <strong><code>max_deviation</code></strong>=<em><code>0.1</code></em>, <strong><code>caliper_range</code></strong>=<em><code>(0.01, 0.5)</code></em>, <strong><code>max_pihat_range</code></strong>=<em><code>(0.95, 0.999)</code></em>, <strong><code>max_iter_per_param</code></strong>=<em><code>5</code></em>, <strong><code>min_users_per_group</code></strong>=<em><code>1000</code></em>, <strong><code>smd_cols</code></strong>=<em><code>['pihat']</code></em>, <strong><code>dev_cols_transformations</code></strong>=<em><code>{'pihat': &lt;function mean at 0x7f3e6429a2f0&gt;}</code></em>, <strong><code>dev_factor</code></strong>=<em><code>1.0</code></em>, <strong><code>verbose</code></strong>=<em><code>True</code></em>)</p>
</blockquote>

</div>
Expand Down
9 changes: 8 additions & 1 deletion nbs/00b_core.causalbert.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@
"source": [
"### Example\n",
"\n",
"This implementation of `CausalBert` was adapted from [Causal Effects of Linguistic Properties](https://arxiv.org/abs/2010.12919) by Pryzant et al. `CausalBert` is essentially an [S-Learner](https://arxiv.org/abs/1706.03461) that uses a DistilBert sequence classification model as the base learner."
"This implementation of `CausalBert` was adapted from [Causal Effects of Linguistic Properties](https://arxiv.org/abs/2010.12919) by Pryzant et al. `CausalBert` is essentially a kind of [S-Learner](https://arxiv.org/abs/1706.03461) that uses a DistilBert sequence classification model as the base learner."
]
},
{
Expand Down Expand Up @@ -490,6 +490,13 @@
"print(cb.estimate_ate(df['C_true'], df['text']))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"(Reduce the `batch_size` if you receive an Out-Of-Memory error when running the code above.)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
2 changes: 1 addition & 1 deletion nbs/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"- Sensitivity analysis to [assess robustness of causal estimates](https://amaiya.github.io/causalnlp/causalinference.html#CausalInferenceModel.evaluate_robustness)\n",
"- Quick and simple [key driver analysis](https://amaiya.github.io/causalnlp/key_driver_analysis.html) to yield clues on potential drivers of an outcome based on predictive power, correlations, etc.\n",
"- Can easily be applied to [\"traditional\" tabular datasets without text](https://amaiya.github.io/causalnlp/examples.html#What-is-the-causal-impact-of-having-a-PhD-on-making-over-$50K?) (i.e., datasets with only numerical and categorical variables)\n",
"- Includes an experimental PyTorch implementation of [CausalBert](https://arxiv.org/abs/1905.12741) by Veitch, Sridar, and Blei (based on [reference implementation](https://github.com/rpryzant/causal-bert-pytorch) by R. Pryzant)"
"- Includes an experimental [PyTorch implementation](https://amaiya.github.io/causalnlp/core.causalbert.html) of [CausalBert](https://arxiv.org/abs/1905.12741) by Veitch, Sridar, and Blei (based on [reference implementation](https://github.com/rpryzant/causal-bert-pytorch) by R. Pryzant)"
]
},
{
Expand Down

0 comments on commit c21406f

Please sign in to comment.