module ml.voronoi

Inheritance diagram of mlstatpy.ml.voronoi

Short summary

module mlstatpy.ml.voronoi

About Voronoi Diagram

source on GitHub

Classes

class

truncated documentation

VoronoiEstimationError

Raised when the algorithm failed.

Functions

function

truncated documentation

voronoi_estimation_from_lr

Determines a Voronoi diagram close to a convex partition defined by a logistic regression in n classes. M \in \mathbb{M}_{nd}

Documentation

About Voronoi Diagram

source on GitHub

exception mlstatpy.ml.voronoi.VoronoiEstimationError[source]

Bases : Exception

Raised when the algorithm failed.

source on GitHub

mlstatpy.ml.voronoi.voronoi_estimation_from_lr(L, B, C=None, D=None, cl=0, qr=True, max_iter=None, verbose=False)[source]

Determines a Voronoi diagram close to a convex partition defined by a logistic regression in n classes. M \in \mathbb{M}_{nd} a row matrix (L_1, ..., L_n). Every border between two classes i and j is defined by: \scal{L_i}{X} + B = \scal{L_j}{X} + B.

The function looks for a set of points from which the Voronoi diagram can be inferred. It is done through a linear regression with norm L1. See Régression logistique, diagramme de Voronoï, k-Means.

Paramètres
  • L – matrix

  • B – vector

  • C – additional conditions (see below)

  • D – addition condictions (see below)

  • cl – class on which the additional conditions applies

  • qr – use quantile regression

  • max_iter – number of condition to remove until convergence

  • verbose – display information while training

Renvoie

matrix P \in \mathbb{M}_{nd}

The function solves the linear system:

\begin{array}{rcl}
& \Longrightarrow & \left\{\begin{array}{l}\scal{\frac{L_i-L_j}{\norm{L_i-L_j}}}{P_i + P_j} +
2 \frac{B_i - B_j}{\norm{L_i-L_j}} = 0 \\
\scal{P_i-  P_j}{u_{ij}} - \scal{P_i - P_j}{\frac{L_i-L_j}{\norm{L_i-L_j}}} \scal{\frac{L_i-L_j}{\norm{L_i-L_j}}}{u_{ij}}=0
\end{array} \right.
\end{array}

If the number of dimension is big and the number of classes small, the system has multiple solution. Addition condition must be added such as CP_i=D where i=cl, P_i is the Voronoï point attached to class cl. Quantile regression is not implemented in scikit-learn. We use QuantileLinearRegression.

After the first iteration, the function determines the furthest pair of points and removes it from the list of equations. If max_iter is None, the system goes until the number of equations is equal to the number of points * 2, otherwise it stops after max_iter removals. This is not the optimal pair to remove as they could still be neighbors but it should be a good heuristic.

source on GitHub