.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_rvm_for_regression.py: ========================================================= RVM for regression ========================================================= Based on https://github.com/ctgk/PRML/blob/master/notebooks/ch07_Sparse_Kernel_Machines.ipynb .. code-block:: default print(__doc__) import matplotlib.pyplot as plt import numpy as np from sklearn_rvm import EMRVR def create_toy_data(n=20): x = np.linspace(0, 1, n) t = np.sin(2 * np.pi * x) + np.random.normal(scale=0.1, size=n) return x, t x_train, y_train = create_toy_data(n=50) x = np.linspace(0, 1, 100) model = EMRVR(kernel="rbf") model.fit(x_train[:, None], y_train) y, y_std = model.predict(x[:, None], return_std=True) plt.scatter(x_train, y_train, facecolor="none", edgecolor="g", label="training") plt.scatter(x[model.relevance_], y[model.relevance_], s=100, facecolor="none", edgecolor="b", label="relevance vector") plt.plot(x[:, None], y, color="r", label="predict mean") plt.fill_between(x, y - y_std, y + y_std, color="pink", alpha=0.2, label="predict std.") plt.legend(loc="best") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_rvm_for_regression.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: rvm_for_regression.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: rvm_for_regression.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_