I have a question about the sample code below. I am sure that the values being passed to the gp.predict line are the values from X array. But, why is it used as X_? Could somebody explain what X_ or rather an array name_ mean in python?
rng = np.random.RandomState(4)
X = rng.uniform(0, 5, 10)[:, np.newaxis]
y = np.sin((X[:, 0] - 2.5) ** 2)
gp.fit(X, y)
# Plot posterior
plt.subplot(2, 1, 2)
X_ = np.linspace(0, 5, 100)
y_mean, y_std = gp.predict(X_[:, np.newaxis], return_std=True)
plt.plot(X_, y_mean, 'k', lw=3, zorder=9)
plt.fill_between(X_, y_mean - y_std, y_mean + y_std,
alpha=0.2, color='k')
This is not a "proper" use of the trailing underscore. It seems to be just an arbitrary variable here.
According to the Python style guide:
single_trailing_underscore_: used by convention to avoid conflicts with Python keyword, e.g.
You'll often see a trailing underscore used to label something list_, or class_, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With