Skip to content

Commit 4ebda92

Browse files
committed
initial commit
0 parents  commit 4ebda92

33 files changed

+5422
-0
lines changed

.github/workflows/flake8.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: linter
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- 'main'
10+
11+
jobs:
12+
lint:
13+
name: Lint code base
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
20+
- name: Setup Python 3.8
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: 3.8
24+
25+
- name: Lint with flake
26+
run: |
27+
pip install flake8
28+
flake8 skglm/ --exclude="skglm/expes/*","skglm/profile","*/toprof.py*" --max-line-length=88
29+
30+
- name: Check doc style with pydocstyle
31+
run: |
32+
pip install pydocstyle
33+
pydocstyle skglm --ignore='D100',D102,'D104','D107','D203','D213','D413'

.github/workflows/main.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: pytest
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
8+
pull_request:
9+
10+
jobs:
11+
test:
12+
name: Test Code
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up Python 3.8
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: 3.8
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install pytest
24+
pip install numpydoc
25+
pip install .
26+
- name: Test with pytest
27+
run: pytest -v skglm/

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/skglm.egg-info/*
2+
*.pyc
3+
4+
/doc/_build/
5+
/doc/gen_modules/
6+
/doc/generated/
7+
/doc/auto_examples/

doc/Makefile

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
PAPER =
8+
BUILDDIR = _build
9+
10+
GITHUB_PAGES_BRANCH = gh-pages
11+
OUTPUTDIR = _build/html
12+
13+
# User-friendly check for sphinx-build
14+
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
15+
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
16+
endif
17+
18+
# Internal variables.
19+
PAPEROPT_a4 = -D latex_paper_size=a4
20+
PAPEROPT_letter = -D latex_paper_size=letter
21+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
22+
# the i18n builder cannot share the environment and doctrees with the others
23+
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
24+
25+
.PHONY: help
26+
help:
27+
@echo "Please use \`make <target>' where <target> is one of"
28+
@echo " html-noplot to make standalone HTML files, without plotting anything"
29+
@echo " html to make standalone HTML files"
30+
@echo " dirhtml to make HTML files named index.html in directories"
31+
@echo " singlehtml to make a single large HTML file"
32+
@echo " pickle to make pickle files"
33+
@echo " htmlhelp to make HTML files and a HTML help project"
34+
@echo " qthelp to make HTML files and a qthelp project"
35+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
36+
@echo " latexpdf to make LaTeX files and run them through pdflatex"
37+
@echo " changes to make an overview of all changed/added/deprecated items"
38+
@echo " linkcheck to check all external links for integrity"
39+
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
40+
@echo " coverage to run coverage check of the documentation (if enabled)"
41+
@echo " install to make the html and push it online"
42+
43+
.PHONY: clean
44+
45+
clean:
46+
rm -rf $(BUILDDIR)/*
47+
rm -rf auto_examples/
48+
rm -rf generated/*
49+
rm -rf modules/*
50+
51+
html-noplot:
52+
$(SPHINXBUILD) -D plot_gallery=0 -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
53+
@echo
54+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
55+
56+
.PHONY: html
57+
html:
58+
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
59+
@echo
60+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
61+
62+
.PHONY: dirhtml
63+
dirhtml:
64+
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
65+
@echo
66+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
67+
68+
.PHONY: singlehtml
69+
singlehtml:
70+
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
71+
@echo
72+
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
73+
74+
.PHONY: pickle
75+
pickle:
76+
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
77+
@echo
78+
@echo "Build finished; now you can process the pickle files."
79+
80+
.PHONY: htmlhelp
81+
htmlhelp:
82+
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
83+
@echo
84+
@echo "Build finished; now you can run HTML Help Workshop with the" \
85+
".hhp project file in $(BUILDDIR)/htmlhelp."
86+
87+
.PHONY: qthelp
88+
qthelp:
89+
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
90+
@echo
91+
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
92+
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
93+
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/skglm.qhcp"
94+
@echo "To view the help file:"
95+
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/skglms.qhc"
96+
97+
.PHONY: latex
98+
latex:
99+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
100+
@echo
101+
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
102+
@echo "Run \`make' in that directory to run these through (pdf)latex" \
103+
"(use \`make latexpdf' here to do that automatically)."
104+
105+
.PHONY: latexpdf
106+
latexpdf:
107+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
108+
@echo "Running LaTeX files through pdflatex..."
109+
$(MAKE) -C $(BUILDDIR)/latex all-pdf
110+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
111+
112+
.PHONY: changes
113+
changes:
114+
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
115+
@echo
116+
@echo "The overview file is in $(BUILDDIR)/changes."
117+
118+
.PHONY: linkcheck
119+
linkcheck:
120+
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
121+
@echo
122+
@echo "Link check complete; look for any errors in the above output " \
123+
"or in $(BUILDDIR)/linkcheck/output.txt."
124+
125+
.PHONY: doctest
126+
doctest:
127+
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
128+
@echo "Testing of doctests in the sources finished, look at the " \
129+
"results in $(BUILDDIR)/doctest/output.txt."
130+
131+
.PHONY: coverage
132+
coverage:
133+
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
134+
@echo "Testing of coverage in the sources finished, look at the " \
135+
"results in $(BUILDDIR)/coverage/python.txt."
136+
137+
install:
138+
touch $(OUTPUTDIR)/.nojekyll
139+
ghp-import -m "Generate Pelican site [ci skip]" -b $(GITHUB_PAGES_BRANCH) $(OUTPUTDIR)
140+
git push origin $(GITHUB_PAGES_BRANCH)

doc/add.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
:orphan:
2+
3+
.. _how:
4+
5+
With skglm, you can solve any custom Generalized Linear Model with arbitrary smooth datafit and arbitrary proximable penalty, by defining two classes: a ``Penalty`` and a ``Datafit``.
6+
7+
8+
How to add a custom penalty
9+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
11+
A penalty is a jitclass which must inherit from the ``BasePenalty`` class:
12+
13+
.. literalinclude:: ../skglm/penalties/base.py
14+
:pyobject: BasePenalty
15+
16+
17+
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.
18+
19+
For example, the implementation of the ``L1`` penalty is:
20+
21+
.. literalinclude:: ../skglm/penalties/separable.py
22+
:pyobject: L1
23+
24+
25+
26+
How to add a custom datafit
27+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
28+
29+
A ``Datafit`` is a jitclass which must inherit from the ``BaseDatafit`` class:
30+
31+
.. literalinclude:: ../skglm/datafits/base.py
32+
:pyobject: BaseDatafit
33+
34+
35+
To define a custom datafit, you need to implement the methods declared in the ``BaseDatafit`` class (value, gradient, gradient when the design matrix is sparse).
36+
See for example the implementation of the ``Quadratic`` datafit:
37+
38+
.. literalinclude:: ../skglm/datafits/single_task.py
39+
:pyobject: Quadratic

doc/api.rst

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
.. _api_documentation:
2+
3+
=================
4+
API Documentation
5+
=================
6+
7+
.. currentmodule:: skglm
8+
9+
Estimators
10+
==========
11+
12+
.. currentmodule:: skglm
13+
14+
.. autosummary::
15+
:toctree: generated/
16+
17+
ElasticNet
18+
Lasso
19+
LinearSVC
20+
SparseLogisticRegression
21+
MCPRegression
22+
MultiTaskLasso
23+
WeightedLasso
24+
25+
26+
Penalties
27+
=========
28+
29+
30+
.. currentmodule:: skglm.penalties
31+
32+
.. autosummary::
33+
:toctree: generated/
34+
35+
IndicatorBox
36+
L0_5
37+
L1
38+
L1_plus_L2
39+
L2_3
40+
MCPenalty
41+
WeightedL1
42+
43+
44+
Datafits
45+
========
46+
47+
.. currentmodule:: skglm.datafits
48+
49+
.. autosummary::
50+
:toctree: generated/
51+
52+
Logistic
53+
Quadratic
54+
QuadraticSVC
55+
56+
57+

0 commit comments

Comments
 (0)