8000 Make return_std 20x faster in Gaussian Processes (includes solution) · Issue #9234 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
Make return_std 20x faster in Gaussian Processes (includes solution) #9234
Closed
@AndreusUltimus

Description

@AndreusUltimus

Two requests:

(1) Please replace this line:
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/gaussian_process/gpr.py#L329

from this

    yvar -= np.einsum("ki,kj,ij->k", K_trans, K_trans, K_inv)

to this

    sum1 = np.dot(K_trans,K_inv).T
    yvar -= np.einsum("ki,ik->k", K_trans, sum1)

For an input data set of size 800x1, the time difference is 12.7 seconds to 0.2 seconds. I have validated that the result is the same up to 1e-12 or smaller.

(2) Please cache the result of the K_inv computation. It depends only on the result of training, and can be very costly for repeated calls to the class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EasyWell-defined and straightforward way to resolveEnhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0