38
38
39
39
"""
40
40
41
+ # %%
41
42
import numpy as np
42
- import matplotlib .pyplot as plt
43
43
from sklearn .gaussian_process .kernels import Kernel , Hyperparameter
44
44
from sklearn .gaussian_process .kernels import GenericKernelMixin
45
45
from sklearn .gaussian_process import GaussianProcessRegressor
@@ -102,10 +102,11 @@ def clone_with_theta(self, theta):
102
102
103
103
kernel = SequenceKernel ()
104
104
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
109
110
110
111
X = np .array (["AGCT" , "AGC" , "AACT" , "TAA" , "AAA" , "GAACA" ])
111
112
@@ -117,11 +118,11 @@ def clone_with_theta(self, theta):
117
118
plt .xticks (np .arange (len (X )), X )
118
119
plt .yticks (np .arange (len (X )), X )
119
120
plt .title ("Sequence similarity under the kernel" )
121
+ plt .show ()
120
122
121
- """
122
- Regression
123
- ==========
124
- """
123
+ # %%
124
+ # Regression
125
+ # ==========
125
126
126
127
X = np .array (["AGCT" , "AGC" , "AACT" , "TAA" , "AAA" , "GAACA" ])
127
128
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):
136
137
plt .xticks (np .arange (len (X )), X )
137
138
plt .title ("Regression on sequences" )
138
139
plt .legend ()
140
+ plt .show ()
139
141
140
- """
141
- Classification
142
- ==============
143
- """
142
+ # %%
143
+ # Classification
144
+ # ==============
144
145
145
146
X_train = np .array (["AGCT" , "CGA" , "TAAC" , "TCG" , "CTTT" , "TGCT" ])
146
147
# whether there are 'A's in the sequence
@@ -176,13 +177,12 @@ def clone_with_theta(self, theta):
176
177
[1.0 if c else - 1.0 for c in gp .predict (X_test )],
177
178
s = 100 ,
178
179
marker = "x" ,
179
- edgecolor = ( 0 , 1.0 , 0.3 ) ,
180
+ facecolor = "b" ,
180
181
linewidth = 2 ,
181
182
label = "prediction" ,
182
183
)
183
184
plt .xticks (np .arange (len (X_train ) + len (X_test )), np .concatenate ((X_train , X_test )))
184
185
plt .yticks ([- 1 , 1 ], [False , True ])
185
186
plt .title ("Classification on sequences" )
186
187
plt .legend ()
187
-
188
188
plt .show ()
0 commit comments