File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 1
1
import numpy as np
2
2
from scipy .sparse import csr_matrix
3
- from scipy .spatial .distance import cdist
4
3
5
- from ..kernel_approximation import RBFSampler
6
- from ..kernel_approximation import AdditiveChi2Sampler
7
- from ..kernel_approximation import SkewedChi2Sampler
4
+ from sklearn .kernel_approximation import RBFSampler
5
+ from sklearn .kernel_approximation import AdditiveChi2Sampler
6
+ from sklearn .kernel_approximation import SkewedChi2Sampler
7
+ from sklearn .metrics .pairwise import rbf_kernel
8
8
9
9
# generate data
10
10
X = np .random .uniform (size = (300 , 50 ))
@@ -64,8 +64,7 @@ def test_rbf_sampler():
64
64
"""test that RBFSampler approximates kernel on random data"""
65
65
# compute exact kernel
66
66
gamma = 10.
67
- dists = cdist (X , Y )
68
- kernel = np .exp (- gamma * dists ** 2 )
67
+ kernel = rbf_kernel (X , Y , gamma = gamma )
69
68
70
69
# appoximate kernel mapping
71
70
rbf_transform = RBFSampler (gamma = gamma , n_components = 1000 , random_state = 42 )
You can’t perform that action at this time.
0 commit comments