Metadata-Version: 2.1
Name: autora-experimentalist-sampler-uncertainty
Version: 1.0.1
Summary: Sampler based on where the model is least certain.
Author-email: "Built by Sebastian Musslick, restructured by Chad Williams" <sebastian_musslick@brown.edu>
License: MIT license
Project-URL: homepage, http://www.empiricalresearch.ai
Project-URL: repository, https://github.com/AutoResearch/autora-experimentalist-sampler-uncertainty
Project-URL: documentation, https://autoresearch.github.io/autora/
Requires-Python: <4,>=3.8
Description-Content-Type: text/markdown
Provides-Extra: dev

# AutoRA Uncertainty Sampler

The uncertainty sampler identifies experimental conditions $\vec{x}' \in X'$ with respect model uncertainty. Within the uncertainty sampler, there are three methods to determine uncertainty:

## Least Confident
$$
x^* = \text{argmax} \left( 1-P(\hat{y}|x) \right),
$$

where $\hat{y} = \text{argmax} P(y_i|x)$

## Margin

$$
x^* = \text{argmax} \left( P(\hat{y}_1|x) - P(\hat{y}_2|x) \right),
$$

where $\hat{y}_1$ and $\hat{y}_2$ are the first and second most probable class labels under the model, respectively.

## Entropy
$$ 
x^* = \text{argmax} \left( - \sum P(y_i|x)\text{log} P(y_i|x) \right)
$$

# Example Code

```
from autora.experimentalist.sampler.uncertainty import uncertainty_sampler
from sklearn.linear_model import LogisticRegression
import numpy as np

#Meta-Setup
X = np.linspace(start=-3, stop=6, num=10).reshape(-1, 1)
y = (X**2).reshape(-1)
n = 5

#Theorists
lr_theorist = LogisticRegression()
lr_theorist.fit(X,y)

#Sampler
X_new = uncertainty_sampler(X, lr_theorist, n, measure ="least_confident")
```
