Skip to content
Snippets Groups Projects
Commit cadc55d5 authored by Manuel Günther's avatar Manuel Günther
Browse files

Implemented PCA subspace by percentage of vairance in PLDA

parent 7ba1349e
Branches
Tags v6.0.7
No related merge requests found
...@@ -77,8 +77,18 @@ class PLDA (Algorithm): ...@@ -77,8 +77,18 @@ class PLDA (Algorithm):
logger.info(" -> Training LinearMachine using PCA ") logger.info(" -> Training LinearMachine using PCA ")
trainer = bob.learn.linear.PCATrainer() trainer = bob.learn.linear.PCATrainer()
machine, _ = trainer.train(data) machine, eigen_values = trainer.train(data)
if isinstance(self.subspace_dimension_pca, float):
cummulated = numpy.cumsum(eigen_values) / numpy.sum(eigen_values)
for index in range(len(cummulated)):
if cummulated[index] > self.subspace_dimension_pca:
self.subspace_dimension_pca = index
break
self.subspace_dimension_pca = index
# limit number of pcs # limit number of pcs
logger.info(" -> limiting PCA subspace to %d dimensions", self.subspace_dimension_pca)
machine.resize(machine.shape[0], self.subspace_dimension_pca) machine.resize(machine.shape[0], self.subspace_dimension_pca)
return machine return machine
......
...@@ -5,5 +5,5 @@ import bob.bio.base ...@@ -5,5 +5,5 @@ import bob.bio.base
algorithm = bob.bio.base.algorithm.PLDA( algorithm = bob.bio.base.algorithm.PLDA(
subspace_dimension_of_f = 16, # Size of subspace F subspace_dimension_of_f = 16, # Size of subspace F
subspace_dimension_of_g = 16, # Size of subspace G subspace_dimension_of_g = 16, # Size of subspace G
subspace_dimension_pca = 150 # Size of the PCA subspace subspace_dimension_pca = 0.9 # Percentage of PCA variance
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment