diff --git a/README.md b/README.md index e148688..a117527 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,31 @@ # 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. @@ -33,7 +33,7 @@ Finally, the sampler then uses these aggregated ratios to select the next set of # 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 @@ -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) ``` \ No newline at end of file diff --git a/docs/Basic Usage.ipynb b/docs/Basic Usage.ipynb index ae309fa..850549b 100644 --- a/docs/Basic Usage.ipynb +++ b/docs/Basic Usage.ipynb @@ -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." ] }, { diff --git a/docs/index.md b/docs/index.md index f920eea..7c0cf4f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,11 +1,11 @@ # 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. --- @@ -13,23 +13,23 @@ In each iteration, it computes the degree to which the currently removed datapoi 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. diff --git a/docs/quickstart.md b/docs/quickstart.md index 3990c27..0020f94 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -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"] diff --git a/src/autora/experimentalist/leverage/__init__.py b/src/autora/experimentalist/leverage/__init__.py index 43b2c17..b9d9ff7 100644 --- a/src/autora/experimentalist/leverage/__init__.py +++ b/src/autora/experimentalist/leverage/__init__.py @@ -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