Describe the bug
After training an SVM with callable kernel function, the SVM's support vectors attribute is an empty array.
Steps/Code to Reproduce
Minimal example based on this tutorial
import numpy as np
from sklearn import svm, datasets
# import some data to play with
iris = datasets.load_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 = np.array([[2, 0], [0, 1.0]])
return np.dot(np.dot(X, M), Y.T)
# we create an instance of SVM and fit out data.
clf = svm.SVC(kernel=my_kernel)
clf.fit(X, Y)
print(clf.support_vectors_) # array([], shape=(0, 0), dtype=float64)
print(clf.n_support_) # array([ 7, 40, 34], dtype=int32)
print(clf.support_) # array of length 81
Expected Results
Expected clf.support_vectors_ to be an array of shape [num_support_vectors, num_features]
Actual Results
clf.support_vectors_ is an array of shape [0, 0]
Versions
setuptools: 54.0.0
sklearn: 0.23.2
numpy: 1.19.2
scipy: 1.6.1
Cython: None
pandas: 1.2.2
matplotlib: 3.3.4
joblib: 1.0.1
threadpoolctl: 2.1.0
Built with OpenMP: True
Describe the bug
After training an SVM with callable kernel function, the SVM's support vectors attribute is an empty array.
Steps/Code to Reproduce
Minimal example based on this tutorial
Expected Results
Expected
clf.support_vectors_to be an array of shape [num_support_vectors, num_features]Actual Results
clf.support_vectors_is an array of shape [0, 0]Versions
setuptools: 54.0.0
sklearn: 0.23.2
numpy: 1.19.2
scipy: 1.6.1
Cython: None
pandas: 1.2.2
matplotlib: 3.3.4
joblib: 1.0.1
threadpoolctl: 2.1.0
Built with OpenMP: True