Skip to content

Commit

Permalink
Fix typos and update documentation for ReLax
Browse files Browse the repository at this point in the history
methods
  • Loading branch information
BirkhoffG committed Nov 9, 2023
1 parent c152360 commit fa8a532
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions nbs/tutorials/methods.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
"source": [
"## Types of Recourse Methods\n",
"\n",
"1. Non-parametric methods: These methods do not rely on any learned parameters. They generate counterfactuals solely based on the model's predictions and gradients. Examples in ReLax include `VanillaCF`, `DiverseCF` and `GrowingSpheres` . These methods inherit from NonParametricCFModule.\n",
"1. Non-parametric methods: These methods do not rely on any learned parameters. They generate counterfactuals solely based on the model's predictions and gradients. Examples in ReLax include `VanillaCF`, `DiverseCF` and `GrowingSphere` . These methods inherit from `CFModule`.\n",
"\n",
"2. Semi-parametric methods: These methods learn some parameters to aid in counterfactual generation, but do not learn a full counterfactual generation model. Examples in ReLax include `ProtoCF`, `CCHVAE` and `CLUE`. These methods inherit from SemiParametricCFModule.\n",
"2. Semi-parametric methods: These methods learn some parameters to aid in counterfactual generation, but do not learn a full counterfactual generation model. Examples in ReLax include `ProtoCF`, `CCHVAE` and `CLUE`. These methods inherit from `ParametricCFModule `.\n",
"\n",
"3. Parametric methods: These methods learn a full parametric model for counterfactual generation. The model is trained to generate counterfactuals that fool the model. Examples in ReLax include `CounterNet` and `VAECF`. These methods inherit from ParametricCFModule.\n",
"3. Parametric methods: These methods learn a full parametric model for counterfactual generation. The model is trained to generate counterfactuals that fool the model. Examples in ReLax include `CounterNet` and `VAECF`. These methods inherit from `ParametricCFModule`.\n",
"\n",
"\n",
"|Method Type | Learned Parameters | Training Required | Example Methods | \n",
"|-----|:-----|:---:|:-----:|\n",
"|Non-parametric | None |No |`VanillaCF`, `DiverseCF`, `GrowingSpheres` |\n",
"|Non-parametric | None |No |`VanillaCF`, `DiverseCF`, `GrowingSphere` |\n",
"|Semi-parametric| Some (θ) |Modest amount |`ProtoCF`, `CCHVAE`, `CLUE` |\n",
"|Parametric|Full generator model (φ)|Substantial amount|`CounterNet`, `VAECF` |"
]
Expand All @@ -45,7 +45,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Basis \n",
"## Basic Usages\n",
"\n",
"At a high level, you can use the implemented methods in `ReLax` to generate *one* recourse explanation via three lines of code:\n",
"\n",
Expand Down Expand Up @@ -73,8 +73,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Example of using `ReLax` for parametric methods (using `CCHVAE`)\n",
"\n"
"To use parametric and semi-parametric methods, you can first train the model\n",
"by calling `ParametricCF.train`, and then generate recourse explanations.\n",
"Here is an example of using `ReLax` for `CCHVAE`.\n"
]
},
{
Expand All @@ -85,7 +86,8 @@
"from relax.methods import CCHVAE\n",
"\n",
"cchvae = CCHVAE()\n",
"cchvae.train(train_data) # Train counterfactual generator \n",
"cchvae.train(train_data) # Train CVAE before generation\n",
"cf = cchvae.generate_cf(x, pred_fn=pred_fn) \n",
"```\n",
"\n",
"Or generate a batch of recourse explanation via the `jax.vmap` primitive:\n",
Expand Down Expand Up @@ -123,9 +125,9 @@
"vcf = VanillaCF(config)\n",
"\n",
"```\n",
"Each Config class inherits from a BaseConfig that defines common options like n_steps. Method-specific parameters are defined on the individual Config classes.\n",
"Each Config class inherits from a `BaseConfig` that defines common options like n_steps. Method-specific parameters are defined on the individual Config classes.\n",
"\n",
"See the documentation for each recourse method for details on its supported configuration parameters. The Config class for a method can be imported from relax.methods.[method_name]."
"See the documentation for each recourse method for details on its supported configuration parameters. The Config class for a method can be imported from `relax.methods.[method_name]`."
]
},
{
Expand Down

0 comments on commit fa8a532

Please sign in to comment.