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
......@@ -77,8 +77,18 @@ class PLDA (Algorithm):
logger.info(" -> Training LinearMachine using PCA ")
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
logger.info(" -> limiting PCA subspace to %d dimensions", self.subspace_dimension_pca)
machine.resize(machine.shape[0], self.subspace_dimension_pca)
return machine
......
......@@ -5,5 +5,5 @@ import bob.bio.base
algorithm = bob.bio.base.algorithm.PLDA(
subspace_dimension_of_f = 16, # Size of subspace F
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
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment