From 71122941599b9e3863f13cfade302463e940c25b Mon Sep 17 00:00:00 2001 From: ArturoAmorQ Date: Wed, 7 Dec 2022 17:22:26 +0100 Subject: [PATCH] DOC Use notebook style in plot_gpr_on_structured_data.py --- .../plot_gpr_on_structured_data.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/gaussian_process/plot_gpr_on_structured_data.py b/examples/gaussian_process/plot_gpr_on_structured_data.py index bc8c169c91f67..ada50a0edf06b 100644 --- a/examples/gaussian_process/plot_gpr_on_structured_data.py +++ b/examples/gaussian_process/plot_gpr_on_structured_data.py @@ -38,8 +38,8 @@ """ +# %% import numpy as np -import matplotlib.pyplot as plt from sklearn.gaussian_process.kernels import Kernel, Hyperparameter from sklearn.gaussian_process.kernels import GenericKernelMixin from sklearn.gaussian_process import GaussianProcessRegressor @@ -102,10 +102,11 @@ def clone_with_theta(self, theta): kernel = SequenceKernel() -""" -Sequence similarity matrix under the kernel -=========================================== -""" +# %% +# Sequence similarity matrix under the kernel +# =========================================== + +import matplotlib.pyplot as plt X = np.array(["AGCT", "AGC", "AACT", "TAA", "AAA", "GAACA"]) @@ -117,11 +118,11 @@ def clone_with_theta(self, theta): plt.xticks(np.arange(len(X)), X) plt.yticks(np.arange(len(X)), X) plt.title("Sequence similarity under the kernel") +plt.show() -""" -Regression -========== -""" +# %% +# Regression +# ========== X = np.array(["AGCT", "AGC", "AACT", "TAA", "AAA", "GAACA"]) Y = np.array([1.0, 1.0, 2.0, 2.0, 3.0, 3.0]) @@ -136,11 +137,11 @@ def clone_with_theta(self, theta): plt.xticks(np.arange(len(X)), X) plt.title("Regression on sequences") plt.legend() +plt.show() -""" -Classification -============== -""" +# %% +# Classification +# ============== X_train = np.array(["AGCT", "CGA", "TAAC", "TCG", "CTTT", "TGCT"]) # whether there are 'A's in the sequence @@ -176,7 +177,7 @@ def clone_with_theta(self, theta): [1.0 if c else -1.0 for c in gp.predict(X_test)], s=100, marker="x", - edgecolor=(0, 1.0, 0.3), + facecolor="b", linewidth=2, label="prediction", ) @@ -184,5 +185,4 @@ def clone_with_theta(self, theta): plt.yticks([-1, 1], [False, True]) plt.title("Classification on sequences") plt.legend() - plt.show()