Open
Description
Hello everyone,
I am computing the polynomial kernel between atomic environments using the rascal.models.kernel class
for structure in structures_train:
mask_center_atoms_by_species(structure,species_select=[1])
calculator = SphericalInvariants(**hypers)
atoms_list_train = calculator.transform(structures_train)
kernel = Kernel(calculator,target_type="Atom",zeta=2)
kernel_computed = kernel(atoms_list_train)
According to cProfile this takes about 42 seconds.
However, when I compute the same kernel using the sklearn.metrics.pairwise.polynomial_kernel
kernel implementation:
X_train = calculator.transform(structures_train).get_features(calculator)
Kernel_sklearn = sklearn.metrics.pairwise.polynomial_kernel(X_train, degree=2, gamma=1., coef0=0)
np.allclose(kernel_computed,Kernel_sklearn) #returns True
According to cProfile the calculation of the kernel only takes 2 seconds.
Is there something I am missing ?
The transformation of the features takes about 1 second
Metadata
Metadata
Assignees
Labels
No labels