SWoTTeD 1.0.2a4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. swotted-1.0.2a4/.gitignore +13 -0
  2. swotted-1.0.2a4/.gitlab-ci.yml +40 -0
  3. swotted-1.0.2a4/.vscode/launch.json +17 -0
  4. swotted-1.0.2a4/.vscode/settings.json +6 -0
  5. swotted-1.0.2a4/LICENSE.txt +165 -0
  6. swotted-1.0.2a4/PKG-INFO +249 -0
  7. swotted-1.0.2a4/README.md +56 -0
  8. swotted-1.0.2a4/TODO.md +17 -0
  9. swotted-1.0.2a4/docs/Makefile +20 -0
  10. swotted-1.0.2a4/docs/make.bat +35 -0
  11. swotted-1.0.2a4/docs/requirements.txt +16 -0
  12. swotted-1.0.2a4/docs/source/citing.rst +28 -0
  13. swotted-1.0.2a4/docs/source/conf.py +92 -0
  14. swotted-1.0.2a4/docs/source/experiments.rst +21 -0
  15. swotted-1.0.2a4/docs/source/index.rst +37 -0
  16. swotted-1.0.2a4/docs/source/modules.rst +8 -0
  17. swotted-1.0.2a4/docs/source/notebooks/SWoTTeD_firstrun.ipynb +197 -0
  18. swotted-1.0.2a4/docs/source/notebooks/SWoTTeD_module_example.ipynb +1 -0
  19. swotted-1.0.2a4/docs/source/notebooks/SWoTTeD_test_images.ipynb +197 -0
  20. swotted-1.0.2a4/docs/source/notebooks/SWoTTeD_w1.ipynb +1 -0
  21. swotted-1.0.2a4/docs/source/notebooks/model_cmp.ipynb +602 -0
  22. swotted-1.0.2a4/docs/source/readme.rst +2 -0
  23. swotted-1.0.2a4/docs/source/swotted.rst +77 -0
  24. swotted-1.0.2a4/experiments/__init__.py +9 -0
  25. swotted-1.0.2a4/experiments/conf/experiment1.yaml +70 -0
  26. swotted-1.0.2a4/experiments/experiment.py +150 -0
  27. swotted-1.0.2a4/experiments/mimic/CohortConstruction.ipynb +548 -0
  28. swotted-1.0.2a4/experiments/mimic/run_SWoTTeD_mimic.ipynb +207 -0
  29. swotted-1.0.2a4/experiments/run_SwoTTeD_synthetic_data.ipynb +289 -0
  30. swotted-1.0.2a4/logo.png +0 -0
  31. swotted-1.0.2a4/pyproject.toml +69 -0
  32. swotted-1.0.2a4/sliding_window_temporal_phenotyping.png +0 -0
  33. swotted-1.0.2a4/swotted/__init__.py +17 -0
  34. swotted-1.0.2a4/swotted/decomposition_contraints.py +87 -0
  35. swotted-1.0.2a4/swotted/fastswotted.py +604 -0
  36. swotted-1.0.2a4/swotted/loss_metrics.py +39 -0
  37. swotted-1.0.2a4/swotted/slidingWindow_model.py +161 -0
  38. swotted-1.0.2a4/swotted/swotted.py +417 -0
  39. swotted-1.0.2a4/swotted/temporal_regularization.py +56 -0
  40. swotted-1.0.2a4/swotted/utils.py +52 -0
  41. swotted-1.0.2a4/swotted/version.py +9 -0
  42. swotted-1.0.2a4/tests/FastswoTTed_test.py +114 -0
  43. swotted-1.0.2a4/tests/Random_test.py +87 -0
  44. swotted-1.0.2a4/tests/SWoTTeD_module_test.py +110 -0
  45. swotted-1.0.2a4/tests/gen_data.py +271 -0
