├── .gitignore ├── Data └── Examplefiles │ ├── fixedsplits_HN.csv │ ├── pinfo_HN.csv │ └── semantics_HN.csv ├── LICENSE ├── README.md ├── WORCTutorialBasic.ipynb ├── WORCTutorialBasic.py ├── WORCTutorialSimple.ipynb ├── WORCTutorialSimple.py └── installation.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | # Visual studio code config 107 | .vscode 108 | 109 | # Dataset for testing 110 | Data/stwstrategyhn1 111 | WORC_Example* 112 | *.svg 113 | -------------------------------------------------------------------------------- /Data/Examplefiles/fixedsplits_HN.csv: -------------------------------------------------------------------------------- 1 | ,0_train,0_test,1_train,1_test,2_train,2_test 2 | 0,HN1004,HN1146,HN1004,HN1159,HN1077,HN1004 3 | 1,HN1077,HN1342,HN1077,HN1259,HN1088,HN1339 4 | 2,HN1088,HN1501,HN1088,HN1372,HN1146,HN1560 5 | 3,HN1159,HN1554,HN1146,HN1501,HN1159,HN1748 6 | 4,HN1192,,HN1192,,HN1192, 7 | 5,HN1259,,HN1260,,HN1259, 8 | 6,HN1260,,HN1323,,HN1260, 9 | 7,HN1323,,HN1331,,HN1323, 10 | 8,HN1331,,HN1339,,HN1331, 11 | 9,HN1339,,HN1342,,HN1342, 12 | 10,HN1372,,HN1491,,HN1372, 13 | 11,HN1491,,HN1519,,HN1491, 14 | 12,HN1519,,HN1524,,HN1501, 15 | 13,HN1524,,HN1554,,HN1519, 16 | 14,HN1560,,HN1560,,HN1524, 17 | 15,HN1748,,HN1748,,HN1554, 18 | -------------------------------------------------------------------------------- /Data/Examplefiles/pinfo_HN.csv: -------------------------------------------------------------------------------- 1 | Patient,imaginary_label_1,imaginary_label_2,Hospital,Age,complement_label_1 2 | HN1004,0,0,1,99,1 3 | HN1006,1,0,0,34,0 4 | HN1022,1,1,1,28,0 5 | HN1026,1,0,0,37,0 6 | HN1029,1,1,1,14,0 7 | HN1046,0,1,0,48,1 8 | HN1047,0,1,1,7,1 9 | HN1054,0,0,0,11,1 10 | HN1057,1,1,1,36,0 11 | HN1060,1,0,0,55,0 12 | HN1062,0,1,1,14,1 13 | HN1067,0,0,0,50,1 14 | HN1074,1,0,1,24,0 15 | HN1077,0,0,0,29,1 16 | HN1079,1,0,1,23,0 17 | HN1080,1,0,0,47,0 18 | HN1081,1,1,1,79,0 19 | HN1083,1,0,0,74,0 20 | HN1088,0,0,1,25,1 21 | HN1092,0,0,1,17,1 22 | HN1095,1,0,0,69,0 23 | HN1096,1,1,1,68,0 24 | HN1102,1,0,0,42,0 25 | HN1106,1,1,1,21,0 26 | HN1117,1,0,0,64,0 27 | HN1118,0,0,1,76,1 28 | HN1123,1,0,0,63,0 29 | HN1127,1,1,1,7,0 30 | HN1135,1,0,0,32,0 31 | HN1139,0,0,1,69,1 32 | HN1146,1,1,0,77,0 33 | HN1159,1,1,1,5,0 34 | HN1170,1,0,0,35,0 35 | HN1175,1,1,1,5,0 36 | HN1180,1,1,0,1,0 37 | HN1192,1,1,1,47,0 38 | HN1197,1,1,0,54,0 39 | HN1200,0,1,1,78,1 40 | HN1201,1,1,1,61,0 41 | HN1208,1,1,0,62,0 42 | HN1215,0,0,1,94,1 43 | HN1244,1,0,0,57,0 44 | HN1259,0,0,1,44,1 45 | HN1260,1,1,0,22,0 46 | HN1263,1,0,1,8,0 47 | HN1271,1,0,0,54,0 48 | HN1280,0,0,1,80,1 49 | HN1294,0,1,0,78,1 50 | HN1305,0,0,1,97,1 51 | HN1308,1,0,0,4,0 52 | HN1310,0,0,1,32,1 53 | HN1319,1,0,0,84,0 54 | HN1323,1,1,1,52,0 55 | HN1324,1,0,0,11,0 56 | HN1327,0,0,1,56,1 57 | HN1331,0,0,0,71,1 58 | HN1339,0,1,1,29,1 59 | HN1342,0,1,1,9,1 60 | HN1344,1,0,0,18,0 61 | HN1355,0,0,1,30,1 62 | HN1356,0,0,0,63,1 63 | HN1357,0,0,1,67,1 64 | HN1363,1,1,0,15,0 65 | HN1367,0,1,1,17,1 66 | HN1368,0,0,0,73,1 67 | HN1369,0,0,1,71,1 68 | HN1371,1,0,0,54,0 69 | HN1372,1,0,1,13,0 70 | HN1395,1,0,0,1,0 71 | HN1400,0,0,1,95,1 72 | HN1412,0,0,0,49,1 73 | HN1417,0,0,1,18,1 74 | HN1429,1,0,0,92,0 75 | HN1442,1,1,1,3,0 76 | HN1444,0,1,0,48,1 77 | HN1461,0,1,1,39,1 78 | HN1465,0,0,1,59,1 79 | HN1469,1,1,0,49,0 80 | HN1483,1,0,1,22,0 81 | HN1485,1,0,0,44,0 82 | HN1486,1,0,1,84,0 83 | HN1487,1,0,0,81,0 84 | HN1488,0,0,1,26,1 85 | HN1491,1,0,0,92,0 86 | HN1500,1,1,1,89,0 87 | HN1501,0,0,0,68,1 88 | HN1502,0,1,1,50,1 89 | HN1514,1,1,0,8,0 90 | HN1517,1,0,1,13,0 91 | HN1519,1,0,0,74,0 92 | HN1524,1,0,1,23,0 93 | HN1538,1,0,0,35,0 94 | HN1549,0,0,1,51,1 95 | HN1554,1,0,0,74,0 96 | HN1555,0,1,1,44,1 97 | HN1560,1,0,1,37,0 98 | HN1562,1,0,0,66,0 99 | HN1572,0,0,1,32,1 100 | HN1600,0,0,0,96,1 101 | HN1609,0,0,1,11,1 102 | HN1610,1,1,0,99,0 103 | HN1640,1,0,1,97,0 104 | HN1648,0,0,0,12,1 105 | HN1653,0,1,1,8,1 106 | HN1667,0,0,0,49,1 107 | HN1679,1,0,1,40,0 108 | HN1697,0,0,0,78,1 109 | HN1703,0,0,1,18,1 110 | HN1719,0,0,0,98,1 111 | HN1748,1,0,1,9,0 112 | HN1760,1,1,0,11,0 113 | HN1791,1,1,1,43,0 114 | HN1792,1,0,0,37,0 115 | HN1793,1,1,1,52,0 116 | HN1805,1,0,1,72,0 117 | HN1813,0,0,0,18,1 118 | HN1815,0,1,1,6,1 119 | HN1827,1,1,0,21,0 120 | HN1838,0,1,1,11,1 121 | HN1839,1,1,0,58,0 122 | HN1851,1,0,1,13,0 123 | HN1860,1,0,0,60,0 124 | HN1869,1,0,1,81,0 125 | HN1879,0,1,0,36,1 126 | HN1892,0,1,1,21,1 127 | HN1896,1,0,0,76,0 128 | HN1900,1,0,1,69,0 129 | HN1901,1,0,0,40,0 130 | HN1910,0,1,1,28,1 131 | HN1913,0,1,0,67,1 132 | HN1922,0,0,1,90,1 133 | HN1933,0,0,0,43,1 134 | HN1950,0,1,1,59,1 135 | HN1954,0,0,1,3,1 136 | HN1968,0,1,0,89,1 137 | HN1987,0,1,1,30,1 138 | HN1998,0,0,0,25,1 139 | -------------------------------------------------------------------------------- /Data/Examplefiles/semantics_HN.csv: -------------------------------------------------------------------------------- 1 | Patient,Age,Sex 2 | HN1004,56,1 3 | HN1006,63,0 4 | HN1022,56,1 5 | HN1026,67,1 6 | HN1029,54,0 7 | HN1046,66,1 8 | HN1047,73,1 9 | HN1054,64,1 10 | HN1057,53,0 11 | HN1060,44,1 12 | HN1062,54,1 13 | HN1067,69,1 14 | HN1074,62,0 15 | HN1077,82,1 16 | HN1079,71,1 17 | HN1080,71,1 18 | HN1081,55,1 19 | HN1083,70,1 20 | HN1088,46,0 21 | HN1092,77,0 22 | HN1095,62,1 23 | HN1096,54,1 24 | HN1102,60,1 25 | HN1106,80,1 26 | HN1117,67,1 27 | HN1118,55,1 28 | HN1123,60,1 29 | HN1127,54,1 30 | HN1135,51,1 31 | HN1139,64,0 32 | HN1146,65,0 33 | HN1159,50,0 34 | HN1170,58,1 35 | HN1175,74,1 36 | HN1180,76,1 37 | HN1192,60,1 38 | HN1197,54,1 39 | HN1200,56,1 40 | HN1201,59,1 41 | HN1208,61,1 42 | HN1215,54,1 43 | HN1244,65,1 44 | HN1259,69,0 45 | HN1260,47,1 46 | HN1263,69,1 47 | HN1271,65,1 48 | HN1280,71,1 49 | HN1294,51,1 50 | HN1305,61,1 51 | HN1308,57,0 52 | HN1310,57,1 53 | HN1319,46,1 54 | HN1323,61,1 55 | HN1324,50,0 56 | HN1327,58,1 57 | HN1331,46,1 58 | HN1339,54,1 59 | HN1342,79,1 60 | HN1344,56,1 61 | HN1355,64,1 62 | HN1356,66,1 63 | HN1357,70,1 64 | HN1363,74,1 65 | HN1367,63,1 66 | HN1368,69,0 67 | HN1369,57,1 68 | HN1371,72,1 69 | HN1372,54,1 70 | HN1395,56,1 71 | HN1400,56,1 72 | HN1412,53,0 73 | HN1417,60,1 74 | HN1429,63,1 75 | HN1442,61,1 76 | HN1444,66,1 77 | HN1461,80,1 78 | HN1465,61,1 79 | HN1469,59,1 80 | HN1483,51,0 81 | HN1485,70,0 82 | HN1486,70,1 83 | HN1487,62,1 84 | HN1488,57,1 85 | HN1491,58,1 86 | HN1500,54,0 87 | HN1501,50,1 88 | HN1502,76,1 89 | HN1514,83,1 90 | HN1517,66,1 91 | HN1519,56,0 92 | HN1524,77,1 93 | HN1538,67,0 94 | HN1549,57,0 95 | HN1554,62,1 96 | HN1555,53,1 97 | HN1560,58,1 98 | HN1562,70,1 99 | HN1572,53,0 100 | HN1600,63,1 101 | HN1609,63,0 102 | HN1610,63,1 103 | HN1640,62,0 104 | HN1648,63,1 105 | HN1653,56,1 106 | HN1667,79,1 107 | HN1679,67,1 108 | HN1697,55,1 109 | HN1703,60,1 110 | HN1719,56,0 111 | HN1748,62,0 112 | HN1760,67,1 113 | HN1791,64,1 114 | HN1792,60,1 115 | HN1793,61,1 116 | HN1805,52,1 117 | HN1813,74,1 118 | HN1815,66,1 119 | HN1827,68,1 120 | HN1838,62,1 121 | HN1839,65,1 122 | HN1851,60,1 123 | HN1860,76,1 124 | HN1869,46,1 125 | HN1879,51,1 126 | HN1892,53,0 127 | HN1896,60,1 128 | HN1900,72,1 129 | HN1901,52,1 130 | HN1910,76,1 131 | HN1913,67,1 132 | HN1922,57,1 133 | HN1933,62,0 134 | HN1950,66,1 135 | HN1954,77,0 136 | HN1968,47,1 137 | HN1987,66,1 138 | HN1998,71,1 139 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WORCTutorial 2 | This is a tutorial for the WORC Package. For more info on WORC, see 3 | [the WORC readthedocs](https://worc.readthedocs.io/en/latest/static/quick_start.html#installation). 4 | 5 | This tutorial can be followed in two ways: 6 | 1. Using [Jupyter notebook](http://jupyter.org/install): see the link for installation and usage details. 7 | The notebook can alternatively be loaded directly in [Google Colab](https://colab.research.google.com/). 8 | 2. A .py Python script with comments. 9 | 10 | Details on the usage can be found below. The code examples are the same in both 11 | ways. This repository contains a tutorial suitable for users new to WORC, 12 | which makes use of the SimpleWORC facade. Two formats are provided: 13 | 14 | * Jupyter: WORCTutorialSimple.ipynb 15 | * Script: WORCTutorialSimple.py 16 | 17 | Futher documentation can be found on [the WORC readthedocs](https://worc.readthedocs.io/). 18 | 19 | ## Installation 20 | 21 | ### Windows 22 | On Windows, please install the required python packages either through pip or conda: 23 | pip install jupyter 24 | pip install WORC 25 | 26 | Jupyter is only required when using the notebood. Optionally, you may 27 | install [Graphviz](http://www.graphviz.org/). 28 | 29 | ### Ubuntu 30 | Installation of all requirements for this tutorial can be done through the 31 | *installation.sh* shellscript provided in this repository. In order to make 32 | the script executable, on Ubuntu, please run the following: 33 | 34 | chmod -R 777 /path/to/installation.sh 35 | 36 | Alternatively, you can use the following commands: 37 | 38 | echo -e "Installing git, pip, build-essential, graphviz, ipython and jupyter notebook requirements." 39 | apt-get -y install git python-pip build-essential graphviz ipython jupyter-core 40 | 41 | pip install jupyter 42 | pip install WORC 43 | 44 | NOTE: Graphviz installation is optional. 45 | 46 | ## No Installation: Google Colab 47 | If you want to actively use WORC, we advice you to install it locally. However, 48 | for a quick test demonstration without installation, you can use [Google Colab](https://colab.research.google.com/). 49 | Just launch the relevant Jupyter notebook from this repository and uncomment the relevant lines. 50 | 51 | ## WIP 52 | - We are working on the notebooks for Intermediate and Advanced workflows. 53 | -------------------------------------------------------------------------------- /WORCTutorialBasic.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# WORC Tutorial: Basic\n", 9 | "\n", 10 | "Welcome to the tutorial of WORC: a Workflow for Optimal Radiomics\n", 11 | "Classification! This tutorial interacts with WORC through BasicWORC,\n", 12 | "which is based on SimpleWORC (SimpleWORC is the parent class of BasicWORC)\n", 13 | "but provides additional functionality. For # first time use, we recommend\n", 14 | "the WORCTutorialSimple using SimpleWORC, where we also\n", 15 | "mention tips and tricks also valid for BasicWORC." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 1, 21 | "metadata": {}, 22 | "outputs": [ 23 | { 24 | "name": "stdout", 25 | "output_type": "stream", 26 | "text": [ 27 | "[WARNING] warnings:0110 >> c:\\users\\martijn starmans\\.conda\\envs\\veworc\\lib\\site-packages\\sklearn\\utils\\deprecation.py:143: FutureWarning: The sklearn.feature_selection.base module is deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.feature_selection. Anything that cannot be imported from sklearn.feature_selection is now part of the private API.\n", 28 | " warnings.warn(message, FutureWarning)\n", 29 | "\n" 30 | ] 31 | } 32 | ], 33 | "source": [ 34 | "# import neccesary packages\n", 35 | "from WORC import BasicWORC\n", 36 | "import os\n", 37 | "\n", 38 | "# These packages are only used in analysing the results\n", 39 | "import pandas as pd\n", 40 | "import json\n", 41 | "import fastr\n", 42 | "import glob\n", 43 | "\n", 44 | "# If you don't want to use your own data, we use the following example set,\n", 45 | "# see also the next code block in this example.\n", 46 | "from WORC.exampledata.datadownloader import download_HeadAndNeck\n", 47 | "\n", 48 | "# Define the folder this script is in, so we can easily find the example data\n", 49 | "script_path = os.getcwd()\n", 50 | "\n", 51 | "# NOTE: If on Google Colab, uncomment this line\n", 52 | "# script_path = os.path.join(script_path, 'WORCTutorial')\n", 53 | "\n", 54 | "# Determine whether you would like to use WORC for binary_classification,\n", 55 | "# multiclass_classification or regression\n", 56 | "modus = 'binary_classification'" 57 | ] 58 | }, 59 | { 60 | "attachments": {}, 61 | "cell_type": "markdown", 62 | "metadata": {}, 63 | "source": [ 64 | "\n", 65 | "\n", 66 | "---------------------------------------------------------------------------\n", 67 | "Input\n", 68 | "---------------------------------------------------------------------------\n", 69 | "\n", 70 | "This part will first largely follow the same steps as the SimpleWORC tutorial." 71 | ] 72 | }, 73 | { 74 | "cell_type": "code", 75 | "execution_count": null, 76 | "metadata": {}, 77 | "outputs": [], 78 | "source": [ 79 | "# Download a subset of 20 patients in this folder. You can change these if you want.\n", 80 | "nsubjects = 20 # use \"all\" if you want to download all patients.\n", 81 | "data_path = os.path.join(script_path, 'Data')\n", 82 | "download_HeadAndNeck(datafolder=data_path, nsubjects=nsubjects)" 83 | ] 84 | }, 85 | { 86 | "cell_type": "markdown", 87 | "metadata": {}, 88 | "source": [ 89 | "Define the inputs of our network" 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "execution_count": null, 95 | "metadata": {}, 96 | "outputs": [], 97 | "source": [ 98 | "# Identify our data structure: change the fields below accordingly\n", 99 | "# if you use your own data.\n", 100 | "imagedatadir = os.path.join(data_path, 'stwstrategyhn1')\n", 101 | "image_file_name = 'image.nii.gz'\n", 102 | "segmentation_file_name = 'mask.nii.gz'\n", 103 | "\n", 104 | "# File in which the labels (i.e. outcome you want to predict) is stated\n", 105 | "# Again, change this accordingly if you use your own data.\n", 106 | "label_file = os.path.join(data_path, 'Examplefiles', 'pinfo_HN.csv')\n", 107 | "\n", 108 | "# Name of the label you want to predict\n", 109 | "if modus == 'binary_classification':\n", 110 | " # Classification: predict a binary (0 or 1) label\n", 111 | " label_name = ['imaginary_label_1']\n", 112 | "\n", 113 | "elif modus == 'regression':\n", 114 | " # Regression: predict a continuous label\n", 115 | " label_name = ['Age']\n", 116 | "\n", 117 | "elif modus == 'multiclass_classification':\n", 118 | " # Multiclass classification: predict several mutually exclusive binaru labels together\n", 119 | " label_name = ['imaginary_label_1', 'complement_label_1']\n", 120 | "\n", 121 | "# Determine whether we want to do a coarse quick experiment, or a full lengthy\n", 122 | "# one. Again, change this accordingly if you use your own data.\n", 123 | "coarse = True\n", 124 | "\n", 125 | "# Give your experiment a name\n", 126 | "experiment_name = 'Example_STWStrategyHN_BasicWORC'\n", 127 | "\n", 128 | "# Instead of the default tempdir, let's but the temporary output in a subfolder\n", 129 | "# in the same folder as this script\n", 130 | "tmpdir = os.path.join(script_path, 'WORC_' + experiment_name)\n", 131 | "print(f\"Temporary folder: {tmpdir}.\")" 132 | ] 133 | }, 134 | { 135 | "attachments": {}, 136 | "cell_type": "markdown", 137 | "metadata": {}, 138 | "source": [ 139 | "\n", 140 | "---------------------------------------------------------------------------\n", 141 | "The actual experiment\n", 142 | "---------------------------------------------------------------------------\n", 143 | "\n", 144 | "Here we will use BasicWORC. We could still use the ``..._from_this_directory`` SimpleWORC functions, but for\n", 145 | "this tutorial we will instead directly provide the data to BasicWORC ourselves.\n", 146 | "To this end, we need to create dictionaties, where the keys will be the sample\n", 147 | "names (e.g. patient ID) and the values the filenames. The keys are used\n", 148 | "to match segmentations to images, and match the files to the IDs provides in your\n", 149 | "label file, so make sure everything corresponds." 150 | ] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": null, 155 | "metadata": {}, 156 | "outputs": [], 157 | "source": [ 158 | "# Create a WORC object\n", 159 | "experiment = BasicWORC(experiment_name)\n", 160 | "\n", 161 | "# Get the image files and convert to dictionary with patient names as keys\n", 162 | "images = glob.glob(os.path.join(imagedatadir, \"*\", image_file_name))\n", 163 | "images = {f\"{os.path.basename(os.path.dirname(image))}_0\": image for image in images}\n", 164 | "\n", 165 | "# We now append this dictionary to the images_train object. The\n", 166 | "# images_from_this_directory function from SimpleWORC also appends to this object.\n", 167 | "experiment.images_train.append(images)\n", 168 | "\n", 169 | "# We do the same with the segmentations\n", 170 | "segmentations = glob.glob(os.path.join(imagedatadir, \"*\", segmentation_file_name))\n", 171 | "segmentations = {f\"{os.path.basename(os.path.dirname(segmentation))}_0\": segmentation for segmentation in segmentations} \n", 172 | "experiment.segmentations_train.append(segmentations)\n", 173 | " \n", 174 | "experiment.labels_from_this_file(label_file)\n", 175 | "experiment.predict_labels(label_name)\n", 176 | "\n", 177 | "# Set the types of images WORC has to process. Used in fingerprinting\n", 178 | "# Valid quantitative types are ['CT', 'PET', 'Thermography', 'ADC']\n", 179 | "# Valid qualitative types are ['MRI', 'DWI', 'US']\n", 180 | "experiment.set_image_types(['CT'])\n", 181 | "\n", 182 | "# Use the standard workflow for your specific modus\n", 183 | "if modus == 'binary_classification':\n", 184 | " experiment.binary_classification(coarse=coarse)\n", 185 | "elif modus == 'regression':\n", 186 | " experiment.regression(coarse=coarse)\n", 187 | "elif modus == 'multiclass_classification':\n", 188 | " experiment.multiclass_classification(coarse=coarse)\n", 189 | "\n", 190 | "# Set the temporary directory\n", 191 | "experiment.set_tmpdir(tmpdir)" 192 | ] 193 | }, 194 | { 195 | "attachments": {}, 196 | "cell_type": "markdown", 197 | "metadata": {}, 198 | "source": [ 199 | "There are various other objects you can interact with, see https://worc.readthedocs.io/en/latest/static/user_manual.html#attributes-sources\n", 200 | "for an overview and the function of each attribute.\n", 201 | " \n", 202 | "Note: You can keep appending dictionaries to these objects here if you want to\n", 203 | "use multiple images per patient, e.g. a T1 MRI and a T2 MRI. You should\n", 204 | "provide matching segmentations for each of the images, as WORC extracts the features\n", 205 | "per image-segmentation set. Except when you want to\n", 206 | "use special workflows, e.g. use image registration, see the WORC readthedocs.\n" 207 | ] 208 | }, 209 | { 210 | "cell_type": "code", 211 | "execution_count": null, 212 | "metadata": {}, 213 | "outputs": [], 214 | "source": [ 215 | "# The rest remains the same as in SimpleWORC\n", 216 | "experiment.labels_from_this_file(label_file)\n", 217 | "experiment.predict_labels(label_name)\n", 218 | "\n", 219 | "# Set the types of images WORC has to process. Used in fingerprinting\n", 220 | "# Valid quantitative types are ['CT', 'PET', 'Thermography', 'ADC']\n", 221 | "# Valid qualitative types are ['MRI', 'DWI', 'US']\n", 222 | "experiment.set_image_types(['CT'])\n", 223 | "\n", 224 | "# Use the standard workflow for your specific modus\n", 225 | "if modus == 'binary_classification':\n", 226 | " experiment.binary_classification(coarse=coarse)\n", 227 | "elif modus == 'regression':\n", 228 | " experiment.regression(coarse=coarse)\n", 229 | "elif modus == 'multiclass_classification':\n", 230 | " experiment.multiclass_classification(coarse=coarse)\n", 231 | "\n", 232 | "# Set the temporary directory\n", 233 | "experiment.set_tmpdir(tmpdir)" 234 | ] 235 | }, 236 | { 237 | "cell_type": "code", 238 | "execution_count": null, 239 | "metadata": {}, 240 | "outputs": [], 241 | "source": [ 242 | "# Run the experiment!\n", 243 | "experiment.execute()" 244 | ] 245 | }, 246 | { 247 | "cell_type": "markdown", 248 | "metadata": {}, 249 | "source": [ 250 | "---------------------------------------------------------------------------\n", 251 | "Analysis of results\n", 252 | "---------------------------------------------------------------------------\n", 253 | "\n", 254 | "There are two main outputs: the features for each patient/object, and the overall\n", 255 | "performance. These are stored as .hdf5 and .json files, respectively. By\n", 256 | "default, they are saved in the so-called \"fastr output mount\", in a subfolder\n", 257 | "named after your experiment name." 258 | ] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": null, 263 | "metadata": {}, 264 | "outputs": [], 265 | "source": [ 266 | "# Locate output folder\n", 267 | "outputfolder = fastr.config.mounts['output']\n", 268 | "experiment_folder = os.path.join(outputfolder, 'WORC_' + experiment_name)\n", 269 | "\n", 270 | "print(f\"Your output is stored in {experiment_folder}.\")\n", 271 | "\n", 272 | "# Read the features for the first patient\n", 273 | "# NOTE: we use the glob package for scanning a folder to find specific files\n", 274 | "feature_files = glob.glob(os.path.join(experiment_folder,\n", 275 | " 'Features',\n", 276 | " 'features_*.hdf5'))\n", 277 | "if len(feature_files) == 0:\n", 278 | " raise ValueError('No feature files found: your network has failed.')\n", 279 | "\n", 280 | "feature_files.sort()\n", 281 | "featurefile_p1 = feature_files[0]\n", 282 | "features_p1 = pd.read_hdf(featurefile_p1)\n", 283 | "\n", 284 | "# Read the overall peformance\n", 285 | "performance_file = os.path.join(experiment_folder, 'performance_all_0.json')\n", 286 | "if not os.path.exists(performance_file):\n", 287 | " raise ValueError(f'No performance file {performance_file} found: your network has failed.')\n", 288 | " \n", 289 | "with open(performance_file, 'r') as fp:\n", 290 | " performance = json.load(fp)\n", 291 | "\n", 292 | "# Print the feature values and names\n", 293 | "print(\"Feature values from first patient:\")\n", 294 | "for v, l in zip(features_p1.feature_values, features_p1.feature_labels):\n", 295 | " print(f\"\\t {l} : {v}.\")\n", 296 | "\n", 297 | "# Print the output performance\n", 298 | "print(\"\\n Performance:\")\n", 299 | "stats = performance['Statistics']\n", 300 | "for k, v in stats.items():\n", 301 | " print(f\"\\t {k} {v}.\")" 302 | ] 303 | }, 304 | { 305 | "cell_type": "markdown", 306 | "metadata": {}, 307 | "source": [ 308 | "**NOTE:** the performance is probably horrible, which is expected as we ran\n", 309 | "the experiment on coarse settings. These settings are recommended to only\n", 310 | "use for testing: see also below.\n" 311 | ] 312 | } 313 | ], 314 | "metadata": { 315 | "kernelspec": { 316 | "display_name": "Python 3.7.6 ('VEWORC')", 317 | "language": "python", 318 | "name": "python3" 319 | }, 320 | "language_info": { 321 | "codemirror_mode": { 322 | "name": "ipython", 323 | "version": 3 324 | }, 325 | "file_extension": ".py", 326 | "mimetype": "text/x-python", 327 | "name": "python", 328 | "nbconvert_exporter": "python", 329 | "pygments_lexer": "ipython3", 330 | "version": "3.7.6" 331 | }, 332 | "vscode": { 333 | "interpreter": { 334 | "hash": "9ed99ebfaecbb93fba24de0c912838568cec8e40873d89cab18962835b65ad13" 335 | } 336 | } 337 | }, 338 | "nbformat": 4, 339 | "nbformat_minor": 2 340 | } 341 | -------------------------------------------------------------------------------- /WORCTutorialBasic.py: -------------------------------------------------------------------------------- 1 | # Welcome to the tutorial of WORC: a Workflow for Optimal Radiomics 2 | # Classification! # This tutorial interacts with WORC through BasicWORC, 3 | # which is based on SimpleWORC (SimpleWORC is the parent class of BasicWORC) 4 | # but provides additional functionality. For # first time use, we recommend 5 | # the WORCTutorialSimple using SimpleWORC, where we also 6 | # mention tips and tricks also valid for BasicWORC. 7 | 8 | # import neccesary packages 9 | from WORC import BasicWORC 10 | import os 11 | 12 | # These packages are only used in analysing the results 13 | import pandas as pd 14 | import json 15 | import fastr 16 | import glob 17 | 18 | # If you don't want to use your own data, we use the following example set, 19 | # see also the next code block in this example. 20 | from WORC.exampledata.datadownloader import download_HeadAndNeck 21 | 22 | # Define the folder this script is in, so we can easily find the example data 23 | script_path = os.path.dirname(os.path.abspath(__file__)) 24 | 25 | # Determine whether you would like to use WORC for binary_classification, 26 | # multiclass_classification or regression 27 | modus = 'binary_classification' 28 | 29 | 30 | def main(): 31 | """Execute WORC Tutorial experiment.""" 32 | print(f"Running in folder: {script_path}.") 33 | # --------------------------------------------------------------------------- 34 | # Input: Same as the SimpleWORC tutorial 35 | # --------------------------------------------------------------------------- 36 | 37 | # ------------------------------------------------------------------------------- 38 | # This part will first largely follow the same steps as the SimpleWORC tutorial. 39 | # ------------------------------------------------------------------------------- 40 | 41 | # Download a subset of 20 patients in this folder. You can change these if you want. 42 | nsubjects = 20 # use "all" to download all patients 43 | data_path = os.path.join(script_path, 'Data') 44 | download_HeadAndNeck(datafolder=data_path, nsubjects=nsubjects) 45 | 46 | # Identify our data structure: change the fields below accordingly 47 | # if you use your own data. 48 | imagedatadir = os.path.join(data_path, 'stwstrategyhn1') 49 | image_file_name = 'image.nii.gz' 50 | segmentation_file_name = 'mask.nii.gz' 51 | 52 | # File in which the labels (i.e. outcome you want to predict) is stated 53 | # Again, change this accordingly if you use your own data. 54 | label_file = os.path.join(data_path, 'Examplefiles', 'pinfo_HN.csv') 55 | 56 | # Name of the label you want to predict 57 | if modus == 'binary_classification': 58 | # Classification: predict a binary (0 or 1) label 59 | label_name = ['imaginary_label_1'] 60 | 61 | elif modus == 'regression': 62 | # Regression: predict a continuous label 63 | label_name = ['Age'] 64 | 65 | elif modus == 'multiclass_classification': 66 | # Multiclass classification: predict several mutually exclusive binaru labels together 67 | label_name = ['imaginary_label_1', 'complement_label_1'] 68 | 69 | # Determine whether we want to do a coarse quick experiment, or a full lengthy 70 | # one. Again, change this accordingly if you use your own data. 71 | coarse = True 72 | 73 | # Give your experiment a name 74 | experiment_name = 'Example_STWStrategyHN_BasicWORC' 75 | 76 | # Instead of the default tempdir, let's but the temporary output in a subfolder 77 | # in the same folder as this script 78 | tmpdir = os.path.join(script_path, 'WORC_' + experiment_name) 79 | print(f"Temporary folder: {tmpdir}.") 80 | 81 | # --------------------------------------------------------------------------- 82 | # The actual experiment: here we will use BasicWORC 83 | # --------------------------------------------------------------------------- 84 | 85 | # Create a BasicWORC object 86 | experiment = BasicWORC(experiment_name) 87 | 88 | # We could still use the ..._from_this_directory SimpleWORC functions, but for 89 | # this tutorial we will instead directly provide the data to BasicWORC ourselves. 90 | # To this end, we need to create dictionaties, where the keys will be the sample 91 | # names (e.g. patient ID) and the values the filenames. The keys are used 92 | # to match segmentations to images, and match the files to the IDs provides in your 93 | # label file, so make sure everything corresponds. 94 | 95 | # Get the image files and convert to dictionary with patient names as keys 96 | images = glob.glob(os.path.join(imagedatadir, "*", image_file_name)) 97 | images = {f"{os.path.basename(os.path.dirname(image))}_0": image for image in images} 98 | 99 | # We now append this dictionary to the images_train object. The 100 | # images_from_this_directory function from SimpleWORC also appends to this object. 101 | experiment.images_train.append(images) 102 | 103 | # We do the same with the segmentations 104 | segmentations = glob.glob(os.path.join(imagedatadir, "*", segmentation_file_name)) 105 | segmentations = {f"{os.path.basename(os.path.dirname(segmentation))}_0": segmentation for segmentation in segmentations} 106 | experiment.segmentations_train.append(segmentations) 107 | 108 | # There are various other objects you can interact with, see https://worc.readthedocs.io/en/latest/static/user_manual.html#attributes-sources 109 | # for an overview and the function of each attribute. 110 | 111 | # Note: You can keep appending dictionaries to these objects here if you want to 112 | # use multiple images per patient, e.g. a T1 MRI and a T2 MRI. You should 113 | # provide matching segmentations for each of the images, as WORC extracts the features 114 | # per image-segmentation set. Except when you want to 115 | # use special workflows, e.g. use image registration, see the WORC readthedocs. 116 | 117 | # The rest remains the same as in SimpleWORC 118 | experiment.labels_from_this_file(label_file) 119 | experiment.predict_labels(label_name) 120 | 121 | # Set the types of images WORC has to process. Used in fingerprinting 122 | # Valid quantitative types are ['CT', 'PET', 'Thermography', 'ADC'] 123 | # Valid qualitative types are ['MRI', 'DWI', 'US'] 124 | experiment.set_image_types(['CT']) 125 | 126 | # Use the standard workflow for your specific modus 127 | if modus == 'binary_classification': 128 | experiment.binary_classification(coarse=coarse) 129 | elif modus == 'regression': 130 | experiment.regression(coarse=coarse) 131 | elif modus == 'multiclass_classification': 132 | experiment.multiclass_classification(coarse=coarse) 133 | 134 | # Set the temporary directory 135 | experiment.set_tmpdir(tmpdir) 136 | 137 | # Run the experiment! 138 | experiment.execute() 139 | 140 | # --------------------------------------------------------------------------- 141 | # Analysis of results 142 | # --------------------------------------------------------------------------- 143 | 144 | # There are two main outputs: the features for each patient/object, and the overall 145 | # performance. These are stored as .hdf5 and .json files, respectively. By 146 | # default, they are saved in the so-called "fastr output mount", in a subfolder 147 | # named after your experiment name. 148 | 149 | # Locate output folder 150 | outputfolder = fastr.config.mounts['output'] 151 | experiment_folder = os.path.join(outputfolder, 'WORC_' + experiment_name) 152 | 153 | print(f"Your output is stored in {experiment_folder}.") 154 | 155 | # Read the features for the first patient 156 | # NOTE: we use the glob package for scanning a folder to find specific files 157 | feature_files = glob.glob(os.path.join(experiment_folder, 158 | 'Features', 159 | 'features_*.hdf5')) 160 | 161 | if len(feature_files) == 0: 162 | raise ValueError('No feature files found: your network has failed.') 163 | 164 | feature_files.sort() 165 | featurefile_p1 = feature_files[0] 166 | features_p1 = pd.read_hdf(featurefile_p1) 167 | 168 | # Read the overall peformance 169 | performance_file = os.path.join(experiment_folder, 'performance_all_0.json') 170 | if not os.path.exists(performance_file): 171 | raise ValueError(f'No performance file {performance_file} found: your network has failed.') 172 | 173 | with open(performance_file, 'r') as fp: 174 | performance = json.load(fp) 175 | 176 | # Print the feature values and names 177 | print("Feature values from first patient:") 178 | for v, l in zip(features_p1.feature_values, features_p1.feature_labels): 179 | print(f"\t {l} : {v}.") 180 | 181 | # Print the output performance 182 | print("\n Performance:") 183 | stats = performance['Statistics'] 184 | for k, v in stats.items(): 185 | print(f"\t {k} {v}.") 186 | 187 | # NOTE: the performance is probably horrible, which is expected as we ran 188 | # the experiment on coarse settings. These settings are recommended to only 189 | # use for testing: see also below. 190 | 191 | 192 | if __name__ == '__main__': 193 | main() 194 | -------------------------------------------------------------------------------- /WORCTutorialSimple.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# WORC Tutorial: Simple\n", 8 | "\n", 9 | "Welcome to the tutorial of WORC: a Workflow for Optimal Radiomics Classification! It will provide you with basis knowledge and practical skills on how to run the WORC. For advanced topics and WORCflows, please see the other notebooks provided with this tutorial. For installation details, see the ReadMe.md provided with this tutorial.\n", 10 | "\n", 11 | "\n", 12 | "This tutorial interacts with WORC through SimpleWORC and is especially suitable for first time usage. We first do some neccesary imports." 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 1, 18 | "metadata": {}, 19 | "outputs": [ 20 | { 21 | "name": "stdout", 22 | "output_type": "stream", 23 | "text": [ 24 | "[WARNING] warnings:0110 >> c:\\users\\martijn starmans\\.conda\\envs\\veworc\\lib\\site-packages\\sklearn\\utils\\deprecation.py:143: FutureWarning: The sklearn.feature_selection.base module is deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.feature_selection. Anything that cannot be imported from sklearn.feature_selection is now part of the private API.\n", 25 | " warnings.warn(message, FutureWarning)\n", 26 | "\n" 27 | ] 28 | } 29 | ], 30 | "source": [ 31 | "# import neccesary packages\n", 32 | "from WORC import SimpleWORC\n", 33 | "import os\n", 34 | "\n", 35 | "# These packages are only used in analysing the results\n", 36 | "import pandas as pd\n", 37 | "import json\n", 38 | "import fastr\n", 39 | "import glob\n", 40 | "\n", 41 | "# If you don't want to use your own data, we use the following example set,\n", 42 | "# see also the next code block in this example.\n", 43 | "from WORC.exampledata.datadownloader import download_HeadAndNeck\n", 44 | "\n", 45 | "# Define the folder this script is in, so we can easily find the example data\n", 46 | "script_path = os.getcwd()\n", 47 | "\n", 48 | "# NOTE: If on Google Colab, uncomment this line\n", 49 | "# script_path = os.path.join(script_path, 'WORCTutorial')\n", 50 | "\n", 51 | "# Determine whether you would like to use WORC for binary_classification,\n", 52 | "# multiclass_classification or regression\n", 53 | "modus = 'binary_classification'" 54 | ] 55 | }, 56 | { 57 | "cell_type": "markdown", 58 | "metadata": {}, 59 | "source": [ 60 | "\n", 61 | "\n", 62 | "---------------------------------------------------------------------------\n", 63 | "Input\n", 64 | "---------------------------------------------------------------------------\n", 65 | "The minimal inputs to WORC are:\n", 66 | " - Images\n", 67 | " - Segmentations\n", 68 | " - Labels\n", 69 | "\n", 70 | "In SimpleWORC, we assume you have a folder \"datadir\", in which there is a\n", 71 | "folder for each patient, where in each folder there is a image.nii.gz and a mask.nii.gz:\n", 72 | " * Datadir\n", 73 | " * Patient_001\n", 74 | " * image.nii.gz\n", 75 | " * mask.nii.gz\n", 76 | " * Patient_002\n", 77 | " * image.nii.gz\n", 78 | " * mask.nii.gz\n", 79 | " * ...\n", 80 | "\n", 81 | "\n", 82 | "You can skip this part if you use your own data.\n", 83 | "In the example, We will use open source data from the online XNAT platform\n", 84 | "at https://xnat.bmia.nl/data/archive/projects/stwstrategyhn1. This dataset\n", 85 | "consists of CT scans of patients with Head and Neck tumors. " 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": null, 91 | "metadata": {}, 92 | "outputs": [], 93 | "source": [ 94 | "# Download a subset of 20 patients in this folder. You can change these if you want.\n", 95 | "nsubjects = 20 # use \"all\" if you want to download all patients.\n", 96 | "data_path = os.path.join(script_path, 'Data')\n", 97 | "download_HeadAndNeck(datafolder=data_path, nsubjects=nsubjects)" 98 | ] 99 | }, 100 | { 101 | "cell_type": "markdown", 102 | "metadata": {}, 103 | "source": [ 104 | "Define the inputs of our network" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": null, 110 | "metadata": {}, 111 | "outputs": [], 112 | "source": [ 113 | "# Identify our data structure: change the fields below accordingly\n", 114 | "# if you use your own data.\n", 115 | "imagedatadir = os.path.join(data_path, 'stwstrategyhn1')\n", 116 | "image_file_name = 'image.nii.gz'\n", 117 | "segmentation_file_name = 'mask.nii.gz'\n", 118 | "\n", 119 | "# File in which the labels (i.e. outcome you want to predict) is stated\n", 120 | "# Again, change this accordingly if you use your own data.\n", 121 | "label_file = os.path.join(data_path, 'Examplefiles', 'pinfo_HN.csv')\n", 122 | "\n", 123 | "# Name of the label you want to predict\n", 124 | "if modus == 'binary_classification':\n", 125 | " # Classification: predict a binary (0 or 1) label\n", 126 | " label_name = ['imaginary_label_1']\n", 127 | "\n", 128 | "elif modus == 'regression':\n", 129 | " # Regression: predict a continuous label\n", 130 | " label_name = ['Age']\n", 131 | "\n", 132 | "elif modus == 'multiclass_classification':\n", 133 | " # Multiclass classification: predict several mutually exclusive binaru labels together\n", 134 | " label_name = ['imaginary_label_1', 'complement_label_1']\n", 135 | "\n", 136 | "# Determine whether we want to do a coarse quick experiment, or a full lengthy\n", 137 | "# one. Again, change this accordingly if you use your own data.\n", 138 | "coarse = True\n", 139 | "\n", 140 | "# Give your experiment a name\n", 141 | "experiment_name = 'Example_STWStrategyHN'\n", 142 | "\n", 143 | "# Instead of the default tempdir, let's but the temporary output in a subfolder\n", 144 | "# in the same folder as this script\n", 145 | "tmpdir = os.path.join(script_path, 'WORC_' + experiment_name)\n", 146 | "print(f\"Temporary folder: {tmpdir}.\")" 147 | ] 148 | }, 149 | { 150 | "cell_type": "markdown", 151 | "metadata": {}, 152 | "source": [ 153 | "\n", 154 | "---------------------------------------------------------------------------\n", 155 | "The actual experiment\n", 156 | "---------------------------------------------------------------------------\n", 157 | "\n", 158 | "NOTE: Precomputed features can be used instead of images and masks\n", 159 | "by instead using ``I.features_from_this_directory()`` in a similar fashion to below. " 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "execution_count": null, 165 | "metadata": {}, 166 | "outputs": [], 167 | "source": [ 168 | "# Create a WORC object\n", 169 | "experiment = SimpleWORC(experiment_name)\n", 170 | "\n", 171 | "# Set the input data according to the variables we defined earlier\n", 172 | "experiment.images_from_this_directory(imagedatadir,\n", 173 | " image_file_name=image_file_name,\n", 174 | " is_training=True)\n", 175 | "experiment.segmentations_from_this_directory(imagedatadir,\n", 176 | " segmentation_file_name=segmentation_file_name,\n", 177 | " is_training=True)\n", 178 | "experiment.labels_from_this_file(label_file)\n", 179 | "experiment.predict_labels(label_name)\n", 180 | "\n", 181 | "# Set the types of images WORC has to process. Used in fingerprinting\n", 182 | "# Valid quantitative types are ['CT', 'PET', 'Thermography', 'ADC']\n", 183 | "# Valid qualitative types are ['MRI', 'DWI', 'US']\n", 184 | "experiment.set_image_types(['CT'])\n", 185 | "\n", 186 | "# Use the standard workflow for your specific modus\n", 187 | "if modus == 'binary_classification':\n", 188 | " experiment.binary_classification(coarse=coarse)\n", 189 | "elif modus == 'regression':\n", 190 | " experiment.regression(coarse=coarse)\n", 191 | "elif modus == 'multiclass_classification':\n", 192 | " experiment.multiclass_classification(coarse=coarse)\n", 193 | "\n", 194 | "# Set the temporary directory\n", 195 | "experiment.set_tmpdir(tmpdir)" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": null, 201 | "metadata": {}, 202 | "outputs": [], 203 | "source": [ 204 | "# Run the experiment!\n", 205 | "experiment.execute()" 206 | ] 207 | }, 208 | { 209 | "cell_type": "markdown", 210 | "metadata": {}, 211 | "source": [ 212 | "**NOTE:** Precomputed features can be used instead of images and masks by instead using ``experiment.features_from_this_directory(featuresdatadir)`` in a similar fashion." 213 | ] 214 | }, 215 | { 216 | "cell_type": "markdown", 217 | "metadata": {}, 218 | "source": [ 219 | "---------------------------------------------------------------------------\n", 220 | "Analysis of results\n", 221 | "---------------------------------------------------------------------------\n", 222 | "\n", 223 | "There are two main outputs: the features for each patient/object, and the overall\n", 224 | "performance. These are stored as .hdf5 and .json files, respectively. By\n", 225 | "default, they are saved in the so-called \"fastr output mount\", in a subfolder\n", 226 | "named after your experiment name." 227 | ] 228 | }, 229 | { 230 | "cell_type": "code", 231 | "execution_count": null, 232 | "metadata": {}, 233 | "outputs": [], 234 | "source": [ 235 | "# Locate output folder\n", 236 | "outputfolder = fastr.config.mounts['output']\n", 237 | "experiment_folder = os.path.join(outputfolder, 'WORC_' + experiment_name)\n", 238 | "\n", 239 | "print(f\"Your output is stored in {experiment_folder}.\")\n", 240 | "\n", 241 | "# Read the features for the first patient\n", 242 | "# NOTE: we use the glob package for scanning a folder to find specific files\n", 243 | "feature_files = glob.glob(os.path.join(experiment_folder,\n", 244 | " 'Features',\n", 245 | " 'features_*.hdf5'))\n", 246 | "if len(feature_files) == 0:\n", 247 | " raise ValueError('No feature files found: your network has failed.')\n", 248 | "\n", 249 | "feature_files.sort()\n", 250 | "featurefile_p1 = feature_files[0]\n", 251 | "features_p1 = pd.read_hdf(featurefile_p1)\n", 252 | "\n", 253 | "# Read the overall peformance\n", 254 | "performance_file = os.path.join(experiment_folder, 'performance_all_0.json')\n", 255 | "if not os.path.exists(performance_file):\n", 256 | " raise ValueError(f'No performance file {performance_file} found: your network has failed.')\n", 257 | " \n", 258 | "with open(performance_file, 'r') as fp:\n", 259 | " performance = json.load(fp)\n", 260 | "\n", 261 | "# Print the feature values and names\n", 262 | "print(\"Feature values from first patient:\")\n", 263 | "for v, l in zip(features_p1.feature_values, features_p1.feature_labels):\n", 264 | " print(f\"\\t {l} : {v}.\")\n", 265 | "\n", 266 | "# Print the output performance\n", 267 | "print(\"\\n Performance:\")\n", 268 | "stats = performance['Statistics']\n", 269 | "for k, v in stats.items():\n", 270 | " print(f\"\\t {k} {v}.\")" 271 | ] 272 | }, 273 | { 274 | "cell_type": "markdown", 275 | "metadata": {}, 276 | "source": [ 277 | "**NOTE:** the performance is probably horrible, which is expected as we ran\n", 278 | "the experiment on coarse settings. These settings are recommended to only\n", 279 | "use for testing: see also below.\n" 280 | ] 281 | }, 282 | { 283 | "attachments": {}, 284 | "cell_type": "markdown", 285 | "metadata": {}, 286 | "source": [ 287 | "---------------------------------------------------------------------------\n", 288 | "Tips and Tricks\n", 289 | "---------------------------------------------------------------------------\n", 290 | "\n", 291 | "For tips and tricks on running a full experiment instead of this simple\n", 292 | "example, adding more evaluation options, debuggin a crashed network etcetera,\n", 293 | "please go to https://worc.readthedocs.io/en/latest/static/user_manual.html or\n", 294 | "https://worc.readthedocs.io/en/latest/static/additionalfunctionality.html. If you\n", 295 | "run into any issues, check the FAQ at https://worc.readthedocs.io/en/latest/static/faq.html,\n", 296 | "make an issue on the WORC Github, or feel free to mail me.\n", 297 | "\n", 298 | "We advice you to look at the docstrings of the SimpleWORC functions\n", 299 | "introduced in this tutorial, and explore the other SimpleWORC functions,\n", 300 | "as SimpleWORC offers much more functionality than presented here, see\n", 301 | "the documentation: https://worc.readthedocs.io/en/latest/autogen/WORC.facade.html#WORC.facade.simpleworc.SimpleWORC\n", 302 | "\n", 303 | "\n", 304 | "Some things we would advice to always do:\n", 305 | " - Run actual experiments on the full settings (coarse=False):\n", 306 | " \n", 307 | " ``coarse = False``\n", 308 | " \n", 309 | " ``experiment.binary_classification(coarse=coarse)``\n", 310 | " \n", 311 | " **Note**: this will result in more computation time. We therefore recommmend\n", 312 | " to run this script on either a cluster or high performance PC. If so,\n", 313 | " you may change the execution to use multiple cores to speed up computation\n", 314 | " just before before experiment.execute():\n", 315 | " \n", 316 | " ``experiment.set_multicore_execution()``\n", 317 | "\n", 318 | " - Add extensive evaluation: experiment.add_evaluation() before experiment.execute():\n", 319 | " \n", 320 | " ``experiment.add_evaluation()``\n", 321 | " \n", 322 | " See the documentation for more details on the evaluation outputs: https://worc.readthedocs.io/en/development/static/user_manual.html#outputs-and-evaluation-of-your-network.\n", 323 | "\n", 324 | "Changing fields in the configuration (https://worc.readthedocs.io/en/latest/static/configuration.html)\n", 325 | "can be done with the add_config_overrides function, see below. We recommend doing this after the modus part, as these also perform config_overrides. NOTE: all configuration fields have to be provided as strings." 326 | ] 327 | }, 328 | { 329 | "cell_type": "code", 330 | "execution_count": null, 331 | "metadata": {}, 332 | "outputs": [], 333 | "source": [ 334 | "overrides = {\n", 335 | " 'Classification': {\n", 336 | " 'classifiers': 'SVM',\n", 337 | " },\n", 338 | " }\n", 339 | "\n", 340 | "experiment.add_config_overrides(overrides)\n" 341 | ] 342 | } 343 | ], 344 | "metadata": { 345 | "kernelspec": { 346 | "display_name": "Python 3.7.6 ('VEWORC')", 347 | "language": "python", 348 | "name": "python3" 349 | }, 350 | "language_info": { 351 | "codemirror_mode": { 352 | "name": "ipython", 353 | "version": 3 354 | }, 355 | "file_extension": ".py", 356 | "mimetype": "text/x-python", 357 | "name": "python", 358 | "nbconvert_exporter": "python", 359 | "pygments_lexer": "ipython3", 360 | "version": "3.7.6" 361 | }, 362 | "vscode": { 363 | "interpreter": { 364 | "hash": "9ed99ebfaecbb93fba24de0c912838568cec8e40873d89cab18962835b65ad13" 365 | } 366 | } 367 | }, 368 | "nbformat": 4, 369 | "nbformat_minor": 2 370 | } 371 | -------------------------------------------------------------------------------- /WORCTutorialSimple.py: -------------------------------------------------------------------------------- 1 | # Welcome to the tutorial of WORC: a Workflow for Optimal Radiomics 2 | # Classification! It will provide you with basis knowledge and practical 3 | # skills on how to run the WORC. For advanced topics and WORCflows, please see 4 | # the other notebooks provided with this tutorial. For installation details, 5 | # see the ReadMe.md provided with this tutorial. 6 | 7 | # This tutorial interacts with WORC through SimpleWORC and is especially 8 | # suitable for first time usage. 9 | 10 | # import neccesary packages 11 | from WORC import SimpleWORC 12 | import os 13 | 14 | # These packages are only used in analysing the results 15 | import pandas as pd 16 | import json 17 | import fastr 18 | import glob 19 | 20 | # If you don't want to use your own data, we use the following example set, 21 | # see also the next code block in this example. 22 | from WORC.exampledata.datadownloader import download_HeadAndNeck 23 | 24 | # Define the folder this script is in, so we can easily find the example data 25 | script_path = os.path.dirname(os.path.abspath(__file__)) 26 | 27 | # Determine whether you would like to use WORC for binary_classification, 28 | # multiclass_classification or regression 29 | modus = 'binary_classification' 30 | 31 | 32 | def main(): 33 | """Execute WORC Tutorial experiment.""" 34 | print(f"Running in folder: {script_path}.") 35 | # --------------------------------------------------------------------------- 36 | # Input 37 | # --------------------------------------------------------------------------- 38 | # The minimal inputs to WORC are: 39 | # - Images 40 | # - Segmentations 41 | # - Labels 42 | # 43 | # In SimpleWORC, we assume you have a folder "datadir", in which there is a 44 | # folder for each patient, where in each folder there is a image.nii.gz and a mask.nii.gz: 45 | # Datadir 46 | # Patient_001 47 | # image.nii.gz 48 | # mask.nii.gz 49 | # Patient_002 50 | # image.nii.gz 51 | # mask.nii.gz 52 | # ... 53 | # 54 | # 55 | # You can skip this part if you use your own data. 56 | # In the example, We will use open source data from the online XNAT platform 57 | # at https://xnat.bmia.nl/data/archive/projects/stwstrategyhn1. This dataset 58 | # consists of CT scans of patients with Head and Neck tumors. We will download 59 | # a subset of 20 patients in this folder. You can change this settings if you 60 | # like 61 | 62 | nsubjects = 20 # use "all" to download all patients 63 | data_path = os.path.join(script_path, 'Data') 64 | download_HeadAndNeck(datafolder=data_path, nsubjects=nsubjects) 65 | 66 | # Identify our data structure: change the fields below accordingly 67 | # if you use your own data. 68 | imagedatadir = os.path.join(data_path, 'stwstrategyhn1') 69 | image_file_name = 'image.nii.gz' 70 | segmentation_file_name = 'mask.nii.gz' 71 | 72 | # File in which the labels (i.e. outcome you want to predict) is stated 73 | # Again, change this accordingly if you use your own data. 74 | label_file = os.path.join(data_path, 'Examplefiles', 'pinfo_HN.csv') 75 | 76 | # Name of the label you want to predict 77 | if modus == 'binary_classification': 78 | # Classification: predict a binary (0 or 1) label 79 | label_name = ['imaginary_label_1'] 80 | 81 | elif modus == 'regression': 82 | # Regression: predict a continuous label 83 | label_name = ['Age'] 84 | 85 | elif modus == 'multiclass_classification': 86 | # Multiclass classification: predict several mutually exclusive binaru labels together 87 | label_name = ['imaginary_label_1', 'complement_label_1'] 88 | 89 | # Determine whether we want to do a coarse quick experiment, or a full lengthy 90 | # one. Again, change this accordingly if you use your own data. 91 | coarse = True 92 | 93 | # Give your experiment a name 94 | experiment_name = 'Example_STWStrategyHN' 95 | 96 | # Instead of the default tempdir, let's but the temporary output in a subfolder 97 | # in the same folder as this script 98 | tmpdir = os.path.join(script_path, 'WORC_' + experiment_name) 99 | print(f"Temporary folder: {tmpdir}.") 100 | 101 | # --------------------------------------------------------------------------- 102 | # The actual experiment 103 | # --------------------------------------------------------------------------- 104 | 105 | # Create a Simple WORC object 106 | experiment = SimpleWORC(experiment_name) 107 | 108 | # Set the input data according to the variables we defined earlier 109 | experiment.images_from_this_directory(imagedatadir, 110 | image_file_name=image_file_name, 111 | is_training=True) 112 | experiment.segmentations_from_this_directory(imagedatadir, 113 | segmentation_file_name=segmentation_file_name, 114 | is_training=True) 115 | experiment.labels_from_this_file(label_file) 116 | experiment.predict_labels(label_name) 117 | 118 | # Set the types of images WORC has to process. Used in fingerprinting 119 | # Valid quantitative types are ['CT', 'PET', 'Thermography', 'ADC'] 120 | # Valid qualitative types are ['MRI', 'DWI', 'US'] 121 | experiment.set_image_types(['CT']) 122 | 123 | # Use the standard workflow for your specific modus 124 | if modus == 'binary_classification': 125 | experiment.binary_classification(coarse=coarse) 126 | elif modus == 'regression': 127 | experiment.regression(coarse=coarse) 128 | elif modus == 'multiclass_classification': 129 | experiment.multiclass_classification(coarse=coarse) 130 | 131 | # Set the temporary directory 132 | experiment.set_tmpdir(tmpdir) 133 | 134 | # Run the experiment! 135 | experiment.execute() 136 | 137 | # NOTE: Precomputed features can be used instead of images and masks 138 | # by instead using ``experiment.features_from_this_directory(featuresdatadir)`` in a similar fashion. 139 | 140 | # --------------------------------------------------------------------------- 141 | # Analysis of results 142 | # --------------------------------------------------------------------------- 143 | 144 | # There are two main outputs: the features for each patient/object, and the overall 145 | # performance. These are stored as .hdf5 and .json files, respectively. By 146 | # default, they are saved in the so-called "fastr output mount", in a subfolder 147 | # named after your experiment name. 148 | 149 | # Locate output folder 150 | outputfolder = fastr.config.mounts['output'] 151 | experiment_folder = os.path.join(outputfolder, 'WORC_' + experiment_name) 152 | 153 | print(f"Your output is stored in {experiment_folder}.") 154 | 155 | # Read the features for the first patient 156 | # NOTE: we use the glob package for scanning a folder to find specific files 157 | feature_files = glob.glob(os.path.join(experiment_folder, 158 | 'Features', 159 | 'features_*.hdf5')) 160 | 161 | if len(feature_files) == 0: 162 | raise ValueError('No feature files found: your network has failed.') 163 | 164 | feature_files.sort() 165 | featurefile_p1 = feature_files[0] 166 | features_p1 = pd.read_hdf(featurefile_p1) 167 | 168 | # Read the overall peformance 169 | performance_file = os.path.join(experiment_folder, 'performance_all_0.json') 170 | if not os.path.exists(performance_file): 171 | raise ValueError(f'No performance file {performance_file} found: your network has failed.') 172 | 173 | with open(performance_file, 'r') as fp: 174 | performance = json.load(fp) 175 | 176 | # Print the feature values and names 177 | print("Feature values from first patient:") 178 | for v, l in zip(features_p1.feature_values, features_p1.feature_labels): 179 | print(f"\t {l} : {v}.") 180 | 181 | # Print the output performance 182 | print("\n Performance:") 183 | stats = performance['Statistics'] 184 | for k, v in stats.items(): 185 | print(f"\t {k} {v}.") 186 | 187 | # NOTE: the performance is probably horrible, which is expected as we ran 188 | # the experiment on coarse settings. These settings are recommended to only 189 | # use for testing: see also below. 190 | 191 | # --------------------------------------------------------------------------- 192 | # Tips and Tricks 193 | # --------------------------------------------------------------------------- 194 | 195 | # For tips and tricks on running a full experiment instead of this simple 196 | # example, adding more evaluation options, debugging a crashed network etcetera, 197 | # please go to https://worc.readthedocs.io/en/latest/static/user_manual.html or 198 | # https://worc.readthedocs.io/en/latest/static/additionalfunctionality.html. If you 199 | # run into any issues, check the FAQ at https://worc.readthedocs.io/en/latest/static/faq.html, 200 | # make an issue on the WORC Github, or feel free to mail me. 201 | # 202 | # We advice you to look at the docstrings of the SimpleWORC functions 203 | # introduced in this tutorial, and explore the other SimpleWORC functions, 204 | # as SimpleWORC offers much more functionality than presented here, see 205 | # the documentation: https://worc.readthedocs.io/en/latest/autogen/WORC.facade.html#WORC.facade.simpleworc.SimpleWORC 206 | 207 | # Some things we would advice to always do: 208 | # - Run actual experiments on the full settings (coarse=False): 209 | 210 | # coarse = False 211 | # experiment.binary_classification(coarse=coarse) 212 | 213 | # Note: this will result in more computation time. We therefore recommmend 214 | # to run this script on either a cluster or high performance PC. If so, 215 | # you may change the execution to use multiple cores to speed up computation 216 | # just before before experiment.execute(): 217 | # experiment.set_multicore_execution() 218 | # 219 | # - Add extensive evaluation: experiment.add_evaluation() before experiment.execute(): 220 | # experiment.add_evaluation() 221 | # 222 | # See the documentation for more details on the evaluation outputs: https://worc.readthedocs.io/en/development/static/user_manual.html#outputs-and-evaluation-of-your-network. 223 | # 224 | # Changing fields in the configuration (https://worc.readthedocs.io/en/latest/static/configuration.html) 225 | # can be done with the add_config_overrides function: 226 | # 227 | # overrides = { 228 | # 'Classification': { 229 | # 'classifiers': 'SVM', 230 | # }, 231 | # } 232 | # experiment.add_config_overrides(overrides) 233 | # 234 | # We recommend doing this after the modus part, as these also perform config_overrides. 235 | # NOTE: all configuration fields have to be provided as strings. 236 | 237 | 238 | if __name__ == '__main__': 239 | main() 240 | -------------------------------------------------------------------------------- /installation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # ----------------------------------------------------------------------- 4 | # WORC Installation 5 | # ----------------------------------------------------------------------- 6 | 7 | # Install requirements: git, cmake, build-essential 8 | echo -e "Installing git, pip, build-essential, graphviz, ipython and jupyter notebook requirements." 9 | apt-get -y install git python-pip build-essential graphviz ipython jupyter-core 10 | 11 | # Install jupyter when using the notebook 12 | pip install jupyter 13 | 14 | # Install WORC 15 | pip install WORC 16 | 17 | # Alternative: Clone WORC repository from Github and install 18 | # mkdir ~/Documents/Packages 19 | # git clone http://Github.com/MStarmans91/WORC ~/Documents/Packages/WORC 20 | # cd ~/Documents/Packages/WORC 21 | # git checkout development 22 | # pip install -r requirements.txt 23 | # python setup.py install 24 | 25 | # Alternative: Install the PREDICT requirements and package manually 26 | # echo -e "Installing PREDICT requirements and package itself." 27 | # cd ~/Documents/Packages 28 | # git clone http://Github.com/Svdvoort/PREDICTFastr PREDICT 29 | # cd PREDICT 30 | # git checkout develop 31 | # pip install -r requirements.txt 32 | # python setup.py install 33 | --------------------------------------------------------------------------------