Skip to content

Commit 303a918

Browse files
committed
doc
1 parent c9aee23 commit 303a918

16 files changed

+117
-148
lines changed

_doc/api/mlmodel.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ SimpleRegressorCriterion
170170
++++++++++++++++++++++++
171171

172172
.. autoclass:: mlinsights.mlmodel.piecewise_tree_regression_criterion.SimpleRegressorCriterion
173-
:members:
174173

175174
SimpleRegressorCriterionFast
176175
++++++++++++++++++++++++++++
@@ -179,7 +178,6 @@ A similar design but a much faster implementation close to what
179178
:epkg:`scikit-learn` implements.
180179

181180
.. autoclass:: mlinsights.mlmodel.piecewise_tree_regression_criterion_fast.SimpleRegressorCriterionFast
182-
:members:
183181

184182
LinearRegressorCriterion
185183
++++++++++++++++++++++++
@@ -190,4 +188,3 @@ a line. The mean square error is the error made with a linear regressor
190188
and not a constant anymore.
191189

192190
.. autoclass:: mlinsights.mlmodel.piecewise_tree_regression_criterion_linear.LinearRegressorCriterion
193-
:members:

_doc/conf.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@
107107
}
108108

109109
epkg_dictionary = {
110+
"bootstrap": "https://en.wikipedia.org/wiki/Bootstrapping_(statistics)",
110111
"cmake": "https://cmake.org/",
112+
"CountVectorizer": "https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.CountVectorizer.html",
111113
"CPUExecutionProvider": "https://onnxruntime.ai/docs/execution-providers/",
112114
"cublasLtMatmul": "https://docs.nvidia.com/cuda/cublas/index.html?highlight=cublasLtMatmul#cublasltmatmul",
113115
"CUDA": "https://developer.nvidia.com/",
@@ -116,10 +118,18 @@
116118
"CUDAExecutionProvider": "https://onnxruntime.ai/docs/execution-providers/",
117119
"custom_gemm.cu": "https://github.com/sdpython/mlinsights/blob/main/mlinsights/ortops/tutorial/cuda/custom_gemm.cu",
118120
"cython": "https://cython.org/",
121+
"decision tree": "https://en.wikipedia.org/wiki/Decision_tree",
122+
"dataframe": "https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html",
119123
"DOT": "https://graphviz.org/doc/info/lang.html",
120124
"eigen": "https://eigen.tuxfamily.org/",
121125
"gcc": "https://gcc.gnu.org/",
126+
"Iris": "https://scikit-learn.org/stable/auto_examples/datasets/plot_iris_dataset.html",
122127
"JIT": "https://en.wikipedia.org/wiki/Just-in-time_compilation",
128+
"KMeans": "https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html",
129+
"k-means": "https://en.wikipedia.org/wiki/K-means_clustering",
130+
"L1": "https://en.wikipedia.org/wiki/Norm_(mathematics)#Absolute-value_norm",
131+
"L2": "https://en.wikipedia.org/wiki/Norm_(mathematics)#Euclidean_norm",
132+
"matplotlib": "https://matplotlib.org/",
123133
"nccl": "https://developer.nvidia.com/nccl",
124134
"numpy": "https://numpy.org/",
125135
"numba": "https://numba.pydata.org/",
@@ -137,16 +147,41 @@
137147
"model-optimizations/graph-optimizations.html"
138148
),
139149
"openmp": "https://www.openmp.org/",
150+
"pandas": (
151+
"http://pandas.pydata.org/pandas-docs/stable/",
152+
("http://pandas.pydata.org/pandas-docs/stable/generated/pandas.{0}.html", 1),
153+
(
154+
"http://pandas.pydata.org/pandas-docs/stable/generated/pandas.{0}.{1}.html",
155+
2,
156+
),
157+
),
158+
"Pillow": "https://pillow.readthedocs.io/",
140159
"pybind11": "https://github.com/pybind/pybind11",
160+
"Python": "https://www.python.org/",
141161
"python": "https://www.python.org/",
142162
"Python C API": "https://docs.python.org/3/c-api/index.html",
143163
"pytorch": "https://pytorch.org/",
164+
"RandomForestRegressor": "https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestRegressor.html",
144165
"scikit-learn": "https://scikit-learn.org/stable/",
145166
"scipy": "https://scipy.org/",
167+
"sklearn": (
168+
"http://scikit-learn.org/stable/",
169+
("http://scikit-learn.org/stable/modules/generated/{0}.html", 1),
170+
("http://scikit-learn.org/stable/modules/generated/{0}.{1}.html", 2),
171+
),
146172
"sphinx-gallery": "https://github.com/sphinx-gallery/sphinx-gallery",
173+
"t-SNE": "https://lvdmaaten.github.io/tsne/",
174+
"TfidfVectorizer": "https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.TfidfVectorizer.html",
147175
"torch": "https://pytorch.org/docs/stable/torch.html",
148176
"tqdm": "https://tqdm.github.io/",
149177
"TreeEnsembleClassifier": "https://onnx.ai/onnx/operators/onnx_aionnxml_TreeEnsembleClassifier.html",
150178
"TreeEnsembleRegressor": "https://onnx.ai/onnx/operators/onnx_aionnxml_TreeEnsembleRegressor.html",
179+
"TSNE": "https://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html",
151180
"WSL": "https://docs.microsoft.com/en-us/windows/wsl/install",
181+
"*py": (
182+
"https://docs.python.org/3/",
183+
("https://docs.python.org/3/library/{0}.html", 1),
184+
("https://docs.python.org/3/library/{0}.html#{0}.{1}", 2),
185+
("https://docs.python.org/3/library/{0}.html#{0}.{1}.{2}", 3),
186+
),
152187
}

