Import Modules¶
In [ ]:
Copied!
# Uncomment the following line when running on Google Colab
# !pip install "autora[experimentalist-nearest-value]"
# Uncomment the following line when running on Google Colab
# !pip install "autora[experimentalist-nearest-value]"
In [3]:
Copied!
import numpy as np
import matplotlib.pyplot as plt
from autora.experimentalist.nearest_value import nearest_values_sample
import numpy as np
import matplotlib.pyplot as plt
from autora.experimentalist.nearest_value import nearest_values_sample
Define Meta-Space¶
We will here define X values of interest as well as a ground truth model to derive y values.
In [4]:
Copied!
#Define meta-parameters
X_allowed = np.linspace(-3, 6, 10)
X = np.random.choice(X_allowed,10)
#Define ground truth model
def ground_truth(xs):
y = (xs ** 2.0)
y[xs < 0] = 0
return y
#Define meta-parameters
X_allowed = np.linspace(-3, 6, 10)
X = np.random.choice(X_allowed,10)
#Define ground truth model
def ground_truth(xs):
y = (xs ** 2.0)
y[xs < 0] = 0
return y
Plot The Data¶
Let's plot the data to see what we are working with.
In [5]:
Copied!
plt.plot(X, ground_truth(X), 'o')
plt.show()
plt.plot(X, ground_truth(X), 'o')
plt.show()
Run And Report Uncertainty Samples¶
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.
In [6]:
Copied!
sampler_proposal = nearest_values_sample(X_allowed, X, 5)
print(sampler_proposal)
sampler_proposal = nearest_values_sample(X_allowed, X, 5)
print(sampler_proposal)
0 0 5.0 1 -3.0 2 1.0 3 4.0 4 6.0
Plot New Datapoints With Old¶
We can then plot our new datapoints with our previous ones to demonstrate our new dataset of investigation for then next cycle.
In [7]:
Copied!
plt.plot(X, ground_truth(X), 'o', alpha = .5, label = 'Original Datapoints')
plt.plot(sampler_proposal, ground_truth(sampler_proposal), 'o', alpha = .5, label = 'New Datapoints')
plt.legend()
plt.show()
plt.plot(X, ground_truth(X), 'o', alpha = .5, label = 'Original Datapoints')
plt.plot(sampler_proposal, ground_truth(sampler_proposal), 'o', alpha = .5, label = 'New Datapoints')
plt.legend()
plt.show()
In [ ]:
Copied!