datasets
,
svm
from
sklearn.inspection
import
DecisionBoundaryDisplay
iris
=
()
X
=
iris
.
data
[:,
:
2
]
Y
=
iris
.
target
def
my_kernel
(
X
,
Y
):
"""
We create a custom kernel:
(2 0)
k(X, Y) = X ( ) Y.T
(0 1)
"""
M
=
([[
2
,
0
],
[
0
,
1.0
]])
return
(
(
X
,
M
),
Y
.
T
)
clf
=
(
kernel
=
my_kernel
)
clf
.
fit
(
X
,
Y
)
ax
=
()
(
clf
,
X
,
multiclass_colors
=
"Paired"
,
ax
=
ax
,
response_method
=
"predict"
,
plot_method
=
"pcolormesh"
,
shading
=
"auto"
,
alpha
=
0.5
,
)
(
X
[:,
0
],
X
[:,
1
],
c
=
Y
,
cmap
=
plt
.
cm
.
Paired
)
(
X
[
clf
.
support_
,
0
],
X
[
clf
.
support_
,
1
],
facecolor
=
"none"
,
edgecolors
=
"k"
,
)
(
"3-Class classification using Support Vector Machine with custom kernel"
)
(
"tight"
)
()
Total running time of the script: (0 minutes 0.100 seconds)
Related examples