You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/changes/0.4.rst
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,4 +5,5 @@ Version 0.4 (in progress)
5
5
- Add support for weights and positive coefficients to :ref:`MCPRegression Estimator <skglm.MCPRegression>` (PR: :gh:`184`)
6
6
- Move solver specific computations from ``Datafit.initialize()`` to separate ``Datafit`` methods to ease ``Solver`` - ``Datafit`` compatibility check (PR: :gh:`192`)
Copy file name to clipboardExpand all lines: doc/tutorials/add_datafit.rst
+9-10Lines changed: 9 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,16 +30,17 @@ They can then be passed to a :class:`~skglm.GeneralizedLinearEstimator`.
30
30
)
31
31
32
32
33
-
A ``Datafit`` is a jitclass which must inherit from the ``BaseDatafit`` class:
33
+
A ``Datafit`` is a jitclass that must inherit from the ``BaseDatafit`` class:
34
34
35
-
.. literalinclude:: ../skglm/datafits/base.py
35
+
.. literalinclude:: ../../skglm/datafits/base.py
36
36
:pyobject: BaseDatafit
37
37
38
38
39
-
To define a custom datafit, you need to implement the methods declared in the ``BaseDatafit`` class.
40
-
One needs to overload at least the ``value`` and ``gradient`` methods for skglm to support the datafit.
39
+
To define a custom datafit, you need to inherit from ``BaseDatafit`` class and implement methods required by the targeted solver.
40
+
These methods can be found in the solver documentation.
41
41
Optionally, overloading the methods with the suffix ``_sparse`` adds support for sparse datasets (CSC matrix).
42
-
As an example, we show how to implement the Poisson datafit in skglm.
42
+
43
+
This tutorial shows how to implement :ref:`Poisson <skglm.datafits.Poisson>` datafit to be fitted with :ref:`ProxNewton <skglm.solvers.ProxNewton>` solver.
43
44
44
45
45
46
A case in point: defining Poisson datafit
@@ -104,18 +105,16 @@ For the Poisson datafit, this yields
Note that we have not initialized any quantities in the ``initialize`` method.
119
-
Usually it serves to compute a Lipschitz constant of the datafit, whose inverse is used by the solver as a step size.
120
-
However, in this example, the Poisson datafit has no Lipschitz constant since the eigenvalues of the Hessian matrix are unbounded.
121
-
This implies that a step size is not known in advance and a line search has to be performed at every epoch by the solver.
120
+
Usually, it serves to compute datafit attributes specific to a dataset ``X, y`` for computational efficiency, for example the computation of ``X.T @ y`` in :ref:`Quadratic <skglm.datafits.Quadratic>` datafit.
Copy file name to clipboardExpand all lines: doc/tutorials/add_penalty.rst
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,12 @@ skglm supports any arbitrary proximable penalty.
10
10
11
11
It is implemented as a jitclass which must inherit from the ``BasePenalty`` class:
12
12
13
-
.. literalinclude:: ../skglm/penalties/base.py
13
+
.. literalinclude:: ../../skglm/penalties/base.py
14
14
:pyobject: BasePenalty
15
15
16
-
To implement your own penalty, you only need to define a new jitclass, inheriting from ``BasePenalty`` and define how its value, proximal operator, distance to subdifferential (for KKT violation) and penalized features are computed.
16
+
To implement your own penalty, you only need to define a new jitclass, inheriting from ``BasePenalty`` and implement the methods required by the targeted solver.
17
+
Theses methods can be found in the solver documentation.
18
+
17
19
18
20
A case in point: defining L1 penalty
19
21
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -66,6 +68,6 @@ Note that since ``lambda`` is a reserved keyword in Python, ``alpha`` in skglm c
66
68
When putting all together, this gives the implementation of the ``L1`` penalty:
0 commit comments