@@ -0,0 +1,13 @@
1
+ **/lightning_logs
2
+ **/__pycache__
3
+ *.pyc
4
+ poetry.lock
5
+ mlruns/*
6
+ multirun/*
7
+ outputs/*
8
+ run.log
9
+ docs/build/*
10
+ dist/*
11
+ venv/*
12
+ **/.ipynb_checkpoints
13
+ swotted/version.py
@@ -0,0 +1,40 @@
1
+ ## Pipeline for sphinx
2
+ ## -> CI must be activated in the gitlab repo (in Settings>Generals)
3
+ ## -> Runners must also be enabled (in Settings>CI/CD: use the Inria runners)
4
+
5
+ #"pages" is the name of the pipeline
6
+ pages:
7
+ # There exists some standard images to ease the preparation of the task
8
+ image: sphinxdoc/sphinx
9
+ stage: deploy
10
+
11
+ # Tags are used to specify the runner, with Inria gitlab, we use the runners of Inria. The Tags designates the type of machine to use.
12
+ tags:
13
+ - ci.inria.fr
14
+ - small
15
+ - linux
16
+
17
+ # Here, we describe the task to
18
+ script:
19
+ - apt update
20
+ - apt install -y gcc g++
21
+ - apt --yes install pandoc
22
+ - cd docs
23
+ - pip install -r requirements.txt
24
+ - mkdir build
25
+ - mkdir source/_static source/_templates
26
+ - sphinx-apidoc -f -o source/ ..
27
+ - make html
28
+ - cd ..
29
+ - mkdir -p public
30
+ - cp -rf docs/build/html/* public/
31
+ - cp -rf sliding_window_temporal_phenotyping.png public/sliding_window_temporal_phenotyping.png
32
+
33
+ # artifact os something to be deployed
34
+ artifacts:
35
+ paths:
36
+ - public
37
+
38
+ # Runners will explore only the 'master' branch of the repo
39
+ only:
40
+ - main
@@ -0,0 +1,17 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "Python: Current File",
9
+ "type": "python",
10
+ "request": "launch",
11
+ "program": "${file}",
12
+ "console": "integratedTerminal",
13
+ "justMyCode": true,
14
+ "env": {"PYTHONPATH":"${workspaceFolder}${pathSeparator}${env:PYTHONPATH}"}
15
+ }
16
+ ]
17
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "[python]": {
3
+ "editor.defaultFormatter": "ms-python.black-formatter"
4
+ },
5
+ "python.formatting.provider": "none"
6
+ }
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,249 @@
1
+ Metadata-Version: 2.3
2
+ Name: SWoTTeD
3
+ Version: 1.0.2a4
4
+ Summary: A tensor decomposition model extracting temporal phenotypes
5
+ Project-URL: homepage, https://gitlab.inria.fr/hsebia/swotted
6
+ Project-URL: repository, https://gitlab.inria.fr/hsebia/swotted
7
+ Project-URL: documentation, https://hsebia.gitlabpages.inria.fr/swotted/
8
+ Author-email: Hana Sebia <hana.sebia@inria.fr>, Thomas Guyet <thomas.guyet@inria.fr>, Mike Rye <jan-michael.rye@inria.fr>
9
+ License: GNU LESSER GENERAL PUBLIC LICENSE
10
+ Version 3, 29 June 2007
11
+
12
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
13
+ Everyone is permitted to copy and distribute verbatim copies
14
+ of this license document, but changing it is not allowed.
15
+
16
+
17
+ This version of the GNU Lesser General Public License incorporates
18
+ the terms and conditions of version 3 of the GNU General Public
19
+ License, supplemented by the additional permissions listed below.
20
+
21
+ 0. Additional Definitions.
22
+
23
+ As used herein, "this License" refers to version 3 of the GNU Lesser
24
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
25
+ General Public License.
26
+
27
+ "The Library" refers to a covered work governed by this License,
28
+ other than an Application or a Combined Work as defined below.
29
+
30
+ An "Application" is any work that makes use of an interface provided
31
+ by the Library, but which is not otherwise based on the Library.
32
+ Defining a subclass of a class defined by the Library is deemed a mode
33
+ of using an interface provided by the Library.
34
+
35
+ A "Combined Work" is a work produced by combining or linking an
36
+ Application with the Library. The particular version of the Library
37
+ with which the Combined Work was made is also called the "Linked
38
+ Version".
39
+
40
+ The "Minimal Corresponding Source" for a Combined Work means the
41
+ Corresponding Source for the Combined Work, excluding any source code
42
+ for portions of the Combined Work that, considered in isolation, are
43
+ based on the Application, and not on the Linked Version.
44
+
45
+ The "Corresponding Application Code" for a Combined Work means the
46
+ object code and/or source code for the Application, including any data
47
+ and utility programs needed for reproducing the Combined Work from the
48
+ Application, but excluding the System Libraries of the Combined Work.
49
+
50
+ 1. Exception to Section 3 of the GNU GPL.
51
+
52
+ You may convey a covered work under sections 3 and 4 of this License
53
+ without being bound by section 3 of the GNU GPL.
54
+
55
+ 2. Conveying Modified Versions.
56
+
57
+ If you modify a copy of the Library, and, in your modifications, a
58
+ facility refers to a function or data to be supplied by an Application
59
+ that uses the facility (other than as an argument passed when the
60
+ facility is invoked), then you may convey a copy of the modified
61
+ version:
62
+
63
+ a) under this License, provided that you make a good faith effort to
64
+ ensure that, in the event an Application does not supply the
65
+ function or data, the facility still operates, and performs
66
+ whatever part of its purpose remains meaningful, or
67
+
68
+ b) under the GNU GPL, with none of the additional permissions of
69
+ this License applicable to that copy.
70
+
71
+ 3. Object Code Incorporating Material from Library Header Files.
72
+
73
+ The object code form of an Application may incorporate material from
74
+ a header file that is part of the Library. You may convey such object
75
+ code under terms of your choice, provided that, if the incorporated
76
+ material is not limited to numerical parameters, data structure
77
+ layouts and accessors, or small macros, inline functions and templates
78
+ (ten or fewer lines in length), you do both of the following:
79
+
80
+ a) Give prominent notice with each copy of the object code that the
81
+ Library is used in it and that the Library and its use are
82
+ covered by this License.
83
+
84
+ b) Accompany the object code with a copy of the GNU GPL and this license
85
+ document.
86
+
87
+ 4. Combined Works.
88
+
89
+ You may convey a Combined Work under terms of your choice that,
90
+ taken together, effectively do not restrict modification of the
91
+ portions of the Library contained in the Combined Work and reverse
92
+ engineering for debugging such modifications, if you also do each of
93
+ the following:
94
+
95
+ a) Give prominent notice with each copy of the Combined Work that
96
+ the Library is used in it and that the Library and its use are
97
+ covered by this License.
98
+
99
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
100
+ document.
101
+
102
+ c) For a Combined Work that displays copyright notices during
103
+ execution, include the copyright notice for the Library among
104
+ these notices, as well as a reference directing the user to the
105
+ copies of the GNU GPL and this license document.
106
+
107
+ d) Do one of the following:
108
+
109
+ 0) Convey the Minimal Corresponding Source under the terms of this
110
+ License, and the Corresponding Application Code in a form
111
+ suitable for, and under terms that permit, the user to
112
+ recombine or relink the Application with a modified version of
113
+ the Linked Version to produce a modified Combined Work, in the
114
+ manner specified by section 6 of the GNU GPL for conveying
115
+ Corresponding Source.
116
+
117
+ 1) Use a suitable shared library mechanism for linking with the
118
+ Library. A suitable mechanism is one that (a) uses at run time
119
+ a copy of the Library already present on the user's computer
120
+ system, and (b) will operate properly with a modified version
121
+ of the Library that is interface-compatible with the Linked
122
+ Version.
123
+
124
+ e) Provide Installation Information, but only if you would otherwise
125
+ be required to provide such information under section 6 of the
126
+ GNU GPL, and only to the extent that such information is
127
+ necessary to install and execute a modified version of the
128
+ Combined Work produced by recombining or relinking the
129
+ Application with a modified version of the Linked Version. (If
130
+ you use option 4d0, the Installation Information must accompany
131
+ the Minimal Corresponding Source and Corresponding Application
132
+ Code. If you use option 4d1, you must provide the Installation
133
+ Information in the manner specified by section 6 of the GNU GPL
134
+ for conveying Corresponding Source.)
135
+
136
+ 5. Combined Libraries.
137
+
138
+ You may place library facilities that are a work based on the
139
+ Library side by side in a single library together with other library
140
+ facilities that are not Applications and are not covered by this
141
+ License, and convey such a combined library under terms of your
142
+ choice, if you do both of the following:
143
+
144
+ a) Accompany the combined library with a copy of the same work based
145
+ on the Library, uncombined with any other library facilities,
146
+ conveyed under the terms of this License.
147
+
148
+ b) Give prominent notice with the combined library that part of it
149
+ is a work based on the Library, and explaining where to find the
150
+ accompanying uncombined form of the same work.
151
+
152
+ 6. Revised Versions of the GNU Lesser General Public License.
153
+
154
+ The Free Software Foundation may publish revised and/or new versions
155
+ of the GNU Lesser General Public License from time to time. Such new
156
+ versions will be similar in spirit to the present version, but may
157
+ differ in detail to address new problems or concerns.
158
+
159
+ Each version is given a distinguishing version number. If the
160
+ Library as you received it specifies that a certain numbered version
161
+ of the GNU Lesser General Public License "or any later version"
162
+ applies to it, you have the option of following the terms and
163
+ conditions either of that published version or of any later version
164
+ published by the Free Software Foundation. If the Library as you
165
+ received it does not specify a version number of the GNU Lesser
166
+ General Public License, you may choose any version of the GNU Lesser
167
+ General Public License ever published by the Free Software Foundation.
168
+
169
+ If the Library as you received it specifies that a proxy can decide
170
+ whether future versions of the GNU Lesser General Public License shall
171
+ apply, that proxy's public statement of acceptance of any version is
172
+ permanent authorization for you to choose that version for the
173
+ Library.
174
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
175
+ Classifier: Operating System :: OS Independent
176
+ Classifier: Programming Language :: Python :: 3
177
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
178
+ Requires-Python: >=3.7
179
+ Requires-Dist: datetime
180
+ Requires-Dist: fastapi
181
+ Requires-Dist: ipykernel
182
+ Requires-Dist: jupyter
183
+ Requires-Dist: lightning
184
+ Requires-Dist: matplotlib
185
+ Requires-Dist: munkres
186
+ Requires-Dist: numpy
187
+ Requires-Dist: omegaconf
188
+ Requires-Dist: pandas
189
+ Requires-Dist: psycopg
190
+ Requires-Dist: pytorch-lightning
191
+ Requires-Dist: seaborn
192
+ Description-Content-Type: text/markdown
193
+
194
+ # SWoTTeD : An Extension of Tensor Decomposition to Temporal Phenotyping
195
+
196
+ This repository contains the implementation of **SWoTTeD** (**S**liding **W**ind**o**w for **T**emporal **Te**nsor **D**ecomposition)
197
+
198
+ ![Illustration of SwoTTeD Decomposition](./sliding_window_temporal_phenotyping.png)
199
+
200
+
201
+ ### Authors
202
+
203
+ * Hana Sebia, Inria, [AIstroSight](https://team.inria.fr/aistrosight/)
204
+ * Thomas Guyet, Inria, [AIstroSight](https://team.inria.fr/aistrosight/)
205
+ * Mike Rye, Inria, [AIstroSight](https://team.inria.fr/aistrosight/)
206
+
207
+ ### Overview
208
+
209
+ ***SWoTTeD*** is a tensor decomposition framework to extract temporal phenotypes from structured data. Most recent decomposition models allow extracting phenotypes that only describe snapshots of typical profiles, also called daily phenotypes. However, ***SWoTTeD*** extends the notion of daily phenotype into temporal phenotype describing an arrangement of features over a time window.
210
+
211
+ The capabilities of the SWoTTeD model are illustrated in the [example notebook](./notebooks/SWoTTeD_module_example.ipynb).
212
+
213
+
214
+ This code implements the SWoTTeD as a [PyTorch Lightning](http://lightning.ai) module that you can embed in you own architecture. The `SWoTTeD` module enables:
215
+ * to discover phenotypes through the decomposition of a *3D tensor* (with dimensions: patients, features and time). To deal with patient' data having different duration, the dataset is a collection of pathways (2D matrices);
216
+ * to project new patient pathways on discovered phenotypes;
217
+ * to predict next events in a pathways.
218
+
219
+ More documentation about this project and how to use the model is available here: [https://hsebia.gitlabpages.inria.fr/swotted/](https://hsebia.gitlabpages.inria.fr/swotted/).
220
+
221
+ ### How to install
222
+
223
+ The `pyproject.toml` is the project configuration file for *hatchling* which enables to create and set up a virtual environment suitable to run `SWoTTeD`.
224
+
225
+ ```bash
226
+ git clone https://gitlab.inria.fr/hsebia/swotted
227
+
228
+ cd swotted
229
+ pip install -e .
230
+ ```
231
+
232
+ `SWoTTeD` is also available on the Python Package Index (PyPI). In this case, you will only have the model (but not the tests, including the random generator of random tensors with hidden patterns). See the First run example in the documentation in this case.
233
+
234
+ ```bash
235
+ pip install swotted
236
+ ```
237
+
238
+ ### How to cite
239
+
240
+ ```bibtex
241
+ @article{sebia2024swotted,
242
+ title={SWoTTeD: an extension of tensor decomposition to temporal phenotyping},
243
+ author={Sebia, Hana and Guyet, Thomas and Audureau, Etienne},
244
+ journal={Machine Learning},
245
+ pages={1--42},
246
+ year={2024},
247
+ publisher={Springer}
248
+ }
249
+ ```
@@ -0,0 +1,56 @@
1
+ # SWoTTeD : An Extension of Tensor Decomposition to Temporal Phenotyping
2
+
3
+ This repository contains the implementation of **SWoTTeD** (**S**liding **W**ind**o**w for **T**emporal **Te**nsor **D**ecomposition)
4
+
5
+ ![Illustration of SwoTTeD Decomposition](./sliding_window_temporal_phenotyping.png)
6
+
7
+
8
+ ### Authors
9
+
10
+ * Hana Sebia, Inria, [AIstroSight](https://team.inria.fr/aistrosight/)
11
+ * Thomas Guyet, Inria, [AIstroSight](https://team.inria.fr/aistrosight/)
12
+ * Mike Rye, Inria, [AIstroSight](https://team.inria.fr/aistrosight/)
13
+
14
+ ### Overview
15
+
16
+ ***SWoTTeD*** is a tensor decomposition framework to extract temporal phenotypes from structured data. Most recent decomposition models allow extracting phenotypes that only describe snapshots of typical profiles, also called daily phenotypes. However, ***SWoTTeD*** extends the notion of daily phenotype into temporal phenotype describing an arrangement of features over a time window.
17
+
18
+ The capabilities of the SWoTTeD model are illustrated in the [example notebook](./notebooks/SWoTTeD_module_example.ipynb).
19
+
20
+
21
+ This code implements the SWoTTeD as a [PyTorch Lightning](http://lightning.ai) module that you can embed in you own architecture. The `SWoTTeD` module enables:
22
+ * to discover phenotypes through the decomposition of a *3D tensor* (with dimensions: patients, features and time). To deal with patient' data having different duration, the dataset is a collection of pathways (2D matrices);
23
+ * to project new patient pathways on discovered phenotypes;
24
+ * to predict next events in a pathways.
25
+
26
+ More documentation about this project and how to use the model is available here: [https://hsebia.gitlabpages.inria.fr/swotted/](https://hsebia.gitlabpages.inria.fr/swotted/).
27
+
28
+ ### How to install
29
+
30
+ The `pyproject.toml` is the project configuration file for *hatchling* which enables to create and set up a virtual environment suitable to run `SWoTTeD`.
31
+
32
+ ```bash
33
+ git clone https://gitlab.inria.fr/hsebia/swotted
34
+
35
+ cd swotted
36
+ pip install -e .
37
+ ```
38
+
39
+ `SWoTTeD` is also available on the Python Package Index (PyPI). In this case, you will only have the model (but not the tests, including the random generator of random tensors with hidden patterns). See the First run example in the documentation in this case.
40
+
41
+ ```bash
42
+ pip install swotted
43
+ ```
44
+
45
+ ### How to cite
46
+
47
+ ```bibtex
48
+ @article{sebia2024swotted,
49
+ title={SWoTTeD: an extension of tensor decomposition to temporal phenotyping},
50
+ author={Sebia, Hana and Guyet, Thomas and Audureau, Etienne},
51
+ journal={Machine Learning},
52
+ pages={1--42},
53
+ year={2024},
54
+ publisher={Springer}
55
+ }
56
+ ```
@@ -0,0 +1,17 @@
1
+ ---
2
+ title: TODO
3
+ ---
4
+
5
+ # SWoTTeD model improvements
6
+
7
+ * auto-SWoTTeD: integrate the automatic selection of (some) optimal parameters through a validation step. The idea would be also to start with different random initial states and the run few steps to select one of them on a validation dataset. The choosen model would be refined with more steps.
8
+ * hybrid-SWoTTeD: an implementation of a tensor decomposition method that handles features with different characteristics (and different metrics in losses)
9
+
10
+ # Examples
11
+
12
+ * Create more example in the documentation
13
+
14
+ # Meta
15
+
16
+ * Make some more experiments/improvements for GPU
17
+
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = source
9
+ BUILDDIR = build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=source
11
+ set BUILDDIR=build
12
+
13
+ if "%1" == "" goto help
14
+
15
+ %SPHINXBUILD% >NUL 2>NUL
16
+ if errorlevel 9009 (
17
+ echo.
18
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19
+ echo.installed, then set the SPHINXBUILD environment variable to point
20
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
21
+ echo.may add the Sphinx directory to PATH.
22
+ echo.
23
+ echo.If you don't have Sphinx installed, grab it from
24
+ echo.https://www.sphinx-doc.org/
25
+ exit /b 1
26
+ )
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
@@ -0,0 +1,16 @@
1
+ pytorch-lightning >= 2.0.1
2
+ lightning >= 2.0.1
3
+ fastapi >= 0.80
4
+ torch >= 1.13.0
5
+ munkres >= 1.1.4
6
+ numpy >= 1.23.5
7
+ DateTime >= 4.7
8
+ seaborn >= 0.12.1
9
+ matplotlib >= 3.6.2
10
+ pandas >= 1.5.2
11
+ psycopg >= 3.1.4
12
+ sphinx >= 6.2.1
13
+ sphinx-rtd-theme >= 1.2.0
14
+ myst-parser >= 1.0.0
15
+ nbsphinx
16
+ ipykernel
@@ -0,0 +1,28 @@
1
+ Citing ``SWoTTeD``
2
+ ===================
3
+
4
+ If you use ``SWoTTeD`` in a scientific publication, we would appreciate citations:
5
+
6
+ Bibtex entry::
7
+
8
+ @misc{Sebia23_SWoTTeD_ArXiV,
9
+ title = {SWoTTeD: An Extension of Tensor Decomposition to Temporal Phenotyping},
10
+ author = {Hana Sebia and Thomas Guyet and Etienne Audureau},
11
+ year = {2023},
12
+ eprint = {2310.01201},
13
+ archivePrefix = {arXiv},
14
+ url = {https://arxiv.org/abs/2310.01201}
15
+ }
16
+
17
+ Bibtex entry::
18
+
19
+ @inproceedings{Sebia23_SWoTTeD,
20
+ author = {Hana Sebia and Thomas Guyet and Etienne Audureau},
21
+ title = {Une extension de la d{\'{e}}composition tensorielle au ph{\'{e}}notypage temporel},
22
+ booktitle = {Actes de la conf{\'e}rence Extraction et Gestion des Connaissances (EGC)},
23
+ volume = {{E-39}},
24
+ pages = {43--54},
25
+ publisher = {Editions {RNTI}},
26
+ year = {2023},
27
+ url = {http://editions-rnti.fr/?inprocid=1002809}
28
+ }