Commit 4ec2f819 authored by Anthony Larcher's avatar Anthony Larcher Committed by Anthony Larcher
Browse files

Cleaning

parent a0dd6ce3
......@@ -38,7 +38,7 @@ from ctypes.util import find_library
PARALLEL_MODULE = 'multiprocessing' # can be , threading, multiprocessing MPI is planned in the future
PARAM_TYPE = numpy.float32
STAT_TYPE = numpy.float64
THEANO_CONFIG = "cpu" # can be gpu or cpu
THEANO_CONFIG = "gpu" # can be gpu or cpu
# Import bosaris-like classes
from sidekit.bosaris import IdMap
......
......@@ -175,28 +175,6 @@ def __logit__(p):
return lp
def logit_effective_prior(Ptar, cmiss, cfa):
"""This function adjusts a given prior probability of target p_targ,
to incorporate the effects of a cost of miss,
cmiss, and a cost of false-alarm, cfa.
In particular note:
EFFECTIVE_PRIOR(EFFECTIVE_PRIOR(p,cmiss,cfa),1,1)
= EFFECTIVE_PRIOR(p,cfa,cmiss)
The effective prior for the NIST SRE detection cost fuction,
with p_targ = 0.01, cmiss = 10, cfa = 1 is therefore:
EFFECTIVE_PRIOR(0.01,10,1) = 0.0917
:param Ptar: is the probability of a target trial
:param cmiss: is the cost of a miss
:param cfa: is the cost of a false alarm
:return: a prior
"""
p = Ptar * cmiss / (Ptar * cmiss + (1 - Ptar) * cfa)
return __logit__(p)
def __DETsort__(x, col=''):
"""DETsort Sort rows, the first in ascending, the remaining in descending
thereby postponing the false alarms on like scores.
......
......@@ -343,7 +343,6 @@ class IdMap:
input Id_Maps.
"""
idmap = IdMap()
if self.validate() & idmap2.validate():
# create tuples of (model,seg) for both IdMaps for quick comparaison
tup1 = [(mod, seg) for mod, seg in zip(self.leftids, self.rightids)]
......
......@@ -94,7 +94,7 @@
<span class="sd">useful parameters for speaker verification.</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">numpy</span>
<span class="c">#import pandas</span>
<span class="kn">import</span> <span class="nn">pandas</span>
<span class="kn">import</span> <span class="nn">scipy.stats</span> <span class="kn">as</span> <span class="nn">stats</span>
<span class="kn">from</span> <span class="nn">scipy.signal</span> <span class="kn">import</span> <span class="n">lfilter</span>
......@@ -277,7 +277,7 @@
<span class="k">else</span><span class="p">:</span>
<span class="n">d_win</span> <span class="o">=</span> <span class="n">win</span> <span class="o">//</span> <span class="mi">2</span>
<span class="c">#df = pandas.DataFrame(features[label, :])</span>
<span class="n">df</span> <span class="o">=</span> <span class="n">pandas</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">features</span><span class="p">[</span><span class="n">label</span><span class="p">,</span> <span class="p">:])</span>
<span class="n">r</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">rolling</span><span class="p">(</span><span class="n">window</span><span class="o">=</span><span class="n">win</span><span class="p">,</span> <span class="n">center</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">mean</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">mean</span><span class="p">()</span><span class="o">.</span><span class="n">values</span>
<span class="n">std</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">std</span><span class="p">()</span><span class="o">.</span><span class="n">values</span>
......
......@@ -586,7 +586,6 @@
<span class="sd"> </span>
<span class="sd"> :return: a list of segments belonging to the model</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c">#return self.segset[self.modelset == mod_id, :]</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">segset</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">modelset</span> <span class="o">==</span> <span class="n">mod_id</span><span class="p">]</span>
</div>
<div class="viewcode-block" id="StatServer.get_model_segments_by_index"><a class="viewcode-back" href="../statserver.html#statserver.StatServer.get_model_segments_by_index">[docs]</a> <span class="k">def</span> <span class="nf">get_model_segments_by_index</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mod_idx</span><span class="p">):</span>
......@@ -1201,6 +1200,28 @@
<span class="k">for</span> <span class="n">mu</span><span class="p">,</span> <span class="n">Cov</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">spectral_norm_mean</span><span class="p">,</span> <span class="n">spectral_norm_cov</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">whiten_stat1</span><span class="p">(</span><span class="n">mu</span><span class="p">,</span> <span class="n">Cov</span><span class="p">,</span> <span class="n">is_sqr_inv_sigma</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">norm_stat1</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="StatServer.spectral_norm_stat1_trace"><a class="viewcode-back" href="../statserver.html#statserver.StatServer.spectral_norm_stat1_trace">[docs]</a> <span class="k">def</span> <span class="nf">spectral_norm_stat1_trace</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">spectral_norm_mean</span><span class="p">,</span> <span class="n">spectral_norm_cov</span><span class="p">,</span> <span class="n">traces</span><span class="p">,</span> <span class="n">is_sqr_inv_sigma</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Apply Spectral Sormalization to all first order statistics.</span>
<span class="sd"> See more details in [Bousquet11]_</span>
<span class="sd"> The number of iterations performed is equal to the length of the</span>
<span class="sd"> input lists.</span>
<span class="sd"> :param spectral_norm_mean: a list of mean vectors</span>
<span class="sd"> :param spectral_norm_cov: a list of co-variance matrices as ndarrays</span>
<span class="sd"> :param is_sqr_inv_sigma: boolean, True if</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">spectral_norm_mean</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">spectral_norm_cov</span><span class="p">),</span> \
<span class="s">&#39;Number of mean vectors and covariance matrices is different&#39;</span>
<span class="k">for</span> <span class="n">mu</span><span class="p">,</span> <span class="n">Cov</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">spectral_norm_mean</span><span class="p">,</span> <span class="n">spectral_norm_cov</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">whiten_stat1</span><span class="p">(</span><span class="n">mu</span><span class="p">,</span> <span class="n">Cov</span><span class="p">,</span> <span class="n">is_sqr_inv_sigma</span><span class="p">)</span>
<span class="n">norms</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">stat1</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="n">norms</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">power</span><span class="p">(</span><span class="n">norms</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span> <span class="o">+</span> <span class="n">traces</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">stat1</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">stat1</span><span class="o">.</span><span class="n">transpose</span><span class="p">()</span> <span class="o">/</span> <span class="n">norms</span><span class="p">)</span><span class="o">.</span><span class="n">transpose</span><span class="p">()</span>
<span class="k">return</span> <span class="n">norms</span>
</div>
<span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">ch</span> <span class="o">=</span> <span class="s">&#39;-&#39;</span> <span class="o">*</span> <span class="mi">30</span> <span class="o">+</span> <span class="s">&#39;</span><span class="se">\n</span><span class="s">&#39;</span>
......
......@@ -70,7 +70,6 @@
<div class="genindex-jumpbox">
<a href="#A"><strong>A</strong></a>
| <a href="#B"><strong>B</strong></a>
| <a href="#C"><strong>C</strong></a>
| <a href="#D"><strong>D</strong></a>
| <a href="#E"><strong>E</strong></a>
......@@ -138,21 +137,15 @@
</dl></td>
</tr></table>
<h2 id="B">B</h2>
<h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="bosaris.html#module-bosaris">bosaris (module)</a>
<dt><a href="statserver.html#statserver.StatServer.center_stat1">center_stat1() (statserver.StatServer method)</a>
</dt>
</dl></td>
</tr></table>
<h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="statserver.html#statserver.StatServer.center_stat1">center_stat1() (statserver.StatServer method)</a>
<dt><a href="frontend/normfeat.html#frontend.normfeat.cep_sliding_norm">cep_sliding_norm() (in module frontend.normfeat)</a>
</dt>
......@@ -164,12 +157,20 @@
</dt>
<dt><a href="frontend/features.html#frontend.features.compute_delta">compute_delta() (in module frontend.features)</a>
<dt><a href="frontend/normfeat.html#frontend.normfeat.cms">cms() (in module frontend.normfeat)</a>
</dt>
<dt><a href="frontend/normfeat.html#frontend.normfeat.cmvn">cmvn() (in module frontend.normfeat)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="frontend/features.html#frontend.features.compute_delta">compute_delta() (in module frontend.features)</a>
</dt>
<dt><a href="mixture.html#mixture.Mixture.compute_log_posterior_probabilities">compute_log_posterior_probabilities() (mixture.Mixture method)</a>
</dt>
......@@ -324,6 +325,10 @@
</dt>
<dt><a href="frontend/normfeat.html#module-frontend.normfeat">frontend.normfeat (module)</a>
</dt>
<dt><a href="frontend/vad.html#module-frontend.vad">frontend.vad (module)</a>
</dt>
......@@ -670,6 +675,10 @@
</dt>
<dt><a href="iv_scoring.html#iv_scoring.PLDA_scoring_with_test_uncertainty">PLDA_scoring_with_test_uncertainty() (in module iv_scoring)</a>
</dt>
<dt><a href="bosaris/detplot.html#bosaris.DetPlot.plot_DR30_both">plot_DR30_both() (bosaris.DetPlot method)</a>
</dt>
......@@ -718,6 +727,10 @@
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="frontend/normfeat.html#frontend.normfeat.rasta_filt">rasta_filt() (in module frontend.normfeat)</a>
</dt>
<dt><a href="bosaris/idmap.html#bosaris.IdMap.read">read() (bosaris.IdMap static method)</a>
</dt>
......@@ -794,12 +807,16 @@
</dt>
<dt><a href="sidekit_io.html#sidekit_io.read_matrix">read_matrix() (in module sidekit_io)</a>
<dt><a href="bosaris/scores.html#bosaris.Scores.read_matlab">read_matlab() (bosaris.Scores static method)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="sidekit_io.html#sidekit_io.read_matrix">read_matrix() (in module sidekit_io)</a>
</dt>
<dt><a href="sidekit_io.html#sidekit_io.read_norm_hdf5">read_norm_hdf5() (in module sidekit_io)</a>
</dt>
......@@ -934,16 +951,28 @@
</dt>
<dt><a href="frontend/vad.html#frontend.vad.speech_enhancement">speech_enhancement() (in module frontend.vad)</a>
<dt><a href="statserver.html#statserver.StatServer.spectral_norm_stat1_trace">spectral_norm_stat1_trace() (statserver.StatServer method)</a>
</dt>
<dt><a href="iv_scoring.html#iv_scoring.spectral_norm_stat2">spectral_norm_stat2() (in module iv_scoring)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="frontend/vad.html#frontend.vad.speech_enhancement">speech_enhancement() (in module frontend.vad)</a>
</dt>
<dt><a href="statserver.html#statserver.StatServer">StatServer (class in statserver)</a>
</dt>
<dt><a href="frontend/normfeat.html#frontend.normfeat.stg">stg() (in module frontend.normfeat)</a>
</dt>
<dt><a href="statserver.html#statserver.StatServer.subtract_weighted_stat1">subtract_weighted_stat1() (statserver.StatServer method)</a>
</dt>
......
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