Skip to content

Commit

Permalink
Merge pull request #8 from AutoResearch/docs-sampler-to-experimentalist
Browse files Browse the repository at this point in the history
docs: sampler to experimentalist at the appropriate places
  • Loading branch information
younesStrittmatter authored Sep 2, 2023
2 parents deceff6 + d7e8f6d commit 838f1d9
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 39 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
# The Leverage Experimentalist

This sampler uses the statistical concept of leverage by refitting the provided models iteratively with the leave-one-out method.
This experimentalist uses the statistical concept of leverage by refitting the provided models iteratively with the leave-one-out method.

---
WARNING:
This sampler needs to fit each model you provide it n times, where n corresponds to the number of datapoints you have.
As such, the computational time and power needed to run this sampler increases exponentially with increasing number of models and datapoints.
This experimentalist needs to fit each model you provide it n times, where n corresponds to the number of datapoints you have.
As such, the computational time and power needed to run this experimentalist increases exponentially with increasing number of models and datapoints.

---

In each iteration, it computes the degree to which the currently removed datapoint has influence on the model.
If the model remains stable, the datapoint is deemed to have little influence on the model, and as such will have a low likelyhood of being selected for further investigation.
If the model remains stable, the datapoint is deemed to have little influence on the model, and as such will have a low likelihood of being selected for further investigation.
In contrast, if the model changes, the datapoint is influential on the model, and has a higher likelihood of being selected for further investigation.

