Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/skmatter/preprocessing/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,11 @@ def fit(self, Knm, Kmm, y=None, sample_weight=None):
if self.with_trace:
Knm_centered = Knm - self.K_fit_rows_

Khat = Knm_centered @ np.linalg.pinv(Kmm, self.rcond) @ Knm_centered.T
# The following is more correctly written as Knm @ Kmm^{-1} @ Knm.T
# but has been changed to Knm.T @ Knm @ Kmm^{-1} to avoid the memory
# overload often caused by storing n x n matrices. This is fine
# for the following trace, but should not be used for other operations.
Khat = Knm_centered.T @ Knm_centered @ np.linalg.pinv(Kmm, self.rcond)

self.scale_ = np.sqrt(np.trace(Khat) / Knm.shape[0])
else:
Expand Down