Package pycv :: Package cs :: Package ml :: Package cla :: Package boost
[hide private]
[frames] | no frames]

Package boost

source code

An umbrella package containing all boosting modules.



Submodules [hide private]

Classes [hide private]
  OnlineDiscreteBoostedClassifier
DiscreteBoostedClassifier with an ability to learn online.
  DiscreteBoostedClassifier
Discrete Boosted Classifier of this form:...
  SimpleCascade
A cascade of binary classifiers.
  GeneralizedCascade
A cascade of M weak binary classifiers.
  DirectFilteringCascade
A cascaded rejector of M*N weak rejectors f_1(x), ..., f_{M*N}(x).
Functions [hide private]
 
train_VJ(classification_dataset, trainfunc, M, k, evenly=True, can_learn=True, polarity_balancing=1)
Train a DiscreteBoostedClassifier using Viola and Jones' asymmetric boost (NIPS'02) Warning: This function is now obsolete, use train_DBC() instead.
source code
 
train_DBC(classification_dataset, trainfunc, M, k=1.0, balancing=2, can_learn=True, polarity_balancing=1, previous=None)
Train a DiscreteBoostedClassifier...
source code
 
train_OfflineDBC(scd, trainfunc, M, criterion=0, param1=1.0, skewness_balancing=1, preceeding_sc=None, extra_output=False)
Train an offline DiscreteBoostedClassifier...
source code
 
train_PC(classification_dataset, trainfunc, M, k, can_learn=True, polarity_balancing=1)
Train a DiscreteBoostedClassifier using our (Pham and Cham's) asymmetric boost (CVPR'07) Warning: This function is now obsolete, use train_DBC() instead.
source code
 
convert_scoring2weighted(scd)
Convert a binary ScoringCDataset into a WeightedCDataset.
source code
 