Specifically, you provide the sampler with a model that has been trained on all of the data. On each iteration, the sampler fits a new model with all data aside from one datapoint.
Specifically, you provide the experimentalist with a model that has been trained on all of the data. On each iteration, the experimentalist fits a new model with all data aside from one datapoint.
Both models ($m$) then predict Y scores ($Y'$) from the original X variable and compute a mean squared error (MSE) for each X score ($i$):

$$MSE_{m,i} = \sum(Y'_{m,i} - Y_{i})^{2}$$

The sampler then computes a ratio of the MSE scores between the sampler model and the original model that you provided:
The experimentalist then computes a ratio of the MSE scores between the experimentalist model and the original model that you provided:

$${MSE_{Ratio}}_{m,i} = {MSE_{sampler}}_{m,i}/{MSE_{original}}_{m}$$
As such, values above one indicates that the original model fit the data better than the sampler model when removing that datapoint ($i$).
In contrast, values below one dindicates that the sampler model fit the data better than the original model when removing that datapoint ($i$).
$${MSE_{Ratio}}_{m,i} = {MSE_{experimentalist}}_{m,i}/{MSE_{original}}_{m}$$
As such, values above one indicates that the original model fit the data better than the experimentalist model when removing that datapoint ($i$).
In contrast, values below one indicates that the experimentalist model fit the data better than the original model when removing that datapoint ($i$).
And a value of one indicates that both models fit the data equally. If you provide multiple models, it will then average across these models to result in an aggregate MSE score for each X score. In the future, it might be a good idea to incorporate multiple models in a more sophisticated way.

Finally, the sampler then uses these aggregated ratios to select the next set of datapoints to explore in one of three ways, declared with the 'fit' parameter.
Finally, the experimentalist then uses these aggregated ratios to select the next set of datapoints to explore in one of three ways, declared with the 'fit' parameter.
-'increase' will choose samples focused on X scores where the fits got better (i.e., the smallest MSE ratios)
-'decrease' will choose samples focused on X scores where the fits got worse (i.e., the largest MSE ratios)
-'both' will do both of the above, or in other words focus on X scores with the most extreme scores.


# Example Code
```
from autora.experimentalist.sampler.leverage import leverage_sample
from autora.experimentalist.leverage import leverage_sample
from autora.theorist.darts import DARTSRegressor; DARTSRegressor()
from sklearn.linear_model import LogisticRegression
Expand All @@ -48,6 +48,6 @@ lr_theorist = LogisticRegression()
darts_theorist.fit(X,y)
lr_theorist.fit(X,y)
#Sampler
X_new = leverage_sample(X, y, [darts_theorist, lr_theorist], fit = 'both', n_samples = n)
#Experimentalist
X_new = leverage_sample(X, y, [darts_theorist, lr_theorist], fit = 'both', num_samples = n)
```
2 changes: 1 addition & 1 deletion docs/Basic Usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
"source": [
"# Run and Leverage Samples\n",
"\n",
"Now we will get a proposal from the sampler as to which datapoints to investigate next. We will retrieve 5 new datapoints in this example."
"Now we will get a proposal from the experimentalist as to which datapoints to investigate next. We will retrieve 5 new datapoints in this example."
]
},
{
Expand Down
18 changes: 9 additions & 9 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# The Leverage Experimentalist

This sampler uses the statistical concept of leverage by refitting the provided models iteratively with the leave-one-out method.
This experimentalist uses the statistical concept of leverage by refitting the provided models iteratively with the leave-one-out method.

---
WARNING:
This sampler needs to fit each model you provide it n times, where n corresponds to the number of datapoints you have.
As such, the computational time and power needed to run this sampler increases exponentially with increasing number of models and datapoints.
This experimentalist needs to fit each model you provide it n times, where n corresponds to the number of datapoints you have.
As such, the computational time and power needed to run this experimentalist increases exponentially with increasing number of models and datapoints.

---

In each iteration, it computes the degree to which the currently removed datapoint has influence on the model.
If the model remains stable, the datapoint is deemed to have little influence on the model, and as such will have a low likelyhood of being selected for further investigation.
In contrast, if the model changes, the datapoint is influential on the model, and has a higher likelihood of being selected for further investigation.

Specifically, you provide the sampler with a model that has been trained on all of the data. On each iteration, the sampler fits a new model with all data aside from one datapoint.
Specifically, you provide the experimentalist with a model that has been trained on all of the data. On each iteration, the experimentalist fits a new model with all data aside from one datapoint.
Both models ($m$) then predict Y scores ($Y'$) from the original X variable and compute a mean squared error (MSE) for each X score ($i$):

$$
MSE_{m,i} = \sum(Y'_{m,i} - Y_{i})^{2}
$$

The sampler then computes a ratio of the MSE scores between the sampler model and the original model that you provided:
The experimentalist then computes a ratio of the MSE scores between the experimentalist model and the original model that you provided:

$$
{MSE_{Ratio}}_{m,i} = {MSE_{sampler}}_{m,i}/{MSE_{original}}_{m}
{MSE_{Ratio}}_{m,i} = {MSE_{experimentalist}}_{m,i}/{MSE_{original}}_{m}
$$
As such, values above one indicates that the original model fit the data better than the sampler model when removing that datapoint ($i$).
In contrast, values below one dindicates that the sampler model fit the data better than the original model when removing that datapoint ($i$).
As such, values above one indicates that the original model fit the data better than the experimentalist model when removing that datapoint ($i$).
In contrast, values below one indicates that the experimentalist model fit the data better than the original model when removing that datapoint ($i$).
And a value of one indicates that both models fit the data equally. If you provide multiple models, it will then average across these models to result in an aggregate MSE score for each X score. In the future, it might be a good idea to incorporate multiple models in a more sophisticated way.

Finally, the sampler then uses these aggregated ratios to select the next set of datapoints to explore in one of three ways, declared with the 'fit' parameter.
Finally, the experimentalist then uses these aggregated ratios to select the next set of datapoints to explore in one of three ways, declared with the 'fit' parameter.
-'increase' will choose samples focused on X scores where the fits got better (i.e., the smallest MSE ratios)
-'decrease' will choose samples focused on X scores where the fits got worse (i.e., the largest MSE ratios)
-'both' will do both of the above, or in other words focus on X scores with the most extreme scores.
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You will need:

- `python` 3.8 or greater: [https://www.python.org/downloads/](https://www.python.org/downloads/)

*leverage is a part of the `autora` package:
*leverage experimentalist* is a part of the `autora` package:

```shell
pip install -U autora["experimentalist-leverage"]
Expand Down
30 changes: 15 additions & 15 deletions src/autora/experimentalist/leverage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,46 @@ def sample(
):
"""
# The Leverage Sampler
# The Leverage Experimentalist
This sampler uses the statistical concept of leverage by refitting the provided models
This experimentalist uses the statistical concept of leverage by refitting the provided models
iteratively with the leave-one-out method.
---
WARNING:
This sampler needs to fit each model you provide it n times, where n corresponds to the
This experimentalist needs to fit each model you provide it n times, where n corresponds to the
number of datapoints you have.
As such, the computational time and power needed to run this sampler increases exponentially
with increasing number of models and datapoints.
As such, the computational time and power needed to run this experimentalist increases
exponentially with increasing number of models and datapoints.
---
In each iteration, it computes the degree to which the currently removed datapoint
has influence on the model.
If the model remains stable, the datapoint is deemed to have little influence on the model,
and as such will have a low likelyhood of being selected for further investigation.
and as such will have a low likelihood of being selected for further investigation.
In contrast, if the model changes, the datapoint is influential on the model,
and has a higher likelihood of being selected for further investigation.
Specifically, you provide the sampler with a model that has been trained on all of the data.
On each iteration, the sampler fits a new model with all data aside from one datapoint.
Both models then predict Y scores from the original X variable and compute a mean squared error
(MSE) for each X score.
Specifically, you provide the experimentalist with a model that has been trained on all of
the data. On each iteration, the experimentalist fits a new model with all data aside from one
datapoint. Both models then predict Y scores from the original X variable and compute a mean
squared error (MSE) for each X score.
The sampler then computes a ratio of the MSE scores between the sampler model
The experimentalist then computes a ratio of the MSE scores between the experimentalist model
and the original model that you provided:
As such, values above one indicates that the original model fit the data better
than the sampler model when removing that datapoint.
In contrast, values below one indicates that the sampler model fit the data better
than the experimentalist model when removing that datapoint.
In contrast, values below one indicates that the experimentalist model fit the data better
than the original model when removing that datapoint.
And a value of one indicates that both models fit the data equally.
If you provide multiple models, it will then average across these models to result
in an aggregate MSE score for each X score. In the future,
it might be a good idea to incorporate multiple models in a more sophisticated way.
Finally, the sampler then uses these aggregated ratios to select the next set of datapoints
to explore in one of three ways, declared with the 'fit' parameter.
Finally, the experimentalsit then uses these aggregated ratios to select the next set of
datapoints to explore in one of three ways, declared with the 'fit' parameter.
-'increase' will choose samples focused on X scores where the fits got better
(i.e., the smallest MSE ratios)
-'decrease' will choose samples focused on X scores where the fits got worse
Expand Down

0 comments on commit 838f1d9

Please sign in to comment.