Skip to content

Commit

Permalink
Bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Krsto Proroković committed Sep 4, 2024
1 parent 7050d32 commit 32f9e29
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/scholar/decomposition/pca.ex
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ defmodule Scholar.Decomposition.PCA do
x_centered = x - mean
variance = Nx.sum(x_centered * x_centered / (num_samples - 1), axes: [0])
{u, s, vt} = Nx.LinAlg.svd(x_centered, full_matrices?: false)
{_, vt} = Scholar.Decomposition.Utils.flip_svd(u, vt)
{_, vt} = flip_svd(u, vt)
components = vt[0..(num_components - 1)]
explained_variance = s * s / (num_samples - 1)

Expand Down Expand Up @@ -311,7 +311,7 @@ defmodule Scholar.Decomposition.PCA do
)

{u, s, vt} = Nx.LinAlg.svd(matrix, full_matrices?: false)
{_, vt} = Scholar.Decomposition.Utils.flip_svd(u, vt)
{_, vt} = flip_svd(u, vt)
updated_components = vt[0..(num_components - 1)]
updated_singular_values = s[0..(num_components - 1)]

Expand Down

0 comments on commit 32f9e29

Please sign in to comment.