train_AdaBoost(classification_dataset, trainfunc, M, can_learn=True, polarity_balancing=1)
Train a DiscreteBoostedClassifier using AdaBoost (Friend et al's DiscreteAdaboost) Warning: This function is now obsolete, use train_DBC() instead.
source code
 
train_DFC(cd, cdgenerator, initfunc, trainfunc, M, N, alpha)
Train a DirectFilteringCascade using my method in my notebook dated 2 May 2007.
source code
 
train_SC(cd, trainfunc, maxM, maxFR=0.9)
Train a cascade of at most maxM filters (binary classifiers).
source code
Variables [hide private]
  __doc__
Function Details [hide private]

train_VJ(classification_dataset, trainfunc, M, k, evenly=True, can_learn=True, polarity_balancing=1)

source code 
Train a DiscreteBoostedClassifier using Viola and Jones'
    asymmetric boost (NIPS'02)

Warning:
    This function is now obsolete, use train_DBC() instead.

Input:
    classification_dataset: a WeightedCDataset of 2 classes
    trainfunc: a function that takes a WeightedCDataset as input
        and returns a BinaryClassifier
    M: the maximum number of stages
    k: false negatives penalized k times more than false positives
    evenly: distribute lambda evenly among the weak classifiers
    can_learn : boolean
        whether the resulting DiscreteBoostedClassifier can learn 
            incrementally
    polarity_balancing: use polarity balancing for online-learning?
        0 = no polarity balancing, same as Oza-Rusell (ICSMC'05)
        1 = polarity balancing, Pham-Cham (CVPR'07)
Output:
    a DiscreteBoostedClassifier

train_DBC(classification_dataset, trainfunc, M, k=1.0, balancing=2, can_learn=True, polarity_balancing=1, previous=None)

source code 
Train a DiscreteBoostedClassifier

Input:
    classification_dataset: a WeightedCDataset of 2 classes
    trainfunc: a function that takes a WeightedCDataset as input
        and returns a BinaryClassifier as a weak classifier
    M: the maximum number of weak classifier
    k: false negatives penalized k times more than false positives
    balancing: type of balancing among weak classifiers
        0 = no balancing at all, this is the original AdaBoost's method
        1 = asymmetric weight balancing, Viola-Jones (NIPS'02)
        2 = skewness balancing, Pham-Cham (CVPR'07)
    can_learn : boolean
        whether the resulting DiscreteBoostedClassifier can learn 
            incrementally
    polarity_balancing: use polarity balancing for online-learning?
        0 = no polarity balancing, same as Oza-Rusell (ICSMC'05)
        1 = polarity balancing, Pham-Cham (CVPR'07)
    previous: previous additive classifier, default is None
Output:
    a DiscreteBoostedClassifier

train_OfflineDBC(scd, trainfunc, M, criterion=0, param1=1.0, skewness_balancing=1, preceeding_sc=None, extra_output=False)

source code 
Train an offline DiscreteBoostedClassifier

Criteria:
    criterion=0: 
        rg \min_f (\lambda P(1) FRR(f) + P(0) FAR(f)) /                 (\lambda P(1) + P(0))
    criterion=1: 
        rg \min_f (\lambda FRR(f) + FAR(f)) / (\lambda + 1)

:Paramters:
    scd : ScoringCDataset
        a binary ScoringCDataset
    trainfunc: a function that takes a WeightedCDataset as input
        and returns a BinaryClassifier as a weak classifier
    M : int
        the maximum number of weak classifiers
    criterion : int
        which criterion
    param1 : double
        \lambda for the criterion
    skewness_balancing : int
        type of balancing among weak classifiers
            0 = no balancing at all, the original AdaBoost's method
            1 = asymmetric weight balancing, Viola-Jones (NIPS'02)
            2 = skewness balancing, Pham-Cham (CVPR'07) 
                (N/A if criterion=1)
    preceeding_sc : ScoringClassifier
        a classifier to preceed this newly trained one, 
        default is None
    extra_output : boolean
        if True then produce extra useful information
        
:Returns:
    dbc : DiscreteBoostedClassifier
        the newly trained DiscreteBoostedClassifier
    err : double (extra_output)
        training error, or training criterion function value
    scd2 : ScoringCDataset (extra_output)
        a new ScoringCDataset with scores augmented by this dbc,

train_PC(classification_dataset, trainfunc, M, k, can_learn=True, polarity_balancing=1)

source code 
Train a DiscreteBoostedClassifier using our (Pham and Cham's)
    asymmetric boost (CVPR'07)

Warning:
    This function is now obsolete, use train_DBC() instead.

Input:
    classification_dataset: a WeightedCDataset of 2 classes
    trainfunc: a function that takes a WeightedCDataset as input
        and returns a BinaryClassifier
    M: the maximum number of stages
    k: false negatives penalized k times more than false positives
    can_learn : boolean
        whether the resulting DiscreteBoostedClassifier can learn 
            incrementally
    polarity_balancing: use polarity balancing for online-learning?
        0 = no polarity balancing, same as Oza-Rusell (ICSMC'05)
        1 = polarity balancing, Pham-Cham (CVPR'07)
Output:
    a DiscreteBoostedClassifier

convert_scoring2weighted(scd)

source code 

Convert a binary ScoringCDataset into a WeightedCDataset.

The formula is weight(x,y) = exp(-y score(x,y)), where y in {-1,1}

Parameters:
  • scd (ScoringCDataset) - scd must be a binary dataset
Returns:
wcd : WeightedCDataset

train_AdaBoost(classification_dataset, trainfunc, M, can_learn=True, polarity_balancing=1)

source code 
Train a DiscreteBoostedClassifier using AdaBoost (Friend et al's DiscreteAdaboost)

Warning:
    This function is now obsolete, use train_DBC() instead.

Input:
    classification_dataset: a WeightedCDataset of 2 classes
    trainfunc: a function that takes a WeightedCDataset as input
        and returns a BinaryClassifier
    M: the maximum number of stages
    can_learn : boolean
        whether the resulting DiscreteBoostedClassifier can learn 
            incrementally
    polarity_balancing: use polarity balancing for online-learning?
        0 = no polarity balancing, same as Oza-Rusell (ICSMC'05)
        1 = polarity balancing, Pham-Cham (CVPR'07)
Output:
    a DiscreteBoostedClassifier

train_DFC(cd, cdgenerator, initfunc, trainfunc, M, N, alpha)

source code 

Train a DirectFilteringCascade using my method in my notebook dated 2 May 2007.

Goal: to train a cascade such that at decisive stages, FAR is minimized
    and FRR is upper-bounded by alpha.
Input:
    cd: a ScoredWCDataset of 2 classes -- modifiable
    cdgenerator: a CDataGenerator for the 'cd'
    initfunc(cd): a function that takes WeightedCDataset 'cd',
        initializes some data, and returns 'data'
    trainfunc(data,minDR): a function that takes initalized 'data'
        and constant 'minDR' as input and returns a BinaryClassifier. The
        function must be able to train to have at least 'minDR' detection
        rate.
    M: the maximum number of stages
    N: the number of weak classifiers per stage
    alpha: the maximum value of an exponential-based upper bound of FRR,
        0 <= alpha <= 1
Output:
    a DirectFilteringCascade

train_SC(cd, trainfunc, maxM, maxFR=0.9)

source code 
Train a cascade of at most maxM filters (binary classifiers).

Input:
    cd: a WeightedCDataset -- modifiable
    trainfunc: a function that takes a WeightedCDataset as input
        and returns a BinaryClassifier
    maxM: the maximum number of filters to be trained
    maxFR: if the filtering rate (the number of negatives after training
        divided by the number of negatives before training) rises above
        'maxFR' then stop
Output:
    cascade: a Cascade of filters
    new_classification_dataset: a new WeightedCDataset filtered by the
        cascade, useful for subsequent training