Package pycv :: Package cs :: Package ml :: Package cla :: Module thresh1d :: Class UAC
[hide private]
[frames] | no frames]

Class UAC

source code

Univariate Additive Classifier

A classifier of the form:
    Classify x as class y = sgn( s(x) + c sgn(x-b) )
where s(x) is a score function, (c,b) are unknown parameters.
Suppose there are N training samples (x_n, y_n, s(x_n)).
Let:
    + B(b) = (sgn(x_1-b), sgn(x_2-b), ..., sgn(x_N-b))
    + F(c,b) = (sgn(s(x_1) + c sgn(x_1-b)), ..., sgn(s(x_N) + c sgn(x_N-b)))
When training with N samples (x_n, y_n, F(x_n)), it is provable that
    + R can be partitioned into at most N+1 intervals such that in any
      interval, B(b) is fixed for different values of b
    + Given b is known, R can be partitioned into at most N+1 intervals such
      that in any interval, F(c,b) is fixed for different values of c
    + Given b is fixed but unknown, R can be partitioned into at most 2N+1
      intervals such that in any interval, F(c,b) is fixed for different
      values of c
s(x) must not be 0 for all x_n



Instance Methods [hide private]
 
__init__(self, s, y)
Initialize the class.
source code
 
setx(self, x) source code
 
solve2(self, typ, bnd)
Get the current best solution.
source code
 
solve(self, typ, bnd)
If typ == 0, constrain FRR <= bnd and minimize FAR.
source code
 
get(self, crit, param1)
Find b, c such that:...
source code
Method Details [hide private]

__init__(self, s, y)
(Constructor)

source code 

Initialize the class.

Input:
s, y: see the class' docstring.

solve2(self, typ, bnd)

source code 

Get the current best solution.

Input:
typ: = 0 if to constrain FRR <= maxFRR and minimize FAR < maxFAR
= 1 if to constrain FAR <= maxFAR and minimize FRR < maxFRR

bnd: a numpy.array of 2 doubles: maxFRR and maxFAR

Output:
bparam: best (b,c) bsol: best (FRR,FAR)

solve(self, typ, bnd)

source code 

If typ == 0, constrain FRR <= bnd and minimize FAR. Otherwise constrain FAR <= bnd and minimize FRR.

Input:
typ: type of optimization, minimize FAR if typ == 0. Otherwise minimize FRR. bnd: upper bound to the other, in [0,1].

get(self, crit, param1)

source code 
Find b, c such that:
If crit = 0: to minimize thelambda*FRR(b,c)+FAR(b,c),
    where thelambda = param1
If crit = 1: to minimize FAR(b,c) subject to FRR(b,c) <= 1-minDR,
    where minDR = param1
If crit = 2: to minimize FRR(b,c) subject to FAR(b,c) <= maxFAR,
    where maxFAR = param1
Return:
    bparam: (b,c)
    bsol: (FRR,FAR)