The novelty experimentalist selects $n$ novel experimental conditions from a pool of candidate experimental conditions $X'$. The choice is informed based on the similarity of the candidate conditions $X'$ with respect to previously examined experiment conditions $X$. We begin with importing the relevant packages.
# Uncomment the following line when running on Google Colab # !pip install "autora[experimentalist-novelty]"
from autora.experimentalist.novelty import novelty_sample, novelty_score_sample import numpy as np
Next, we define the existing experimental conditons $X$.
X = np.array([1, 2, 3])
We define the candidate experimental conditons $X'$ from which we seek to sample.
X_prime = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
Next, we need to specify how many samples we would like to collect. In this case, we pick $n=2$.
n = 2
Finally, we can call the novelty experimentalist. Note that $X'$ is the first argument to the experimentalist, followed by the "reference" conditions $X$, and the number of samples.
X_sampled = novelty_sample(conditions = X_prime, reference_conditions = X, num_samples = n, metric = "euclidean", integration = "sum") print(X_sampled)
[ [ 9]]
The novelty experimentalist also works for experiments with multiple indendent variables. In the following example, we define $X$ as a single experimental condition composed of three independent factors. We choose from a pool $X'$ composed of four experimental conditons.
X = np.array([[1, 1, 1]]) X_prime = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])
Next, we sample a single experimental condition from the pool $X'$ which yields the greatest summed Euclidean distance to the existing condition in $X$.
X_sampled = novelty_sample(conditions = X_prime, reference_conditions = X, num_samples = 1, metric = "euclidean", integration = "sum") print(X_sampled)
[[10 11 12]]
We can also obtain "novelty" scores for the sampled experiment conditions using ``novelty_score_sample''. The scores are z-scored with respect to all conditions from the pool. In the following example, we sample 2 conditions and return their novelty scores.
X_sampled, scores = novelty_score_sample(conditions = X_prime, reference_conditions = X, num_samples = 2, metric = "euclidean", integration = "sum") print(X_sampled) print(scores)
[[10 11 12] [ 7 8 9]] [1.35401943 0.43928867]
The novelty scores align with the sampled experiment conditions (in descending order of the novelty score).