MinimumVolumeClassifier

(Source code, png, hires.png, pdf)

../../../_images/MinimumVolumeClassifier.png
class MinimumVolumeClassifier(*args)

Classifier define by a minimum volume level set.

Parameters
mixtDistDistribution

A distribution.

alphafloat

Confidence level

See also

Classifier

Notes

This implements a mixture classifier which is a particular classifier based on a minimum volume confidence domain.

The minimum volume confidence domain A^*_{\alpha} is the set of minimum volume and which measure is at least \alpha. It is defined by:

A^*_{\alpha} = \argmin_{A \in \Rset^d\, | \, \mu(A) \geq \alpha} \lambda(A)

where \lambda is the Lebesgue measure on \Rset^d. Under some general conditions on \mu (for example, no flat regions), the set A^*_{\alpha} is unique and realises the minimum: \mu(A^*_{\alpha}) = \alpha. We show that A^*_{\alpha} writes:

A^*_{\alpha} = \{ \vect{x} \in \Rset^d \, | \, p(\vect{x}) \geq p_{\alpha} \}

The classifier proposes 2 classes. The rule to assign a point \vect{x} to a class is defined as follows:

\begin{array}{cl}
      0 & \vect{x} \not\in A^*_{\alpha} \\
      1 & \vect{x} \in A^*_{\alpha} \\
 \end{array}

The grade of \vect{x} with respect to the class k is (2 k - 1) log p(\vect{x}).

Examples

>>> import openturns as ot
>>> R2 = ot.CorrelationMatrix(2)
>>> dists = [ot.Normal([-1.0, 2.0], [1.0]*2, R2), ot.Normal([1.0, -2.0], [1.5]*2, R2)]
>>> mixture = ot.Mixture(dists)
>>> sample = mixture.getSample(1000)
>>> distribution = ot.KernelSmoothing().build(sample)
>>> algo = ot.MinimumVolumeClassifier(distribution, 0.8)
>>> algo.classify(distribution.getMean())
1
>>> algo.classify([100.0]*2)
0
>>> sample = distribution.getSample(100)
>>> graph = algo.drawSample(sample, [0, 1])

Methods

classify(*args)

Classify points according to the classifier.

drawContour(alpha)

Draw distribution contours.

drawContourAndSample(alpha, sample, classes)

Draw distribution contour and classified sample.

drawSample(sample, classes)

Draw classified sample.

getClassName()

Accessor to the object’s name.

getDimension()

Accessor to the dimension.

getDistribution()

Accessor to the distribution.

getId()

Accessor to the object’s id.

getLevelSet()

LevelSet accessor.

getName()

Accessor to the object’s name.

getNumberOfClasses()

Accessor to the number of classes.

getShadowedId()

Accessor to the object’s shadowed id.

getThreshold()

Accessor to the threshold.

getVerbose()

Accessor to the verbosity.

getVisibility()

Accessor to the object’s visibility state.

grade(inP, outC)

Grade points according to the classifier.

hasName()

Test if the object is named.

hasVisibleName()

Test if the object has a distinguishable name.

isParallel()

Accessor to the parallel flag.

setName(name)

Accessor to the object’s name.

setParallel(flag)

Accessor to the parallel flag.

setShadowedId(id)

Accessor to the object’s shadowed id.

setVerbose(verbose)

Accessor to the verbosity.

setVisibility(visible)

Accessor to the object’s visibility state.

__init__(*args)

Initialize self. See help(type(self)) for accurate signature.

classify(*args)

Classify points according to the classifier.

Parameters
inputsequence of float or 2-d a sequence of float

A point or set of points to classify.

Returns
clsint or Indices

The class index of the input points, or indices of the classes of each points.

drawContour(alpha)

Draw distribution contours.

Parameters
alphasequence of float

Confidence levels

Returns
graphGraph

The value of the density function defining the frontier of the domain.

drawContourAndSample(alpha, sample, classes)

Draw distribution contour and classified sample.

Parameters
alphasequence of float

Confidence levels

sampleSample

A sample to classifiy.

classessequence of int

Classes to select

Returns
graphGraph

The value of the density function defining the frontier of the domain.

drawSample(sample, classes)

Draw classified sample.

Parameters
sampleSample

A sample to classifiy.

classessequence of int

Classes to select

Returns
graphGraph

The value of the density function defining the frontier of the domain.

getClassName()

Accessor to the object’s name.

Returns
class_namestr

The object class name (object.__class__.__name__).

getDimension()

Accessor to the dimension.

Returns
dimint

The dimension of the classifier.

getDistribution()

Accessor to the distribution.

Returns
distDistribution

The distribution.

getId()

Accessor to the object’s id.

Returns
idint

Internal unique identifier.

getLevelSet()

LevelSet accessor.

Returns
levelsetLevelSet

The levelset defining the domain.

getName()

Accessor to the object’s name.

Returns
namestr

The name of the object.

getNumberOfClasses()

Accessor to the number of classes.

Returns
n_classesint

The number of classes

getShadowedId()

Accessor to the object’s shadowed id.

Returns
idint

Internal unique identifier.

getThreshold()

Accessor to the threshold.

Returns
thresholdfloat

The value p_{\alpha} of the density function defining the frontier of the domain.

getVerbose()

Accessor to the verbosity.

Returns
verbbool

Logical value telling if the verbose mode has been activated.

getVisibility()

Accessor to the object’s visibility state.

Returns
visiblebool

Visibility flag.

grade(inP, outC)

Grade points according to the classifier.

Parameters
inputPointsequence of float or 2-d a sequence of float

A point or set of points to grade.

kint or sequence of int

The class index, or class indices.

Returns
gradefloat or Point

Grade or list of grades of each input point with respect to each class index

hasName()

Test if the object is named.

Returns
hasNamebool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns
hasVisibleNamebool

True if the name is not empty and not the default one.

isParallel()

Accessor to the parallel flag.

Returns
flagbool

Logical value telling if the parallel mode has been activated.

setName(name)

Accessor to the object’s name.

Parameters
namestr

The name of the object.

setParallel(flag)

Accessor to the parallel flag.

Parameters
flagbool

Logical value telling if the classification and grading are done in parallel.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters
idint

Internal unique identifier.

setVerbose(verbose)

Accessor to the verbosity.

Parameters
verbbool

Logical value telling if the verbose mode has been activated.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters
visiblebool

Visibility flag.