The Leverage Experimentalist
This experimentalist uses the statistical concept of leverage by refitting the provided models iteratively with the leave-one-out method.
WARNING: 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 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 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 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{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 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.leverage import leverage_sample
from autora.theorist.darts import DARTSRegressor; DARTSRegressor()
from sklearn.linear_model import LogisticRegression
#Meta-Setup
X = np.linspace(start=-3, stop=6, num=10).reshape(-1, 1)
y = (X**2).reshape(-1, 1)
n = 5
#Theorists
darts_theorist = DARTSRegressor()
lr_theorist = LogisticRegression()
darts_theorist.fit(X,y)
lr_theorist.fit(X,y)
#Experimentalist
X_new = leverage_sample(X, y, [darts_theorist, lr_theorist], fit = 'both', num_samples = n)
Metadata
Release files for autora-experimentalist-leverage 1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| autora_experimentalist_leverage-1.10.tar.gz | 91.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| autora_experimentalist_leverage-1.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 98.2 kB
Release files / autora_experimentalist_leverage-1.10.tar.gz
| Download URL | autora_experimentalist_leverage-1.10.tar.gz |
|---|---|
| Size | 91.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d2c864c5ec0494b8f3b7a21a179c282dfb4e8c1d246a11120a0fd9e9ee96eb6
|
|
BLAKE2b-256 checksum How to use checksums |
0f2f47dbcd0cab98f2f568f48b3cb3db12ad5b062eab2ad8af2f5579f92d2f49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / autora_experimentalist_leverage-1.10-py3-none-any.whl
| Download URL | autora_experimentalist_leverage-1.10-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0702f397aafbca20df1debc7bb1f5b7ff87938959a07d16fc4cc833fd7f0759e
|
|
BLAKE2b-256 checksum How to use checksums |
b841ce3f8f7557e43dfdc82e5176c531457d6077d57672400ce35992f0738148
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Security for autora-experimentalist-leverage 1.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.