Skip to content

Commit b757f35

Browse files
authored
Adds code coverage (#41)
* coverage * fix workflow * dot * cov * yml * remove travis * ong * urls * remove png * fix * update cov * doc * fix url * url
1 parent 39e49ea commit b757f35

29 files changed

Lines changed: 249 additions & 209 deletions

.github/workflows/check_urls.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
print_all: false
1818
timeout: 2
1919
retry_count# : 2
20-
# exclude_urls: https://github, ...
21-
# exclude_patterns: https://github.com/...
22-
force_pass : true
20+
# exclude_urls: https://dumps.wikimedia.org/other/pageviews/%Y/%Y-%m/pageviews-%Y%m%d-%H0000.gz,https://dumps.wikimedia.org/frwiki/latest/latest-all-titles-in-ns0.gz
21+
exclude_patterns: https://dumps.wikimedia.org/
22+
# force_pass : true
2323

2424
- name: urls-checker-docs
2525
uses: urlstechie/urlchecker-action@master
@@ -29,6 +29,6 @@ jobs:
2929
print_all: false
3030
timeout: 2
3131
retry_count# : 2
32-
# exclude_urls: https://github, ...
33-
# exclude_patterns: https://github.com/...
34-
force_pass : true
32+
exclude_urls: https://hal.archives-ouvertes.fr/hal-00990252/document
33+
exclude_patterns: https://www.data.gouv.fr/fr/datasets/r/e3d83ab3-dc52-4c99-abaf-8a38050cc68c
34+
# force_pass : true

.github/workflows/documentation.yml

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
1-
name: Documentation
2-
3-
on:
4-
push:
5-
branches: [main]
6-
pull_request:
7-
branches: [main]
8-
schedule:
9-
# ┌───────────── minute (0 - 59)
10-
# │ ┌───────────── hour (0 - 23)
11-
# │ │ ┌───────────── day of the month (1 - 31)
12-
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
13-
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
14-
# │ │ │ │ │
15-
# │ │ │ │ │
16-
# │ │ │ │ │
17-
# * * * * *
18-
- cron: '30 1 * * 0'
1+
name: Documentation and Code Coverage
2+
3+
on: [push]
194

205
jobs:
21-
build_wheels:
6+
run:
227
name: Build documentation on ${{ matrix.os }}
238
runs-on: ${{ matrix.os }}
249
strategy:
@@ -41,12 +26,34 @@ jobs:
4126
- name: Install requirements
4227
run: python -m pip install -r requirements.txt
4328

44-
- name: Install
45-
run: python setup.py install
46-
4729
- name: Install requirements dev
4830
run: python -m pip install -r requirements-dev.txt
4931

32+
- name: Cache pip
33+
uses: actions/cache@v2
34+
with:
35+
path: ~/.cache/pip
36+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt') }}
37+
restore-keys: |
38+
${{ runner.os }}-pip-
39+
${{ runner.os }}-
40+
41+
- name: Generate coverage report
42+
run: |
43+
pip install pytest
44+
pip install pytest-cov
45+
export PYTHONPATH=.
46+
pytest --cov=./mlstatpy/ --cov-report=xml --durations=10 --ignore-glob=**LONG*.py --ignore-glob=**notebook*.py
47+
export PYTHONPATH=
48+
49+
- name: Upload coverage reports to Codecov
50+
uses: codecov/codecov-action@v3
51+
env:
52+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
53+
54+
- name: Install
55+
run: python setup.py install
56+
5057
- name: Copy license
5158
run: cp LICENSE* ./_doc
5259
- name: Copy changelogs

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ build/*
1212
onnxruntime_profile*
1313
prof
1414
temp_*
15+
_doc/CHANGELOGS.rst
16+
_doc/LICENSE.txt
1517
_doc/auto_examples/*
1618
_doc/examples/_cache/*
1719
_doc/examples/onnxruntime_profile*

README.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11

2-
.. image:: https://travis-ci.com/sdpython/mlstatpy.svg?branch=main
3-
:target: https://app.travis-ci.com/github/sdpython/mlstatpy
4-
:alt: Build status
5-
62
.. image:: https://ci.appveyor.com/api/projects/status/5env33qptorgshaq?svg=true
73
:target: https://ci.appveyor.com/project/sdpython/mlstatpy
84
:alt: Build Status Windows
@@ -24,6 +20,9 @@
2420
:alt: GitHub Issues
2521
:target: https://github.com/sdpython/mlstatpy/issues
2622

23+
.. image:: https://codecov.io/gh/sdpython/mlstatpy/branch/master/graph/badge.svg?token=2gKZsIVL3e
24+
:target: https://codecov.io/gh/sdpython/mlstatpy
25+
2726
.. _l-README:
2827

2928
mlstatpy: détours mathématiques autour du machine learning
@@ -45,4 +44,4 @@ algorithm, a graph edit distance, some helpers on Wikipedia data,
4544
an algorithm to convert decision trees into neural network.
4645

4746
* `GitHub/mlstatpy <https://github.com/sdpython/mlstatpy/>`_
48-
* `documentation <http://www.xavierdupre.fr/app/mlstatpy/helpsphinx/index.html>`_
47+
* `documentation <https://sdpython.github.io/doc/mlstatpy/>`_

_doc/_static/project_ico.png

-114 Bytes
Loading

_doc/c_clus/gauss_mixture.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ L'estimation d'une telle densité s'effectue par l'intermédiaire
5656
d'un algorithme de type `Expectation Maximization (EM) <https://fr.wikipedia.org/wiki/Algorithme_esp%C3%A9rance-maximisation>`_
5757
(voir [Dempster1977]_) ou de ses variantes
5858
`SEM <https://fr.wikipedia.org/wiki/Algorithme_esp%C3%A9rance-maximisation#Algorithme_SEM>`_,
59-
`SAEM <http://wiki.webpopix.org/index.php/The_SAEM_algorithm_for_estimating_population_parameters>`_, ...
59+
`SAEM <https://wiki.inria.fr/popix/The_SAEM_algorithm_for_estimating_population_parameters>`_, ...
6060
(voir [Celeux1985]_, [Celeux1985b]_).
6161
La sélection du nombre de lois dans le mélange reste un
6262
problème ouvert abordé par l'article [Biernacki2001]_.

_doc/c_garden/quantization.rst

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,21 @@ dans l'intervalle *[0, 255]*, 0 à gauche, 255 à droite.
4747
.. math::
4848
4949
\begin{array}{rcl}
50-
q_1(z, \lambda, x) &=& c_{0}^{255}\pa{\intf_{i8}{\frac{x}{\lambda}} + z} \text{ quantization}\\
50+
q_1(z, \lambda, x) &=& c_{0}^{255}\pa{\intf{\frac{x}{\lambda}}_{i8} + z} \text{ quantization}\\
5151
q_2(z, \lambda, i) &=& \lambda(i - z) \text{ déquantization} \\
5252
q(z, \lambda, x) &=& q_2(z, \lambda, q_1(z, \lambda, x)) \\
53-
&=& \lambda\pa{c_{0}^{255}\pa{\intf_{i8}{\frac{x}{\lambda}} + z} - z} \\
54-
&=& \lambda\intf_{i8,z}{\frac{x}{\lambda}}
53+
&=& \lambda\pa{c_{0}^{255}\pa{\intf{\frac{x}{\lambda}}_{i8} + z} - z} \\
54+
&=& \lambda\intf{\frac{x}{\lambda}}_{i8,z}
5555
\end{array}
5656
57-
La fonction :math:`\intf_{i8,z}{x}` est la partie entière asociée à la fonction
57+
La fonction :math:`\intf{x}_{i8,z}` est la partie entière asociée à la fonction
5858
:math:`c_{0}^{255}(i)`.
5959

6060
.. math::
6161
62-
\norm{B - q(z,\lambda,B)}^2 = \sum_{ij} \pa{b_{ij} - \lambda\intf_{i8,z}{\frac{x}{\lambda}}}^2
62+
\norm{B - q(z,\lambda,B)}^2 = \sum_{ij} \pa{b_{ij} - \lambda\intf{\frac{x}{\lambda}}_{i8,z}}^2
6363
64-
Le problème est la fonction :math:`\intf_{i8,z}{.}` qui n'est pas dérivable.
64+
Le problème est la fonction :math:`\intf{.}_{i8,z}` qui n'est pas dérivable.
6565
C'est un problème d'optimisation discrète. Le paramètre :math:`\lambda`
6666
est appelé *scale* ou *échelle*. Il peut y en avoir un ou plusieurs
6767
mais dans ce cas, on considère les différentes parties de *B*
@@ -97,20 +97,60 @@ inférieur (ou le plus proche).
9797

9898
.. math::
9999
100-
\norm{B - q(z,\lambda,B)}^2 = \sum_{ij} \pa{b_{ij} - \lambda\intf_{f8,z}{\frac{x}{\lambda}} }^2
100+
\norm{B - q(z,\lambda,B)}^2 = \sum_{ij} \pa{b_{ij} - \lambda\intf{\frac{x}{\lambda}}_{f8,z} }^2
101101
102102
Optimisation
103103
============
104104

105105
L'idée est de traiter la discrétisation sur un ensemble fini de valeurs,
106-
quel qu'il soit, des entiers ou des réels codés sur 8 bits. On note Cette
106+
quel qu'il soit, des entiers ou des réels codés sur 8 bits. On note cet
107107
ensemble :math:`(d_1, ..., d_n)`. On réécrit le problème d'optimisation :
108108

109109
.. math::
110110
111111
\begin{array}{rcl}
112-
\norm{B - q(z,\lambda,B)}^2 &=& \sum_{ij} \pa{b_{ij} - \lambda\intf_{f8,z}{\frac{x}{\lambda}} }^2 \\
113-
&=& \sum_{k=1}^{n} \sum_{ij} \pa{b_{ij} - \lambda\intf_{f8}{\frac{x}{\lambda}} }^2
114-
\indicatrice{\intf_{f8}{\frac{x}{\lambda}} = d_k}
112+
\norm{B - q(z,\lambda,B)}^2 &=& \sum_{ij} \pa{b_{ij} - \lambda\intf{\frac{x}{\lambda}}_{f8,z} }^2 \\
113+
&=& \sum_{k=1}^{n} \sum_{ij} \pa{b_{ij} - \lambda\intf{\frac{x}{\lambda}}_{f8} }^2
114+
\indicatrice{\intf{\frac{x}{\lambda}}_{f8} = d_k} \\
115+
&=& \sum_{k=1}^{n} \sum_{ij} \pa{b_{ij} - \lambda d_k }^2
116+
\indicatrice{\intf{\frac{x}{\lambda}}_{f8} = d_k} \\
115117
\end{array}
116118
119+
On note :math:`K(u)=\frac{1}{\sqrt{2\pi}}e^{-\frac{1}{2}u^2}` le noyau gaussien.
120+
121+
.. math::
122+
123+
\begin{array}{rcl}
124+
\norm{B - q(z,\lambda,B)}^2 &=& \lim_{h\to 0} \sum_{k=1}^{n} \sum_{ij} \pa{b_{ij} - \lambda d_k }^2
125+
\frac{1}{h} K\pa{\frac{b_{ij} - \lambda d_k}{h}}\indicatrice{\intf{\frac{x}{\lambda}}_{f8} = d_k}
126+
\end{array}
127+
128+
Cette notation ne tient pas compte du décalage *z* qu'on peut ajouter comme suit :
129+
130+
.. math::
131+
132+
\begin{array}{rcl}
133+
\norm{B - q(z,\lambda,B)}^2 &=& \lim_{h\to 0} \sum_{k=1}^{n} \sum_{ij} \pa{b_{ij} - \lambda d_k - z }^2
134+
\frac{1}{h} K\pa{\frac{b_{ij} - \lambda d_k - z}{h}}\indicatrice{\intf{\frac{x}{\lambda}}_{?,z} = d_k}
135+
\end{array}
136+
137+
Le problème est beaucoup plus simple à résoudre si on enlève l'indicatrice
138+
et la fonction devient dérivable. L'idée est de regarder l'évolution des valeurs trouvées
139+
pour :math:`\lambda` et *z* en faisant tendre *h* vers 0.
140+
On commence par le plus simple, le cas float 8 pour lequel on impose :math:`z=0`.
141+
142+
.. math::
143+
144+
f(B,\lambda,h) = \frac{1}{h} \sum_{k=1}^{n} \sum_{ij} \pa{b_{ij} - \lambda d_k - z }^2
145+
K\pa{\frac{b_{ij} - \lambda d_k - z}{h}}
146+
147+
Si on suppose que les coefficients de *B* suivent une certaine loi de probabilité,
148+
ce calcul devient une somme d'espérence.
149+
150+
.. math::
151+
152+
f(X,\lambda,h) = \frac{1}{h} \sum_{k=1}^{n} \esp{X - \lambda d_k - z }^2
153+
K\pa{\frac{X - \lambda d_k - z}{h}}
154+
155+
Résolution
156+
==========

_doc/c_metric/pvalues.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ Bibliographie
435435
=============
436436

437437
* `p-Value and Statistical Practice
438-
<https://www.stat.columbia.edu/~gelman/research/published/pvalues3.pdf>`_
438+
<http://www.stat.columbia.edu/~gelman/research/published/pvalues3.pdf>`_
439439
* `An investigation of the false discovery rate and the misinterpretation of p-values
440440
<https://rsos.royalsocietypublishing.org/content/royopensci/1/3/140216.full.pdf>`_
441441
* :epkg:`Holm-Bonferroni method`

_doc/c_metric/roc.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,6 @@ courbes ROC obtenues pour chacune des classes prise séparément
620620
Exemple
621621
=======
622622

623-
Voir `ROC <http://www.xavierdupre.fr/app/ensae_teaching_cs/helpsphinx/antiseches/ml_basic/plot_regression.html#sphx-glr-antiseches-ml-basic-plot-roc-py>`_.
624-
625623
.. [Agarwal2005] Generalization Bounds for the Area Under the ROC Curve (2005),
626624
Shivani Agarwal, Thore Graepel, Ralf Herbich, Sariel Har-Peled, Dan Roth
627625
*Journal of Machine Learning Research, volume 6, pages 393-425*

_doc/c_ml/missing_values_mf.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ revient à déterminer les coordonnées de la projection d'un nouveau point :mat
291291
dans le plan défini par les vecteurs de la matrice :math:`H`.
292292
Pour de nouvelles observations :math:`M_2=X_{q+1}`,
293293
la fonction `transform
294-
<https://scikit-learn.org/stable/modules/generated/sklearn.decomposition
295-
.NMF.html#sklearn.decomposition.NMF.transform>`_
294+
<https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.NMF.html#sklearn.decomposition.NMF.transform>`_
296295
de la classe :class:`sklearn.decomposition.NMF` réestime une matrice
297296
:math:`W_2` qui projette les vecteurs lignes de :math:`M_2` sur
298297
les vecteurs de *H* en conservant des coefficients de projection positifs.
@@ -349,7 +348,8 @@ avec une factorisation de matrices. On peut également se server de la méthode
349348
pour calculer une ACP avec des valeurs manquantes.
350349

351350
* `Imputation de données manquantes <https://www.math.univ-toulouse.fr/~besse/Wikistat/pdf/st-m-app-idm.pdf>`_
352-
* `Principal component analysis with missing values: a comparative survey of methods <http://pbil.univ-lyon1.fr/members/dray/files/articles/dray2015a.pdf>`_
351+
* `Principal component analysis with missing values: a comparative survey of methods
352+
<https://www.researchgate.net/publication/273901434_Principal_component_analysis_with_missing_values_a_comparative_survey_of_methods>`_
353353

354354
Interprétation
355355
++++++++++++++

0 commit comments

Comments
 (0)