8000 DOC Use notebook style in plot_gpr_on_structured_data.py (#25132) · scikit-learn/scikit-learn@d8592a6 · GitHub
[go: up one dir, main page]

Skip to content

Commit d8592a6

Browse files
authored
DOC Use notebook style in plot_gpr_on_structured_data.py (#25132)
1 parent 17b8278 commit d8592a6

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

examples/gaussian_process/plot_gpr_on_structured_data.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
3939
"""
4040

41+
# %%
4142
import numpy as np
42-
import matplotlib.pyplot as plt
4343
from sklearn.gaussian_process.kernels import Kernel, Hyperparameter
4444
from sklearn.gaussian_process.kernels import GenericKernelMixin
4545
from sklearn.gaussian_process import GaussianProcessRegressor
@@ -102,10 +102,11 @@ def clone_with_theta(self, theta):
102102

103103
kernel = SequenceKernel()
104104

105-
"""
106-
Sequence similarity matrix under the kernel
107-
===========================================
108-
"""
105+
# %%
106+
# Sequence similarity matrix under the kernel
107+
# ===========================================
108+
109+
import matplotlib.pyplot as plt
109110

110111
X = np.array(["AGCT", "AGC", "AACT", "TAA", "AAA", "GAACA"])
111112

@@ -117,11 +118,11 @@ def clone_with_theta(self, theta):
117118
plt.xticks(np.arange(len(X)), X)
118119
plt.yticks(np.arange(len(X)), X)
119120
plt.title("Sequence similarity under the kernel")
121+
plt.show()
120122

121-
"""
122-
Regression
123-
==========
124-
"""
123+
# %%
124+
# Regression
125+
# ==========
125126

126127
X = np.array(["AGCT", "AGC", "AACT", "TAA", "AAA", "GAACA"])
127128
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):
136137
plt.xticks(np.arange(len(X)), X)
137138
plt.title("Regression on sequences")
138139
plt.legend()
140+
plt.show()
139141

140-
"""
141-
Classification
142-
==============
143-
"""
142+
# %%
143+
# Classification
144+
# ==============
144145

145146
X_train = np.array(["AGCT", "CGA", "TAAC", "TCG", "CTTT", "TGCT"])
146147
# whether there are 'A's in the sequence
@@ -176,13 +177,12 @@ def clone_with_theta(self, theta):
176177
[1.0 if c else -1.0 for c in gp.predict(X_test)],
177178
s=100,
178179
marker="x",
179-
edgecolor=(0, 1.0, 0.3),
180+
facecolor="b",
180181
linewidth=2,
181182
label="prediction",
182183
)
183184
plt.xticks(np.arange(len(X_train) + len(X_test)), np.concatenate((X_train, X_test)))
184185
plt.yticks([-1, 1], [False, True])
185186
plt.title("Classification on sequences")
186187
plt.legend()
187-
188188
plt.show()

0 commit comments

Comments
 (0)
0