mlinsights/mlbatch/pipeline_cache.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ class PipelineCache(Pipeline):
2020
If True, the time elapsed while fitting each step will be printed as it
2121
is completed.
2222
23-
Other attributes:
24-
25-
:param named_steps: bunch object, a dictionary with attribute access
26-
Read-only attribute to access any step parameter by user given name.
27-
Keys are step names and values are steps parameters.
23+
The attribute *named_steps* is a bunch object, a dictionary
24+
with attribute access Read-only attribute to access any step
25+
parameter by user given name. Keys are step names and values
26+
are steps parameters.
2827
"""
2928

3029
def __init__(self, steps, cache_name=None, verbose=False):

mlinsights/mlmodel/categories_to_integers.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
class CategoriesToIntegers(BaseEstimator, TransformerMixin):
77
"""
88
Does something similar to what
9-
`DictVectorizer <http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.DictVectorizer.html>`_
9+
`DictVectorizer
10+
<http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.DictVectorizer.html>`_
1011
does but in a transformer. The method *fit* retains all categories,
1112
the method *transform* transforms categories into integers.
1213
Categories are sorted by columns. If the method *transform* tries to convert
@@ -32,7 +33,7 @@ class CategoriesToIntegers(BaseEstimator, TransformerMixin):
3233
3334
import pandas
3435
from mlinsights.mlmodel import CategoriesToIntegers
35-
df = pandas.DataFrame( [{"cat": "a"}, {"cat": "b"}] )
36+
df = pandas.DataFrame([{"cat": "a"}, {"cat": "b"}])
3637
trans = CategoriesToIntegers()
3738
trans.fit(df)
3839
newdf = trans.transform(df)
@@ -64,6 +65,7 @@ def fit(self, X, y=None, **fit_params):
6465
Training data
6566
:param y: iterable, default=None
6667
Training targets.
68+
:param fit_params: additional fit params
6769
:return: self
6870
"""
6971
if not isinstance(X, pandas.DataFrame):
@@ -112,7 +114,7 @@ def _build_schema(self):
112114

113115
return schema, position, new_vector
114116

115-
def transform(self, X, y=None, **fit_params):
117+
def transform(self, X, y=None):
116118
"""
117119
Transforms categories in numerical features based on the list
118120
of categories found by method *fit*.
@@ -204,6 +206,7 @@ def fit_transform(self, X, y=None, **fit_params):
204206
Training data
205207
:param y: iterable, default=None
206208
Training targets.
209+
:param fit_params: additional fitting parameters
207210
:return: Dataframe, *X* with categories.
208211
"""
209212
return self.fit(X, y=y, **fit_params).transform(X, y)

mlinsights/mlmodel/extended_features.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def fit(self, X, y=None):
119119
120120
:param X: array-like, shape (n_samples, n_features)
121121
The data.
122+
:param y: targets
122123
:return: self : instance
123124
"""
124125
self.n_input_features_ = X.shape[1]
@@ -144,9 +145,6 @@ def transform(self, X):
144145
:param X: array-like, shape [n_samples, n_features]
145146
The data to transform, row by row.
146147
rns
147-
:param XP: numpy.ndarray, shape [n_samples, NP]
148-
The matrix of features, where NP is the number of polynomial
149-
features generated from the combination of inputs.
150148
"""
151149
n_features = X.shape[1]
152150
if n_features != self.n_input_features_:

mlinsights/mlmodel/kmeans_constraint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def constraint_kmeans(
153153
:param X: features
154154
:param sample_weight: sample weight
155155
:param state: state
156+
:param learning_rate: learning rate
156157
:param history: keeps evolution of centers
157158
"""
158159
labels, centers, inertia, weights, iter_, all_centers = constraint_kmeans(

mlinsights/mlmodel/kmeans_l1.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -446,17 +446,6 @@ class KMeansL1L2(KMeans):
446446
single run.
447447
:param tol: float, default=1e-4
448448
Relative tolerance with regards to inertia to declare convergence.
449-
:param precompute_distances: default='lloyd'
450-
Precompute distances (faster but takes more memory).
451-
452-
'lloyd' : do not precompute distances if n_samples * n_clusters > 12
453-
million. This corresponds to about 100MB overhead per job using
454-
double precision.
455-
456-
True : always precompute distances.
457-
458-
False : never precompute distances.
459-
460449
:param verbose: int, default=0
461450
Verbosity mode.
462451
:param random_state: int, RandomState instance, default=None
@@ -471,13 +460,6 @@ class KMeansL1L2(KMeans):
471460
numerical differences may be introduced by subtracting and then adding
472461
the data mean, in this case it will also not ensure that data is
473462
C-contiguous which may cause a significant slowdown.
474-
:param n_jobs: int, default=None
475-
The number of jobs to use for the computation. This works by computing
476-
each of the n_init runs in parallel.
477-
478-
``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
479-
``-1`` means using all processors. See :term:`Glossary <n_jobs>`
480-
for more details.
481463
:param algorithm: {"lloyd", "elkan"}, default="lloyd"
482464
K-means algorithm to use. The classical EM-style algorithm is "lloyd".
483465
The "elkan" variation is more efficient by using the triangle

mlinsights/mlmodel/ml_featurizer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ def model_featurizer(model, **params):
1818
a vector into features produced by the model.
1919
It can be the output itself or intermediate results.
2020
The model can come from :epkg:`scikit-learn`,
21-
:epkg:`keras` or :epkg:`torch`.
21+
:epkg:`torch`.
2222
23-
@param model model
24-
@param params additional parameters
25-
@return function
23+
:param model: model
24+
:param params: additional parameters
25+
:return: function
2626
"""
2727
tried = []
2828
if isinstance(model, LogisticRegression):

mlinsights/mlmodel/predictable_tsne.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class PredictableTSNE(BaseEstimator, TransformerMixin):
2323
:param normalize: normalizes the outputs, centers and normalizes
2424
the output of the *t-SNE* and applies that same
2525
normalization to he prediction of the estimator
26-
:param keep_tsne_output: if True, keep raw outputs of
26+
:param keep_tsne_outputs: if True, keep raw outputs of
2727
:epkg:`TSNE` is stored in member `tsne_outputs_`
2828
"""
2929

mlinsights/mlmodel/quantile_mlpregressor.py

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -239,25 +239,23 @@ class QuantileMLPRegressor(CustomizedMultilayerPerceptron, RegressorMixin):
239239
hidden layer.
240240
:param activation: {'identity', 'logistic', 'tanh', 'relu'}, default 'relu'
241241
Activation function for the hidden layer.
242-
- 'identity', no-op activation, useful to implement linear bottleneck,
243-
returns :math:`f(x) = x`
244-
- 'logistic', the logistic sigmoid function,
245-
returns :math:`f(x) = 1 / (1 + exp(-x))`.
246-
- 'tanh', the hyperbolic tan function,
247-
returns :math:`f(x) = tanh(x)`.
248-
- 'relu', the rectified linear unit function,
249-
returns :math:`f(x) = \\max(0, x)`.
242+
'identity', no-op activation, useful to implement linear bottleneck,
243+
returns :math:`f(x) = x`,
244+
'logistic', the logistic sigmoid function,
245+
returns :math:`f(x) = 1 / (1 + exp(-x))`.
246+
'tanh', the hyperbolic tan function, returns :math:`f(x) = tanh(x)`.
247+
'relu', the rectified linear unit function,
248+
returns :math:`f(x) = \\max(0, x)`.
250249
:param solver: ``{'lbfgs', 'sgd', 'adam'}``, default 'adam'
251-
The solver for weight optimization.
252-
- *'lbfgs'* is an optimizer in the family of quasi-Newton methods.
253-
- *'sgd'* refers to stochastic gradient descent.
254-
- *'adam'* refers to a stochastic gradient-based optimizer proposed by
255-
Kingma, Diederik, and Jimmy Ba
250+
The solver for weight optimization,
251+
*'lbfgs'* is an optimizer in the family of quasi-Newton methods.
252+
*'sgd'* refers to stochastic gradient descent.
253+
*'adam'* refers to a stochastic gradient-based optimizer proposed by
254+
Kingma, Diederik, and Jimmy Ba
256255
Note: The default solver 'adam' works pretty well on relatively
257256
large datasets (with thousands of training samples or more) in terms of
258-
both training time and validation score.
259-
For small datasets, however, 'lbfgs' can converge faster and perform
260-
better.
257+
both training time and validation score. For small datasets, however,
258+
'lbfgs' can converge faster and perform better.
261259
:param alpha: float, optional, default 0.0001
262260
:epkg:`L2` penalty (regularization term) parameter.
263261
:param batch_size: int, optional, default 'auto'
@@ -266,17 +264,15 @@ class QuantileMLPRegressor(CustomizedMultilayerPerceptron, RegressorMixin):
266264
When set to "auto", `batch_size=min(200, n_samples)`
267265
:param learning_rate: {'constant', 'invscaling', 'adaptive'}, default 'constant'
268266
Learning rate schedule for weight updates.
269-
- 'constant' is a constant learning rate given by
270-
'learning_rate_init'.
271-
- 'invscaling' gradually decreases the learning rate ``learning_rate_``
272-
at each time step 't' using an inverse scaling exponent of 'power_t'.
273-
effective_learning_rate = learning_rate_init / pow(t, power_t)
274-
- 'adaptive' keeps the learning rate constant to
275-
'learning_rate_init' as long as training loss keeps decreasing.
276-
Each time two consecutive epochs fail to decrease training loss by at
277-
least tol, or fail to increase validation score by at least tol if
278-
'early_stopping' is on, the current learning rate is divided by 5.
279-
Only used when solver='sgd'.
267+
'constant' is a constant learning rate given by 'learning_rate_init',
268+
'invscaling' gradually decreases the learning rate ``learning_rate_``
269+
at each time step 't' using an inverse scaling exponent of 'power_t'.
270+
effective_learning_rate = learning_rate_init / pow(t, power_t),
271+
'adaptive' keeps the learning rate constant to 'learning_rate_init'
272+
as long as training loss keeps decreasing. Each time two consecutive
273+
epochs fail to decrease training loss by at least tol, or fail to
274+
increase validation score by at least tol if 'early_stopping' is on,
275+
the current learning rate is divided by 5. Only used when solver='sgd'.
280276
:param learning_rate_init: double, optional, default 0.001
281277
The initial learning rate used. It controls the step-size
282278
in updating the weights. Only used when solver='sgd' or 'adam'.
@@ -337,25 +333,26 @@ class QuantileMLPRegressor(CustomizedMultilayerPerceptron, RegressorMixin):
337333
:param n_iter_no_change: int, optional, default 10
338334
Maximum number of epochs to not meet ``tol`` improvement.
339335
Only effective when solver='sgd' or 'adam'
336+
:param kwargs: additional parameters sent to the constructor of the parent
340337
341338
Fitted attributes:
342339
343340
* `loss_`: float
344-
The current loss computed with the loss function.
341+
The current loss computed with the loss function.
345342
* `coefs_`: list, length n_layers - 1
346-
The ith element in the list represents the weight matrix corresponding
347-
to layer i.
343+
The ith element in the list represents the weight matrix corresponding
344+
to layer i.
348345
* `intercepts_`: list, length n_layers - 1
349-
The ith element in the list represents the bias vector corresponding to
350-
layer i + 1.
346+
The ith element in the list represents the bias vector corresponding to
347+
layer i + 1.
351348
* `n_iter_`: int,
352-
The number of iterations the solver has ran.
349+
The number of iterations the solver has ran.
353350
* `n_layers_`: int
354-
Number of layers.
351+
Number of layers.
355352
* `n_outputs_`: int
356-
Number of outputs.
353+
Number of outputs.
357354
* `out_activation_`: string
358-
Name of the output activation function.
355+
Name of the output activation function.
359356
"""
360357

361358
def __init__(

0 commit comments

Comments
 (0)