Generate this documentation#
See Generating the documention with pyquickhelper.
Configuration:
# -*- coding: utf-8 -*-
import sys
import os
import warnings
from pyquickhelper.helpgen.default_conf import set_sphinx_variables
import pydata_sphinx_theme
# see https://sphinx-gallery.github.io/stable/configuration.html#removing-warnings
warnings.simplefilter("ignore", category=UserWarning)
html_theme = 'pydata_sphinx_theme'
html_theme_path = ['_static', '_images']
sys.path.insert(0, os.path.abspath(os.path.join(os.path.split(__file__)[0])))
local_template = os.path.join(os.path.abspath(
os.path.dirname(__file__)), "phdoc_templates")
set_sphinx_variables(__file__, "mlstatpy", "Xavier Dupré", 2023,
html_theme, html_theme_path, locals(),
extlinks=dict(issue=(
'https://github.com/sdpython/mlstatpy/issues/%s',
'issue %s')),
title="Machine Learning, Statistiques et Programmation", book=True, nblayout='table')
# next
blog_root = "http://www.xavierdupre.fr/app/mlstatpy/helpsphinx/"
html_logo = "_static/project_ico_small.png"
language = "fr"
preamble = '''
\\usepackage{etex}
\\usepackage{fixltx2e} % LaTeX patches, \\textsubscript
\\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\\usepackage[raccourcis]{fast-diagram}
\\usepackage{titlesec}
\\usepackage{amsmath}
\\usepackage{amssymb}
\\usepackage{amsfonts}
\\usepackage{graphics}
\\usepackage{epic}
\\usepackage{eepic}
%\\usepackage{pict2e}
%%% Redefined titleformat
\\setlength{\\parindent}{0cm}
\\setlength{\\parskip}{1ex plus 0.5ex minus 0.2ex}
\\newcommand{\\hsp}{\\hspace{20pt}}
\\newcommand{\\acc}[1]{\\left\\{#1\\right\\}}
\\newcommand{\\cro}[1]{\\left[#1\\right]}
\\newcommand{\\pa}[1]{\\left(#1\\right)}
\\newcommand{\\R}{\\mathbb{R}}
\\newcommand{\\HRule}{\\rule{\\linewidth}{0.5mm}}
%\\titleformat{\\chapter}[hang]{\\Huge\\bfseries\\sffamily}{\\thechapter\\hsp}{0pt}{\\Huge\\bfseries\\sffamily}
'''
custom_preamble = """\n
\\usepackage[all]{xy}
\\newcommand{\\vecteur}[2]{\\pa{#1,\\dots,#2}}
\\newcommand{\\N}[0]{\\mathbb{N}}
\\newcommand{\\indicatrice}[1]{ {1\\!\\!1}_{\\acc{#1}} }
\\newcommand{\\infegal}[0]{\\leqslant}
\\newcommand{\\supegal}[0]{\\geqslant}
\\newcommand{\\ensemble}[2]{\\acc{#1,\\dots,#2}}
\\newcommand{\\fleche}[1]{\\overrightarrow{ #1 }}
\\newcommand{\\intervalle}[2]{\\left\\{#1,\\cdots,#2\\right\\}}
\\newcommand{\\independant}[0]{\\perp \\!\\!\\! \\perp}
\\newcommand{\\esp}{\\mathbb{E}}
\\newcommand{\\espf}[2]{\\mathbb{E}_{#1}\\pa{#2}}
\\newcommand{\\var}{\\mathbb{V}}
\\newcommand{\\pr}[1]{\\mathbb{P}\\pa{#1}}
\\newcommand{\\loi}[0]{{\\cal L}}
\\newcommand{\\vecteurno}[2]{#1,\\dots,#2}
\\newcommand{\\norm}[1]{\\left\\Vert#1\\right\\Vert}
\\newcommand{\\norme}[1]{\\left\\Vert#1\\right\\Vert}
\\newcommand{\\scal}[2]{\\left<#1,#2\\right>}
\\newcommand{\\dans}[0]{\\rightarrow}
\\newcommand{\\partialfrac}[2]{\\frac{\\partial #1}{\\partial #2}}
\\newcommand{\\partialdfrac}[2]{\\dfrac{\\partial #1}{\\partial #2}}
\\newcommand{\\trace}[1]{tr\\pa{#1}}
\\newcommand{\\sac}[0]{|}
\\newcommand{\\abs}[1]{\\left|#1\\right|}
\\newcommand{\\loinormale}[2]{{\\cal N} \\pa{#1,#2}}
\\newcommand{\\loibinomialea}[1]{{\\cal B} \\pa{#1}}
\\newcommand{\\loibinomiale}[2]{{\\cal B} \\pa{#1,#2}}
\\newcommand{\\loimultinomiale}[1]{{\\cal M} \\pa{#1}}
\\newcommand{\\variance}[1]{\\mathbb{V}\\pa{#1}}
"""
# \\usepackage{eepic}
imgmath_latex_preamble = preamble + custom_preamble
latex_elements['preamble'] = preamble + custom_preamble
mathdef_link_only = True
epkg_dictionary.update({
'ACP': 'https://fr.wikipedia.org/wiki/Analyse_en_composantes_principales',
"AESA": "https://tavianator.com/aesa/",
'ApproximateNMFPredictor':
'http://www.xavierdupre.fr/app/mlinsights/helpsphinx/mlinsights/mlmodel/anmf_predictor.html',
"B+ tree": "https://en.wikipedia.org/wiki/B%2B_tree",
"Branch and Bound": "https://en.wikipedia.org/wiki/Branch_and_bound",
"Custom Criterion for DecisionTreeRegressor":
"http://www.xavierdupre.fr/app/mlinsights/helpsphinx/notebooks/piecewise_linear_regression_criterion.html",
'cython': 'https://cython.org/',
'DecisionTreeClassifier':
'https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html',
'DecisionTreeRegressor optimized for Linear Regression':
"http://www.xavierdupre.fr/app/mlinsights/helpsphinx/notebooks/piecewise_linear_regression_criterion.html",
'dot': 'https://fr.wikipedia.org/wiki/DOT_(langage)',
'ICML 2016': 'https://icml.cc/2016/index.html',
'KMeans': 'https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html',
"LAESA": "https://tavianator.com/aesa/",
'LAPACK': 'http://www.netlib.org/lapack/',
'mlinsights': 'http://www.xavierdupre.fr/app/mlinsights/helpsphinx/index.html',
'PiecewiseTreeRegressor':
'http://www.xavierdupre.fr/app/mlinsights/helpsphinx/mlinsights/mlmodel/'
'piecewise_tree_regression.html#mlinsights.mlmodel.piecewise_tree_regression.PiecewiseTreeRegressor',
'Predictable t-SNE': 'http://www.xavierdupre.fr/app/mlinsights/helpsphinx/notebooks/predictable_tsne.html',
"R-tree": "https://en.wikipedia.org/wiki/R-tree",
"R* tree": "https://en.wikipedia.org/wiki/R*_tree",
'Regression with confidence interval':
'http://www.xavierdupre.fr/app/mlinsights/helpsphinx/notebooks/regression_confidence_interval.html',
'relu': 'https://en.wikipedia.org/wiki/Rectifier_(neural_networks)',
'ROC': 'https://fr.wikipedia.org/wiki/Courbe_ROC',
'statsmodels': 'http://www.statsmodels.org/stable/index.html',
'SVD': 'https://fr.wikipedia.org/wiki/D%C3%A9composition_en_valeurs_singuli%C3%A8res',
'Visualize a scikit-learn pipeline':
'http://www.xavierdupre.fr/app/mlinsights/helpsphinx/notebooks/visualize_pipeline.html',
"X-tree": "https://en.wikipedia.org/wiki/X-tree",
})
nblinks = {
'l-reglin-piecewise-streaming':
'http://www.xavierdupre.fr/app/mlstatpy/helpsphinx/c_ml/piecewise.html#streaming-linear-regression',
'cl-NeuralTreeNet':
'http://www.xavierdupre.fr/app/mlstatpy/helpsphinx//mlstatpy/ml/'
'neural_tree.html#mlstatpy.ml.neural_tree.NeuralTreeNet',
}
Extensions to install#
Tips#
Module pyquickhelper defines sphinx command runpython which generates from a python script included in the documentation itself. The following snippet produces a table.
<<<
from pyquickhelper.pandashelper import df2rst
import pandas
df = pandas.DataFrame([{"x": 3, "y": 4}, {"x": 3.5, "y": 5}])
print(df2rst(df))
>>>
x |
y |
---|---|
3.0 |
4.0 |
3.5 |
5.0 |
The next one is more complex. The code produces titles, label and references. It requires Sphinx engine to be processed.
<<<
rows = []
list_title = ["T1", "T2", "T3"]
back = None
for t in list_title:
rows.append("")
rows.append(".. _l-fake_title-" + t + ":")
rows.append("")
rows.append(t * 3)
rows.append("^" * len(t * 3))
rows.append("")
if back:
rows.append("link :ref:`l-fake_title-" + back + "`")
else:
rows.append("no link")
rows.append("")
back = t
print("\n".join(rows))
>>>
T1T1T1#
no link
T2T2T2#
link T1T1T1
T3T3T3#
link T2T2T2
Sortie brute
.. _l-fake_title-T1:
T1T1T1
^^^^^^
no link
.. _l-fake_title-T2:
T2T2T2
^^^^^^
link :ref:`l-fake_title-T1`
.. _l-fake_title-T3:
T3T3T3
^^^^^^
link :ref:`l-fake_title-T2`