Skip to content

Improve latex #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: python -m pip install -r requirements-dev.txt

- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt') }}
Expand All @@ -52,7 +52,7 @@ jobs:
export PYTHONPATH=

- name: test notebooks
run: python -m pytest _unittests/ut_xrun_doc/test_documentation_notebook.py --durations=10
run: SCIPY_ARRAY_API=1 python -m pytest _unittests/ut_xrun_doc/test_documentation_notebook.py --durations=10

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
Expand All @@ -68,7 +68,7 @@ jobs:
run: cp CHANGELOGS* ./_doc

- name: Documentation
run: python -m sphinx ./_doc ./dist/html -n -w doc.txt
run: SCIPY_ARRAY_API=1 python -m sphinx ./_doc ./dist/html -n -w doc.txt

- name: Summary
run: cat doc.txt
Expand All @@ -86,6 +86,6 @@ jobs:
exit 1
fi

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: ./dist/html/**
2 changes: 1 addition & 1 deletion .github/workflows/wheels-any.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
- name: build wheel
run: python -m pip wheel .

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: ./mlstatpy*.whl
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ prof
temp_*
.ipynb_checkpoints
_doc/CHANGELOGS.rst
_doc/sg_execution_times.rst
_doc/LICENSE.txt
_doc/auto_examples/*
_doc/examples/_cache/*
Expand Down
7 changes: 3 additions & 4 deletions CHANGELOGS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Change Logs
0.5.0
+++++

0.4.0
+++++

* :pr:`42`: quantization
* :pr:`39`: refactoring, use black, better documentation

0.4.0
=====
* :pr:`32`: Improves usability of distance_matching_graphs_paths (2021-08-10)
* :pr:`31`: Links to notebooks are broken, notebooks slides are not working. (2021-03-31)
* :pr:`30`: Fixes #26, implements a compact architecture (2021-01-23)
Expand All @@ -28,4 +28,3 @@ Change Logs
* :pr:`9`: fix unittest on wikipedia_dump after a change on wikipedia website (2018-04-01)
* :pr:`4`: implémentation la complétion en C++ (2016-09-25)
* :pr:`1`: ajouter les petits exposés finance... (2016-06-29)

4 changes: 0 additions & 4 deletions _doc/api/data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
Source de données
=================

.. contents::
:local:
:depth: 2

Wikipédia
+++++++++

Expand Down
4 changes: 0 additions & 4 deletions _doc/api/graph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
Graphes
=======

.. contents::
:local:
:depth: 2

Distance
++++++++

Expand Down
4 changes: 0 additions & 4 deletions _doc/api/image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
Image
=====

.. contents::
:local:
:depth: 2

Conversion
++++++++++

Expand Down
4 changes: 0 additions & 4 deletions _doc/api/ml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
Machine Learning
================

.. contents::
:local:
:depth: 2

Matrices
++++++++

Expand Down
4 changes: 0 additions & 4 deletions _doc/api/optim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
Optimisation
================

.. contents::
:local:
:depth: 2

Gradient
++++++++

Expand Down
4 changes: 0 additions & 4 deletions _doc/api/text.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
Traitement du langage naturel
=============================

.. contents::
:local:
:depth: 2

Complétion
++++++++++

Expand Down
8 changes: 4 additions & 4 deletions _doc/c_algo/edit_distance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ tels que :math:`d\pa{m_1,m_2} = d\pa{N_2,N_1}` alors :
Il reste à démontrer l'inégalité triangulaire.
Soient trois mots :math:`\pa{m_1,m_2,m_3}`,
on veut démontrer que
:math:`d\pa{m_1,m_3} \infegal d\pa{m_1,m_2} + d \pa{m_2,m_3}`.
:math:`d\pa{m_1,m_3} \leqslant d\pa{m_1,m_2} + d \pa{m_2,m_3}`.
On définit :

.. math::
Expand Down Expand Up @@ -292,15 +292,15 @@ tels que :
\end{eqnarray*}

Or comme la fonction :math:`c` est une distance sur :math:`\mathcal{C}'`, on peut affirmer que :
:math:`d\pa{M_1,M_3} \infegal d\pa{M_1,M_2} + d \pa{M_2,M_3}`.
:math:`d\pa{M_1,M_3} \leqslant d\pa{M_1,M_2} + d \pa{M_2,M_3}`.
D'où :

.. math::
:nowrap:
:label: edit_demo_eq_3

\begin{eqnarray*}
d\pa{m_1,m_3} \infegal d\pa{m_1,m_2} + d \pa{m_2,m_3}
d\pa{m_1,m_3} \leqslant d\pa{m_1,m_2} + d \pa{m_2,m_3}
\end{eqnarray*}

Les assertions :eq:`1 <edit_demo_eq_1>`, :eq:`2 <edit_demo_eq_2>`, :eq:`3 <edit_demo_eq_3>`
Expand Down Expand Up @@ -410,7 +410,7 @@ La démonstration s'effectue par récurrence, la définition :ref:`3 <definition
est bien sûr équivalente :ref:`1 <defition_distance_edition_1>`
pour des mots de longueur un. On suppose donc que ce résultat est
vrai pour un couple de mots :math:`\pa{m_1,m_2}` de longueur :math:`\pa{l_1,l_2}`
vérifiant :math:`l_1 \infegal i` et `l_2 \infegal j` avec au plus une égalité.
vérifiant :math:`l_1 \leqslant i` et `l_2 \leqslant j` avec au plus une égalité.
Soit :math:`m` un mot, on note :math:`n` le nombre de lettres qu'il contient.
On note :math:`m\left( l\right)` le mot formé des :math:`l` premières lettres de :math:`m`.
Alors :
Expand Down
3 changes: 0 additions & 3 deletions _doc/c_algo/gest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
Détection de segments
=====================

.. contents::
:local:

L'idée
======

Expand Down
3 changes: 0 additions & 3 deletions _doc/c_algo/graph_distance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ One of the solution is the
a better solution is described in [Blondel2004]_. You can also read
`Graph similarity <http://www.cs.uoi.gr/~pvassil/downloads/GraphDistance/LauraZager.pdf>`_.

.. contents::
:local:

Definitions
===========

Expand Down
9 changes: 3 additions & 6 deletions _doc/c_clus/gauss_mixture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
Mélange de lois normales
========================

.. contents::
:local:

Algorithme EM
=============

Expand All @@ -17,7 +14,7 @@ Algorithme EM

Soit :math:`X` une variable aléatoire d'un espace vectoriel de dimension :math:`d`, :math:`X`
suit un la loi d'un mélange de :math:`N` lois gaussiennes de paramètres
:math:`\pa{\mu_i, \Sigma_i}_ {1 \infegal i \infegal N}`,
:math:`\pa{\mu_i, \Sigma_i}_ {1 \leqslant i \leqslant N}`,
alors la densité :math:`f` de :math:`X` est de la forme :

.. math::
Expand Down Expand Up @@ -92,7 +89,7 @@ on suppose que :math:`X` suit la loi du mélange suivant :

f\pa{X \sac \theta} = \sum_{i=1}^{k} \alpha_i \, f\pa{X \sac \theta_i}

Avec : :math:`\theta = \pa{\alpha_i,\theta_i}_{1 \infegal i \infegal k}, \; \forall i, \; \alpha_i \supegal 0`
Avec : :math:`\theta = \pa{\alpha_i,\theta_i}_{1 \leqslant i \leqslant k}, \; \forall i, \; \alpha_i \supegal 0`
et :math:`\sum_{i=1}^{k} \alpha_i = 1`.

On définit pour une classe :math:`m` la probabilité
Expand Down Expand Up @@ -184,7 +181,7 @@ est dérivé de l'algorithme EM :
P_a = \min \acc{ \exp\cro{ \frac{ L\pa{ \theta''_t, X} - L\pa{ \theta_t, X} }{\gamma} }, 1}

On génére aléatoirement une variable :math:`u \sim U\cro{0,1}`,
si :math:`u \infegal P_a`, alors les paramètres :math:`\theta''_t`
si :math:`u \leqslant P_a`, alors les paramètres :math:`\theta''_t`
sont validés. :math:`\hat{\theta}_t \longleftarrow \theta''_t`
et retour à l'étape d'expectation. Dans le cas contraire, les paramètres
:math:`\theta''_t` sont refusés et retour à l'étape précédente.
Expand Down
29 changes: 13 additions & 16 deletions _doc/c_clus/kmeans.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
k-means
=======

.. contents::
:local:

*Dénomination française : algorithme des centres mobiles.*

.. index:: centres mobiles, k-means, variance intra-classe, inertie
Expand Down Expand Up @@ -130,12 +127,12 @@ On en déduit que :

\begin{eqnarray}
J^{t+1} &=& \sum_{i, c_i^t \neq c_i^{t+1}} \; d^2\pa{ X_i, G_{c_i^{t+1}}^t} + J^{t+1} \sum_{i, c_i^t = c_i^{t+1}} \; d^2\pa{ X_i, G_{c_i^{t+1}}^t} \\
J^{t+1} &\infegal& \sum_{i, c_i^t \neq c_i^{t+1}} \; d^2\pa{ X_i, G_{c_i^{t}}^t} + \sum_{i, c_i^t = c_i^{t+1}} \; d^2\pa{ X_i, G_{c_i^{t}}^t} \\
J^{t+1} &\infegal& I^t
J^{t+1} &\leqslant& \sum_{i, c_i^t \neq c_i^{t+1}} \; d^2\pa{ X_i, G_{c_i^{t}}^t} + \sum_{i, c_i^t = c_i^{t+1}} \; d^2\pa{ X_i, G_{c_i^{t}}^t} \\
J^{t+1} &\leqslant& I^t
\end{eqnarray}

Le lemme précédent appliqué à chacune des classes :math:`\ensemble{1}{C}`,
permet d'affirmer que :math:`I^{t+1} \infegal J^{t+1}`.
permet d'affirmer que :math:`I^{t+1} \leqslant J^{t+1}`.
Par conséquent, la suite :math:`\pa{I_t}_{t\supegal 0}` est décroissante et minorée par
0, elle est donc convergente.

Expand Down Expand Up @@ -242,7 +239,7 @@ par la suivante :

La fonction :math:`D_k` est définie par la distance du point :math:`x`
au centre :math:`G_l` choisi parmi les :math:`k` premiers centres.
:math:`D_k(x) = \min_{1 \infegal l \infegal k} d(x - G_l)`.
:math:`D_k(x) = \min_{1 \leqslant l \leqslant k} d(x - G_l)`.

La suite de l'algorithme *k-means++* reprend les mêmes étapes que
:ref:`k-means <kmeans_def_algo>`.
Expand All @@ -257,7 +254,7 @@ centres déjà choisis. L'article montre que :
On définit l'inertie par
:math:`J_(X) = \sum_{i=1}^{P} \; \min_G d^2(X_i, G)`.
Si :math:`J_{OPT}` définit l'inertie optimale alors
:math:`\esp{J(X)} \infegal 8 (\ln C + 2) J_{OPT}(X)`.
:math:`\esp{J(X)} \leqslant 8 (\ln C + 2) J_{OPT}(X)`.

La démonstration est disponible dans l'article [Arthur2007]_.

Expand Down Expand Up @@ -314,7 +311,7 @@ Estimation de probabilités
==========================

A partir de cette classification en :math:`C` classes, on construit un
vecteur de probabilités pour chaque point :math:`\pa{X_{i}}_{1 \infegal i \infegal P}`
vecteur de probabilités pour chaque point :math:`\pa{X_{i}}_{1 \leqslant i \leqslant P}`
en supposant que la loi de :math:`X` sachant sa classe :math:`c_X` est une loi
normale multidimensionnelle. La classe de :math:`X_i` est
notée :math:`c_i`. On peut alors écrire :
Expand Down Expand Up @@ -500,7 +497,7 @@ L'inertie de ce nuage de points est définie par :

On définit tout d'abord une distance
:math:`\alpha \in \mathbb{R}^+`, puis l'ensemble
:math:`V\pa{y,\alpha} = \acc{ z \in Y \sac d\pa{y,z} \infegal \alpha }`,
:math:`V\pa{y,\alpha} = \acc{ z \in Y \sac d\pa{y,z} \leqslant \alpha }`,
:math:`V\pa{y,\alpha}` est donc l'ensemble des voisins des
centres dont la distance avec :math:`y` est inférieur à :math:`\alpha`.
L'article [Kothari1999]_ propose de minimiser le coût :math:`J\pa{\alpha}`
Expand Down Expand Up @@ -596,7 +593,7 @@ Il s'appuie sur la méthode des multiplicateurs de Lagrange.

| for i in :math:`1..N`
| Mise à jour d'après le premier terme de la fonction de coût :math:`J\pa{\alpha}`.
| :math:`w \longleftarrow \underset{1 \infegal l \infegal K}{\arg \min} \; \norme{x_i - y_l}^2`
| :math:`w \longleftarrow \underset{1 \leqslant l \leqslant K}{\arg \min} \; \norme{x_i - y_l}^2`
| :math:`z^1_w \longleftarrow z^1_w + \eta \pa{ x_i - y_w}`
| :math:`c^1_w \longleftarrow c^1_w + 1`
|
Expand All @@ -617,7 +614,7 @@ Il s'appuie sur la méthode des multiplicateurs de Lagrange.
:math:`y_k`, retour à l'étape précédente. Sinon, tous les couples de classes :math:`\pa{i,j}`
vérifiant :math:`\norme{y_i - y_j} > \alpha` sont fusionnés :
:math:`\alpha \longleftarrow \alpha + \alpha_t`.
Si :math:`\alpha \infegal \alpha2`, retour à l'étape de préparation.
Si :math:`\alpha \leqslant \alpha2`, retour à l'étape de préparation.

*terminaison*

Expand Down Expand Up @@ -652,7 +649,7 @@ L'algorithme qui suit a pour objectif de minimiser la quantité pour un échanti

.. math::

I = \sum_{i=1}^{N}\sum_{k=1}^{K} \indicatrice{ i = \underset{1 \infegal j \infegal N}{\arg \max}
I = \sum_{i=1}^{N}\sum_{k=1}^{K} \indicatrice{ i = \underset{1 \leqslant j \leqslant N}{\arg \max}
G\pa{X_k, \mu_j,\Sigma_j} } \; \ln \cro{ p_i G\pa{ X_k, \mu_i, \Sigma_i } }

.. mathdef::
Expand All @@ -666,7 +663,7 @@ L'algorithme qui suit a pour objectif de minimiser la quantité pour un échanti
*initialisation*

:math:`t \longleftarrow 0`.
Les paramètres :math:`\acc{p_i^0, \mu_i^0, \Sigma_i^0 \sac 1 \infegal i \infegal N}` sont initialisés
Les paramètres :math:`\acc{p_i^0, \mu_i^0, \Sigma_i^0 \sac 1 \leqslant i \leqslant N}` sont initialisés
grâce à un algorithme des :ref:`k-means <kmeans_def_algo>` ou :ref:`FSCL <label_kmeans_fscl>`.
:math:`\forall i, \; p_i^0 = \frac{1}{N}` et :math:`\beta_i^0 = 0`.

Expand All @@ -676,7 +673,7 @@ L'algorithme qui suit a pour objectif de minimiser la quantité pour un échanti

.. math::

i = \underset{1 \infegal i \infegal N}{\arg \min} \; G\pa{X_k, \mu_i^t, \Sigma_i^t}
i = \underset{1 \leqslant i \leqslant N}{\arg \min} \; G\pa{X_k, \mu_i^t, \Sigma_i^t}

| for i in :math:`1..N`
| :math:`\mu_i^{t+1} = \mu_i^t + \eta \, \pa{\Sigma_i^t}^{-1} \, \pa{ X_k - \mu_i^t}`
Expand All @@ -690,7 +687,7 @@ L'algorithme qui suit a pour objectif de minimiser la quantité pour un échanti

*terminaison*

Tant que :math:`\underset{1 \infegal i \infegal N}{\arg \min} \; G\pa{X_k, \mu_i^t, \Sigma_i^t}`
Tant que :math:`\underset{1 \leqslant i \leqslant N}{\arg \min} \; G\pa{X_k, \mu_i^t, \Sigma_i^t}`
change pour au moins un des points :math:`X_k`.

Lors de la mise à jour de :math:`\Sigma^{-1}`,
Expand Down
9 changes: 3 additions & 6 deletions _doc/c_clus/kohonen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
Carte de Kohonen
================

.. contents::
:local:

Principe
========

Expand Down Expand Up @@ -58,7 +55,7 @@ linéaire, rectangulaire, triangulaire.
On choisi aléatoirement un points du nuage
:math:`X_i` puis on définit le neurone
:math:`\mu_{k^*}^t` de telle sorte que :
:math:`\norme{ \mu_{k^*}^t - X_i} = \underset{1 \infegal j \infegal N}{\min } \; \norme{ \mu_j^t - X_i }`.
:math:`\norme{ \mu_{k^*}^t - X_i} = \underset{1 \leqslant j \leqslant N}{\min } \; \norme{ \mu_j^t - X_i }`.

*mise à jour*

Expand Down Expand Up @@ -153,7 +150,7 @@ L'article définit ensuite la densité interne pour :math:`C` classes :

\begin{eqnarray*}
D_{int} (C) &=& \frac{1}{C} \; \sum_{k=1}^{C} \; \sum_{i=1}^{N} \; \sum_{j=1}^{N} \;
a_{ik} a_{jk} \indicatrice{ \norme{ X_i - X_j} \infegal \sigma }
a_{ik} a_{jk} \indicatrice{ \norme{ X_i - X_j} \leqslant \sigma }
\end{eqnarray*}

On définit la distance :math:`d^*_{kl}` pour :math:`\pa{k,l} \in \ensemble{1}{C}^2`,
Expand All @@ -175,7 +172,7 @@ La densité externe est alors définie en fonction du nombre de classes :math:`C
\begin{eqnarray*}
D_{ext} (C) = \sum_{k=1}^{C} \; \sum_{l=1}^{C} \; \cro{ \frac{ d_{kl} } { \sigma\pa{k} \sigma\pa{l} } \;
\sum_{i=1}^{N} \; \indicatrice{ a_{ik} + a_{il} > 0 } \indicatrice{ \norme{ X_i - \frac{X_{i^*}^{kl} + X_{j^*}^{kl}}{2} }
\infegal \frac{\sigma\pa{k} +\sigma\pa{l}}{2} } }
\leqslant \frac{\sigma\pa{k} +\sigma\pa{l}}{2} } }
\end{eqnarray*}

L'article définit ensuite la séparabilité en fonction du nombre de classes :math:`C` :
Expand Down
Loading