Skip to content
This repository has been archived by the owner on Aug 6, 2020. It is now read-only.

Changed LDA Feature class to handle non-continuous sets of class labels #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
4 changes: 2 additions & 2 deletions py/facerec/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def compute(self, X, y):
y = np.asarray(y)
# calculate dimensions
d = XC.shape[0]
c = len(np.unique(y))
c = len(np.unique(y))
# set a valid number of components
if self._num_components <= 0:
self._num_components = c-1
Expand All @@ -124,7 +124,7 @@ def compute(self, X, y):
# calculate the within and between scatter matrices
Sw = np.zeros((d, d), dtype=np.float32)
Sb = np.zeros((d, d), dtype=np.float32)
for i in range(0,c):
for i in np.unique(y):
Xi = XC[:,np.where(y==i)[0]]
meanClass = np.mean(Xi, axis = 1).reshape(-1,1)
Sw = Sw + np.dot((Xi-meanClass), (Xi-meanClass).T)
Expand Down