Skip to content
This repository was archived by the owner on Jan 15, 2026. It is now read-only.
This repository was archived by the owner on Jan 15, 2026. It is now read-only.

Computation of kernel between atomic environments takes a long time using rascal.models.kernel #389

@bananenpampe

Description

@bananenpampe

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions