kmodel 0.0.1__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.
kmodel-0.0.1/LICENSE ADDED
@@ -0,0 +1,201 @@
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.
@@ -0,0 +1,5 @@
1
+ include pyproject.toml
2
+ include LICENSE
3
+ include CONTRIBUTING.md
4
+ include README.md
5
+ recursive-exclude * __pycache__
kmodel-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.4
2
+ Name: kmodel
3
+ Version: 0.0.1
4
+ Summary: A fresh nbdev project for kmodel.
5
+ Author-email: keke <lcai888666@gmail.com>
6
+ License: Apache-2.0
7
+ Project-URL: Repository, https://github.com/sky1ove/kmodel
8
+ Project-URL: Documentation, https://sky1ove.github.io/kmodel/
9
+ Keywords: nbdev
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: fastai>=2.8.7
16
+ Requires-Dist: joblib>=1.5.3
17
+ Requires-Dist: numpy>=2.2.6
18
+ Requires-Dist: pandas>=2.3.3
19
+ Requires-Dist: scikit-learn>=1.7.2
20
+ Requires-Dist: torch>=2.11.0
21
+ Dynamic: license-file
22
+
23
+ # kmodel
24
+
25
+
26
+ <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
27
+
28
+ This file will become your README and also the index of your
29
+ documentation.
30
+
31
+ ## Developer Guide
32
+
33
+ If you are new to using `nbdev` here are some useful pointers to get you
34
+ started.
35
+
36
+ ### Install kmodel in Development mode
37
+
38
+ ``` sh
39
+ # make sure kmodel package is installed in development mode
40
+ $ pip install -e .
41
+
42
+ # make changes under nbs/ directory
43
+ # ...
44
+
45
+ # compile to have changes apply to kmodel
46
+ $ nbdev_prepare
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ ### Installation
52
+
53
+ Install latest from the GitHub
54
+ [repository](https://github.com/sky1ove/kmodel):
55
+
56
+ ``` sh
57
+ $ pip install git+https://github.com/sky1ove/kmodel.git
58
+ ```
59
+
60
+ or from [conda](https://anaconda.org/sky1ove/kmodel)
61
+
62
+ ``` sh
63
+ $ conda install -c sky1ove kmodel
64
+ ```
65
+
66
+ or from [pypi](https://pypi.org/project/kmodel/)
67
+
68
+ ``` sh
69
+ $ pip install kmodel
70
+ ```
71
+
72
+ ### Documentation
73
+
74
+ Documentation can be found hosted on this GitHub
75
+ [repository](https://github.com/sky1ove/kmodel)’s
76
+ [pages](https://sky1ove.github.io/kmodel/). Additionally you can find
77
+ package manager specific guidelines on
78
+ [conda](https://anaconda.org/sky1ove/kmodel) and
79
+ [pypi](https://pypi.org/project/kmodel/) respectively.
80
+
81
+ ## How to use
82
+
83
+ Fill me in please! Don’t forget code examples:
84
+
85
+ ``` python
86
+ 1+1
87
+ ```
88
+
89
+ 2
kmodel-0.0.1/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # kmodel
2
+
3
+
4
+ <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
5
+
6
+ This file will become your README and also the index of your
7
+ documentation.
8
+
9
+ ## Developer Guide
10
+
11
+ If you are new to using `nbdev` here are some useful pointers to get you
12
+ started.
13
+
14
+ ### Install kmodel in Development mode
15
+
16
+ ``` sh
17
+ # make sure kmodel package is installed in development mode
18
+ $ pip install -e .
19
+
20
+ # make changes under nbs/ directory
21
+ # ...
22
+
23
+ # compile to have changes apply to kmodel
24
+ $ nbdev_prepare
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Installation
30
+
31
+ Install latest from the GitHub
32
+ [repository](https://github.com/sky1ove/kmodel):
33
+
34
+ ``` sh
35
+ $ pip install git+https://github.com/sky1ove/kmodel.git
36
+ ```
37
+
38
+ or from [conda](https://anaconda.org/sky1ove/kmodel)
39
+
40
+ ``` sh
41
+ $ conda install -c sky1ove kmodel
42
+ ```
43
+
44
+ or from [pypi](https://pypi.org/project/kmodel/)
45
+
46
+ ``` sh
47
+ $ pip install kmodel
48
+ ```
49
+
50
+ ### Documentation
51
+
52
+ Documentation can be found hosted on this GitHub
53
+ [repository](https://github.com/sky1ove/kmodel)’s
54
+ [pages](https://sky1ove.github.io/kmodel/). Additionally you can find
55
+ package manager specific guidelines on
56
+ [conda](https://anaconda.org/sky1ove/kmodel) and
57
+ [pypi](https://pypi.org/project/kmodel/) respectively.
58
+
59
+ ## How to use
60
+
61
+ Fill me in please! Don’t forget code examples:
62
+
63
+ ``` python
64
+ 1+1
65
+ ```
66
+
67
+ 2
@@ -0,0 +1 @@
1
+ __version__ = "0.0.1"
@@ -0,0 +1,41 @@
1
+ # Autogenerated by nbdev
2
+
3
+ d = { 'settings': { 'branch': 'main',
4
+ 'doc_baseurl': '/kmodel',
5
+ 'doc_host': 'https://sky1ove.github.io',
6
+ 'git_url': 'https://github.com/sky1ove/kmodel',
7
+ 'lib_path': 'kmodel'},
8
+ 'syms': { 'kmodel.core': {'kmodel.core.foo': ('core.html#foo', 'kmodel/core.py')},
9
+ 'kmodel.dnn': { 'kmodel.dnn.CE': ('dnn.html#ce', 'kmodel/dnn.py'),
10
+ 'kmodel.dnn.CNN1D': ('dnn.html#cnn1d', 'kmodel/dnn.py'),
11
+ 'kmodel.dnn.CNN1D.__init__': ('dnn.html#cnn1d.__init__', 'kmodel/dnn.py'),
12
+ 'kmodel.dnn.CNN1D.forward': ('dnn.html#cnn1d.forward', 'kmodel/dnn.py'),
13
+ 'kmodel.dnn.GeneralDataset': ('dnn.html#generaldataset', 'kmodel/dnn.py'),
14
+ 'kmodel.dnn.GeneralDataset.__getitem__': ('dnn.html#generaldataset.__getitem__', 'kmodel/dnn.py'),
15
+ 'kmodel.dnn.GeneralDataset.__init__': ('dnn.html#generaldataset.__init__', 'kmodel/dnn.py'),
16
+ 'kmodel.dnn.GeneralDataset.__len__': ('dnn.html#generaldataset.__len__', 'kmodel/dnn.py'),
17
+ 'kmodel.dnn.JSD': ('dnn.html#jsd', 'kmodel/dnn.py'),
18
+ 'kmodel.dnn.KLD': ('dnn.html#kld', 'kmodel/dnn.py'),
19
+ 'kmodel.dnn.MLP': ('dnn.html#mlp', 'kmodel/dnn.py'),
20
+ 'kmodel.dnn.PSSM_model': ('dnn.html#pssm_model', 'kmodel/dnn.py'),
21
+ 'kmodel.dnn.PSSM_model.__init__': ('dnn.html#pssm_model.__init__', 'kmodel/dnn.py'),
22
+ 'kmodel.dnn.PSSM_model.forward': ('dnn.html#pssm_model.forward', 'kmodel/dnn.py'),
23
+ 'kmodel.dnn.conv_wn': ('dnn.html#conv_wn', 'kmodel/dnn.py'),
24
+ 'kmodel.dnn.init_weights': ('dnn.html#init_weights', 'kmodel/dnn.py'),
25
+ 'kmodel.dnn.lin_wn': ('dnn.html#lin_wn', 'kmodel/dnn.py'),
26
+ 'kmodel.dnn.predict_dl': ('dnn.html#predict_dl', 'kmodel/dnn.py'),
27
+ 'kmodel.dnn.seed_everything': ('dnn.html#seed_everything', 'kmodel/dnn.py'),
28
+ 'kmodel.dnn.train_dl': ('dnn.html#train_dl', 'kmodel/dnn.py'),
29
+ 'kmodel.dnn.train_dl_cv': ('dnn.html#train_dl_cv', 'kmodel/dnn.py')},
30
+ 'kmodel.train': { 'kmodel.train._normalize_vector': ('ml.html#_normalize_vector', 'kmodel/train.py'),
31
+ 'kmodel.train.calculate_ce': ('ml.html#calculate_ce', 'kmodel/train.py'),
32
+ 'kmodel.train.get_score': ('ml.html#get_score', 'kmodel/train.py'),
33
+ 'kmodel.train.get_splits': ('ml.html#get_splits', 'kmodel/train.py'),
34
+ 'kmodel.train.js_divergence_flat': ('ml.html#js_divergence_flat', 'kmodel/train.py'),
35
+ 'kmodel.train.kl_divergence_flat': ('ml.html#kl_divergence_flat', 'kmodel/train.py'),
36
+ 'kmodel.train.post_process': ('ml.html#post_process', 'kmodel/train.py'),
37
+ 'kmodel.train.post_process_oof': ('ml.html#post_process_oof', 'kmodel/train.py'),
38
+ 'kmodel.train.predict_ml': ('ml.html#predict_ml', 'kmodel/train.py'),
39
+ 'kmodel.train.split_data': ('ml.html#split_data', 'kmodel/train.py'),
40
+ 'kmodel.train.train_ml': ('ml.html#train_ml', 'kmodel/train.py'),
41
+ 'kmodel.train.train_ml_cv': ('ml.html#train_ml_cv', 'kmodel/train.py')}}}
@@ -0,0 +1,9 @@
1
+ """Fill in a module description here"""
2
+
3
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
4
+
5
+ # %% auto #0
6
+ __all__ = ['foo']
7
+
8
+ # %% ../nbs/00_core.ipynb #97ca5313
9
+ def foo(): pass
@@ -0,0 +1,291 @@
1
+ """Deep learning helpers built on the existing fastai training backbone, with runnable examples from a seaborn dataset."""
2
+
3
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/02_DNN.ipynb.
4
+
5
+ # %% auto #0
6
+ __all__ = ['def_device', 'seed_everything', 'GeneralDataset', 'MLP', 'lin_wn', 'conv_wn', 'CNN1D', 'init_weights', 'PSSM_model',
7
+ 'CE', 'KLD', 'JSD', 'train_dl', 'predict_dl', 'train_dl_cv']
8
+
9
+ # %% ../nbs/02_DNN.ipynb #19eb18c4
10
+ import os
11
+ import random
12
+
13
+ import fastcore.all as fc
14
+ import matplotlib.pyplot as plt
15
+ import numpy as np
16
+ import pandas as pd
17
+ import torch
18
+ import torch.nn as nn
19
+ import torch.nn.functional as F
20
+ from fastai.vision.all import *
21
+ from torch.utils.data import DataLoader, Dataset
22
+
23
+ # %% ../nbs/02_DNN.ipynb #43dceac1
24
+ def seed_everything(seed: int = 123) -> None:
25
+ "Seed Python, NumPy, and PyTorch for reproducible experiments."
26
+ random.seed(seed)
27
+ os.environ['PYTHONHASHSEED'] = str(seed)
28
+ np.random.seed(seed)
29
+ torch.manual_seed(seed)
30
+ if torch.cuda.is_available():
31
+ torch.cuda.manual_seed_all(seed)
32
+ torch.backends.cudnn.deterministic = True
33
+ torch.backends.cudnn.benchmark = False
34
+
35
+ # %% ../nbs/02_DNN.ipynb #cc4d6625
36
+ def_device = 'mps' if torch.backends.mps.is_available() else 'cuda' if torch.cuda.is_available() else 'cpu'
37
+
38
+ # %% ../nbs/02_DNN.ipynb #e5a649d5
39
+ class GeneralDataset(Dataset):
40
+ def __init__(
41
+ self,
42
+ df: pd.DataFrame,
43
+ feat_col,
44
+ target_col=None,
45
+ A: int = 23,
46
+ dtype=np.float32,
47
+ ) -> None:
48
+ "Return features only in test mode, or (features, targets) in training mode."
49
+ self.test = target_col is None
50
+ self.aa = A
51
+ self.X = df[list(feat_col)].to_numpy(dtype=dtype, copy=True)
52
+ self.y = None
53
+ if not self.test:
54
+ y_flat = df[list(target_col)].to_numpy(dtype=dtype, copy=True)
55
+ total = y_flat.shape[1]
56
+ if total % A != 0:
57
+ raise ValueError(f"Target columns ({total}) not divisible by A={A}; cannot infer positions.")
58
+ self.position = total // self.aa
59
+ self.y = y_flat.reshape(-1, A, self.position)
60
+ self.len = len(df)
61
+
62
+ def __len__(self):
63
+ return self.len
64
+
65
+ def __getitem__(self, index):
66
+ X = torch.from_numpy(self.X[index])
67
+ if self.test:
68
+ return X
69
+ y = torch.from_numpy(self.y[index])
70
+ return X, y
71
+
72
+ # %% ../nbs/02_DNN.ipynb #d358392f
73
+ def MLP(
74
+ num_features: int,
75
+ num_targets: int,
76
+ hidden_units: list[int] = [512, 218],
77
+ dp: float = 0.2,
78
+ ):
79
+ "Feed-forward model for tabular inputs."
80
+ layers = [
81
+ nn.Linear(num_features, hidden_units[0]),
82
+ nn.BatchNorm1d(hidden_units[0]),
83
+ nn.Dropout(dp),
84
+ nn.PReLU(),
85
+ ]
86
+ for i in range(len(hidden_units) - 1):
87
+ layers.extend([
88
+ nn.Linear(hidden_units[i], hidden_units[i + 1]),
89
+ nn.BatchNorm1d(hidden_units[i + 1]),
90
+ nn.Dropout(dp),
91
+ nn.PReLU(),
92
+ ])
93
+ layers.append(nn.Linear(hidden_units[-1], num_targets))
94
+ return nn.Sequential(*layers)
95
+
96
+ # %% ../nbs/02_DNN.ipynb #59c86969
97
+ def lin_wn(ni, nf, dp: float = 0.1, act=nn.SiLU):
98
+ "Weight-normalized linear block."
99
+ layers = [
100
+ nn.BatchNorm1d(ni),
101
+ nn.Dropout(dp),
102
+ nn.utils.parametrizations.weight_norm(nn.Linear(ni, nf)),
103
+ ]
104
+ if act:
105
+ layers.append(act())
106
+ return nn.Sequential(*layers)
107
+
108
+ # %% ../nbs/02_DNN.ipynb #25d0985c
109
+ def conv_wn(ni, nf, ks: int = 3, stride: int = 1, padding: int = 1, dp: float = 0.1, act=nn.ReLU):
110
+ "Weight-normalized convolution block."
111
+ layers = [
112
+ nn.BatchNorm1d(ni),
113
+ nn.Dropout(dp),
114
+ nn.utils.parametrizations.weight_norm(nn.Conv1d(ni, nf, ks, stride, padding)),
115
+ ]
116
+ if act:
117
+ layers.append(act())
118
+ return nn.Sequential(*layers)
119
+
120
+ # %% ../nbs/02_DNN.ipynb #b6691f78
121
+ class CNN1D(nn.Module):
122
+ def __init__(self, ni, nf, amp_scale: int = 16):
123
+ super().__init__()
124
+ cha_1, cha_2, cha_3 = 256, 512, 512
125
+ hidden_size = cha_1 * amp_scale
126
+ cha_po_1 = hidden_size // (cha_1 * 2)
127
+ cha_po_2 = (hidden_size // (cha_1 * 4)) * cha_3
128
+
129
+ self.lin = lin_wn(ni, hidden_size)
130
+ self.view = View(-1, cha_1, amp_scale)
131
+ self.conv1 = nn.Sequential(
132
+ conv_wn(cha_1, cha_2, ks=5, stride=1, padding=2, dp=0.1),
133
+ nn.AdaptiveAvgPool1d(output_size=cha_po_1),
134
+ conv_wn(cha_2, cha_2, ks=3, stride=1, padding=1, dp=0.1),
135
+ )
136
+ self.conv2 = nn.Sequential(
137
+ conv_wn(cha_2, cha_2, ks=3, stride=1, padding=1, dp=0.3),
138
+ conv_wn(cha_2, cha_3, ks=5, stride=1, padding=2, dp=0.2),
139
+ )
140
+ self.head = nn.Sequential(
141
+ nn.MaxPool1d(kernel_size=4, stride=2, padding=1),
142
+ nn.Flatten(),
143
+ lin_wn(cha_po_2, nf, act=None),
144
+ )
145
+
146
+ def forward(self, x):
147
+ x = self.lin(x)
148
+ x = self.view(x)
149
+ x = self.conv1(x)
150
+ x_s = x
151
+ x = self.conv2(x)
152
+ x = x * x_s
153
+ return self.head(x)
154
+
155
+ # %% ../nbs/02_DNN.ipynb #32493367
156
+ def init_weights(m, leaky: float = 0.0):
157
+ "Initialize convolution layers with Kaiming normal weights."
158
+ if isinstance(m, (nn.Conv1d, nn.Conv2d, nn.Conv3d)):
159
+ nn.init.kaiming_normal_(m.weight, a=leaky)
160
+
161
+ # %% ../nbs/02_DNN.ipynb #bad5feef
162
+ class PSSM_model(nn.Module):
163
+ def __init__(self, n_features, n_targets, A: int = 23, model: str = 'MLP'):
164
+ super().__init__()
165
+ self.n_features = n_features
166
+ self.n_targets = n_targets
167
+ self.n_aa = A
168
+ if self.n_targets % self.n_aa != 0:
169
+ raise ValueError(f"n_targets ({n_targets}) must be divisible by n_aa ({self.n_aa}).")
170
+ self.n_positions = self.n_targets // self.n_aa
171
+
172
+ if model == 'MLP':
173
+ self.model = MLP(self.n_features, self.n_targets)
174
+ elif model == 'CNN':
175
+ self.model = CNN1D(self.n_features, self.n_targets).apply(init_weights)
176
+ else:
177
+ raise ValueError('model must be MLP or CNN.')
178
+
179
+ def forward(self, x):
180
+ logits = self.model(x).reshape(-1, self.n_aa, self.n_positions)
181
+ return logits
182
+
183
+ # %% ../nbs/02_DNN.ipynb #f87f424e
184
+ def CE(logits: torch.Tensor, target_probs: torch.Tensor):
185
+ "Cross-entropy with soft labels."
186
+ logp = F.log_softmax(logits, dim=1)
187
+ ce = -(target_probs * logp).sum(dim=1)
188
+ return ce.mean()
189
+
190
+ # %% ../nbs/02_DNN.ipynb #ccb32c56
191
+ def KLD(logits: torch.Tensor, target_probs: torch.Tensor):
192
+ "Average KL divergence across positions between target_probs and softmax(logits)."
193
+ logq = F.log_softmax(logits, dim=1)
194
+ logp = torch.log(target_probs + 1e-8)
195
+ kl = (target_probs * (logp - logq)).sum(dim=1)
196
+ return kl.mean()
197
+
198
+ # %% ../nbs/02_DNN.ipynb #fe899c20
199
+ def JSD(logits: torch.Tensor, target_probs: torch.Tensor):
200
+ "Average Jensen-Shannon divergence across positions between target_probs and softmax(logits)."
201
+ q = F.softmax(logits, dim=1)
202
+ p = target_probs
203
+ m = 0.5 * (p + q)
204
+ logp = torch.log(p + 1e-8)
205
+ logq = torch.log(q + 1e-8)
206
+ logm = torch.log(m + 1e-8)
207
+ kld_pm = (p * (logp - logm)).sum(dim=1)
208
+ kld_qm = (q * (logq - logm)).sum(dim=1)
209
+ return (0.5 * (kld_pm + kld_qm)).mean()
210
+
211
+ # %% ../nbs/02_DNN.ipynb #d0f14083
212
+ def train_dl(
213
+ df: pd.DataFrame,
214
+ feat_col,
215
+ target_col,
216
+ split,
217
+ model_func,
218
+ A: int = 23,
219
+ n_epoch: int = 4,
220
+ bs: int = 32,
221
+ lr: float = 1e-2,
222
+ loss=CE,
223
+ save=None,
224
+ sampler=None,
225
+ lr_find: bool = False,
226
+ ):
227
+ "Train a deep learning model with the fastai learner stack."
228
+ train = df.iloc[split[0]]
229
+ valid = df.iloc[split[1]]
230
+
231
+ train_ds = GeneralDataset(train, feat_col, target_col, A=A)
232
+ valid_ds = GeneralDataset(valid, feat_col, target_col, A=A)
233
+ dls = DataLoaders.from_dsets(train_ds, valid_ds, bs=bs, num_workers=min(fc.defaults.cpus, 4))
234
+
235
+ model = model_func()
236
+ learn = Learner(dls.to(def_device), model.to(def_device), loss_func=loss, metrics=[KLD, JSD])
237
+
238
+ if lr_find:
239
+ lr_suggestion = learn.lr_find()
240
+ plt.show()
241
+ plt.close()
242
+ lr = lr_suggestion.valley if hasattr(lr_suggestion, 'valley') else float(lr_suggestion)
243
+ print('lr_find selected', lr)
244
+
245
+ print('lr in training is', lr)
246
+ learn.fit_one_cycle(n_epoch, lr)
247
+
248
+ if save is not None:
249
+ learn.save(save)
250
+
251
+ pred, target = learn.get_preds()
252
+ pred = F.softmax(pred, dim=1).reshape(len(valid), -1)
253
+ target = target.reshape(len(valid), -1)
254
+
255
+ pred = pd.DataFrame(pred.detach().cpu().numpy(), index=valid.index, columns=target_col)
256
+ target = pd.DataFrame(target.detach().cpu().numpy(), index=valid.index, columns=target_col)
257
+ return target, pred
258
+
259
+ # %% ../nbs/02_DNN.ipynb #a789a82c
260
+ def predict_dl(df, feat_col, target_col, model_func, model_pth, A: int = 23, bs: int = 512):
261
+ "Predict a dataframe given a deep learning model saved by fastai."
262
+ test_dset = GeneralDataset(df, feat_col, A=A)
263
+ test_dl = DataLoader(test_dset, batch_size=bs)
264
+
265
+ model = model_func()
266
+ infer_dls = DataLoaders.from_dsets(test_dset, test_dset, bs=bs, num_workers=min(fc.defaults.cpus, 4))
267
+ learn = Learner(infer_dls.to(def_device), model.to(def_device), loss_func=CE)
268
+ learn.load(model_pth, weights_only=False)
269
+ learn.model.eval()
270
+
271
+ preds = []
272
+ for data in test_dl:
273
+ inputs = data.to(def_device)
274
+ pred = learn.model(inputs)
275
+ pred = F.softmax(pred, dim=1).reshape(len(pred), -1)
276
+ preds.append(pred.detach().cpu().numpy())
277
+
278
+ preds = np.concatenate(preds)
279
+ return pd.DataFrame(preds, index=df.index, columns=target_col)
280
+
281
+ # %% ../nbs/02_DNN.ipynb #b266abbf
282
+ def train_dl_cv(df, feat_col, target_col, splits, model_func, A: int = 23, save: str | None = None, **kwargs):
283
+ "Cross-validation training loop for deep learning models."
284
+ oof_frames = []
285
+ for fold, split in enumerate(splits):
286
+ print(f'------fold{fold}------')
287
+ fname = f'{save}_fold{fold}' if save is not None else None
288
+ _, pred = train_dl(df, feat_col, target_col, split, model_func, A=A, save=fname, **kwargs)
289
+ pred['nfold'] = fold
290
+ oof_frames.append(pred)
291
+ return pd.concat(oof_frames).sort_index()
@@ -0,0 +1,205 @@
1
+ """Generic helpers for tabular multi-output training and scoring, with runnable examples built from a seaborn dataset."""
2
+
3
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_ML.ipynb.
4
+
5
+ # %% auto #0
6
+ __all__ = ['get_score_jsd', 'get_score_kld', 'get_score_ce', 'get_splits', 'split_data', 'train_ml', 'train_ml_cv',
7
+ 'post_process', 'post_process_oof', 'get_score', 'js_divergence_flat', 'kl_divergence_flat', 'calculate_ce',
8
+ 'predict_ml']
9
+
10
+ # %% ../nbs/01_ML.ipynb #c4049499
11
+ from collections.abc import Callable, Sequence
12
+ from functools import partial
13
+ from pathlib import Path
14
+
15
+ import numpy as np
16
+ import pandas as pd
17
+ from joblib import dump, load
18
+ from sklearn import set_config
19
+ from sklearn.linear_model import LinearRegression
20
+ from sklearn.model_selection import GroupKFold, StratifiedGroupKFold, StratifiedKFold
21
+
22
+ set_config(transform_output="pandas")
23
+
24
+ # %% ../nbs/01_ML.ipynb #a38f6af8
25
+ def get_splits(
26
+ df: pd.DataFrame,
27
+ stratified: str | None = None, # col used for stratified sampling
28
+ group: str | None = None, # col used to keep grouped rows together
29
+ nfold: int = 5,
30
+ seed: int = 123,
31
+ ) -> list[tuple[np.ndarray, np.ndarray]]:
32
+ "Split samples in a dataframe with stratified, grouped, or stratified-grouped K-fold logic."
33
+
34
+ def _log(colname: str) -> None:
35
+ print(kf)
36
+ split = splits[0]
37
+ print(f"# {colname} in train set: {df.iloc[split[0]][colname].nunique()}")
38
+ print(f"# {colname} in test set: {df.iloc[split[1]][colname].nunique()}")
39
+
40
+ splits: list[tuple[np.ndarray, np.ndarray]] = []
41
+ if stratified is not None and group is None:
42
+ kf = StratifiedKFold(nfold, shuffle=True, random_state=seed)
43
+ for split in kf.split(df.index, df[stratified]):
44
+ splits.append(split)
45
+ _log(stratified)
46
+ elif group is not None and stratified is None:
47
+ kf = GroupKFold(nfold)
48
+ for split in kf.split(df.index, groups=df[group]):
49
+ splits.append(split)
50
+ _log(group)
51
+ elif stratified is not None and group is not None:
52
+ kf = StratifiedGroupKFold(nfold, shuffle=True, random_state=seed)
53
+ for split in kf.split(df.index, groups=df[group], y=df[stratified]):
54
+ splits.append(split)
55
+ _log(stratified)
56
+ else:
57
+ raise ValueError("Either 'stratified' or 'group' argument must be provided.")
58
+ return splits
59
+
60
+ # %% ../nbs/01_ML.ipynb #efeeef7f
61
+ def split_data(
62
+ df: pd.DataFrame, # dataframe of values
63
+ feat_col: Sequence[str], # feature columns
64
+ target_col: Sequence[str], # target columns
65
+ split: tuple[np.ndarray, np.ndarray],
66
+ ) -> tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame]:
67
+ "Given a split tuple, return X_train, y_train, X_test, and y_test."
68
+ X_train = df.iloc[split[0]][list(feat_col)]
69
+ y_train = df.iloc[split[0]][list(target_col)]
70
+ X_test = df.iloc[split[1]][list(feat_col)]
71
+ y_test = df.iloc[split[1]][list(target_col)]
72
+ return X_train, y_train, X_test, y_test
73
+
74
+ # %% ../nbs/01_ML.ipynb #9711d171
75
+ def train_ml(
76
+ df: pd.DataFrame, # dataframe of values
77
+ feat_col: Sequence[str], # feature columns
78
+ target_col: Sequence[str], # target columns
79
+ split: tuple[np.ndarray, np.ndarray],
80
+ model, # sklearn model instance
81
+ save: str | Path | None = None, # output path for joblib model
82
+ params: dict | None = None, # kwargs forwarded to model.fit
83
+ ) -> tuple[pd.DataFrame, pd.DataFrame]:
84
+ "Fit and predict with a sklearn model, returning validation targets and predictions."
85
+ X_train, y_train, X_test, y_test = split_data(df, feat_col, target_col, split)
86
+ model.fit(X_train, y_train, **(params or {}))
87
+ if save is not None:
88
+ dump(model, save)
89
+ y_pred = model.predict(X_test)
90
+ pred = pd.DataFrame(y_pred, index=y_test.index, columns=y_test.columns)
91
+ return y_test, pred
92
+
93
+ # %% ../nbs/01_ML.ipynb #e2d3abaf
94
+ def train_ml_cv(
95
+ df: pd.DataFrame, # dataframe of values
96
+ feat_col: Sequence[str], # feature columns
97
+ target_col: Sequence[str], # target columns
98
+ splits: Sequence[tuple[np.ndarray, np.ndarray]],
99
+ model, # sklearn model instance
100
+ save: str | None = None, # model name prefix for saved folds
101
+ params: dict | None = None, # kwargs forwarded to model.fit
102
+ ) -> pd.DataFrame:
103
+ "Run cross-validation through the given splits."
104
+ oof_frames: list[pd.DataFrame] = []
105
+ for fold, split in enumerate(splits):
106
+ save_path = f"models/{save}_{fold}.joblib" if save is not None else None
107
+ _, pred = train_ml(df, feat_col, target_col, split, model, save=save_path, params=params)
108
+ pred["nfold"] = fold
109
+ oof_frames.append(pred)
110
+ return pd.concat(oof_frames).sort_index()
111
+
112
+ # %% ../nbs/01_ML.ipynb #f52b3804
113
+ def _normalize_vector(values: pd.Series | np.ndarray, epsilon: float = 1e-8) -> np.ndarray:
114
+ "Normalize a probability-like vector after clipping small or negative values."
115
+ array = np.asarray(values, dtype=float)
116
+ array = np.clip(array, epsilon, None)
117
+ return array / array.sum()
118
+
119
+ # %% ../nbs/01_ML.ipynb #63757b94
120
+ def post_process(pred_like: pd.DataFrame | pd.Series, epsilon: float = 1e-8):
121
+ "Clip negatives and renormalize probability-like predictions."
122
+ if isinstance(pred_like, pd.Series):
123
+ values = _normalize_vector(pred_like, epsilon=epsilon)
124
+ return pd.Series(values, index=pred_like.index)
125
+
126
+ pred = pred_like.copy()
127
+ normalized = np.vstack([
128
+ _normalize_vector(row.to_numpy(dtype=float), epsilon=epsilon) for _, row in pred.iterrows()
129
+ ])
130
+ pred.loc[:, :] = normalized
131
+ return pred
132
+
133
+ # %% ../nbs/01_ML.ipynb #f631adc4
134
+ def post_process_oof(oof_ml: pd.DataFrame, target_col: Sequence[str]) -> pd.DataFrame:
135
+ "Post-process prediction columns in an out-of-fold dataframe."
136
+ oof = oof_ml.copy()
137
+ oof[list(target_col)] = post_process(oof[list(target_col)])
138
+ return oof
139
+
140
+ # %% ../nbs/01_ML.ipynb #64338f24
141
+ def get_score(
142
+ target: pd.DataFrame,
143
+ pred: pd.DataFrame,
144
+ func: Callable[[pd.Series | np.ndarray, pd.Series | np.ndarray], float],
145
+ ) -> pd.Series:
146
+ "Apply a row-wise score function to aligned target and prediction frames."
147
+ distance = [func(target.loc[i], pred.loc[i, target.columns]) for i in target.index]
148
+ return pd.Series(distance, index=target.index)
149
+
150
+ # %% ../nbs/01_ML.ipynb #14487edb
151
+ def js_divergence_flat(
152
+ target_series: pd.Series | np.ndarray,
153
+ pred_series: pd.Series | np.ndarray,
154
+ epsilon: float = 1e-8,
155
+ ) -> float:
156
+ "Compute Jensen-Shannon divergence between two flattened probability vectors."
157
+ p = _normalize_vector(target_series, epsilon=epsilon)
158
+ q = _normalize_vector(pred_series, epsilon=epsilon)
159
+ m = 0.5 * (p + q)
160
+ return float(0.5 * np.sum(p * np.log(p / m)) + 0.5 * np.sum(q * np.log(q / m)))
161
+
162
+ # %% ../nbs/01_ML.ipynb #06480577
163
+ get_score_jsd = partial(get_score, func=js_divergence_flat)
164
+
165
+ # %% ../nbs/01_ML.ipynb #9ec84ddd
166
+ def kl_divergence_flat(
167
+ target_series: pd.Series | np.ndarray,
168
+ pred_series: pd.Series | np.ndarray,
169
+ epsilon: float = 1e-8,
170
+ ) -> float:
171
+ "Compute KL divergence between two flattened probability vectors."
172
+ p = _normalize_vector(target_series, epsilon=epsilon)
173
+ q = _normalize_vector(pred_series, epsilon=epsilon)
174
+ return float(np.sum(p * np.log(p / q)))
175
+
176
+ # %% ../nbs/01_ML.ipynb #5cacf75a
177
+ get_score_kld = partial(get_score, func=kl_divergence_flat)
178
+
179
+ # %% ../nbs/01_ML.ipynb #e1fe96d8
180
+ def calculate_ce(
181
+ target_series: pd.Series | np.ndarray,
182
+ pred_series: pd.Series | np.ndarray,
183
+ epsilon: float = 1e-8,
184
+ ) -> float:
185
+ "Compute cross-entropy between two flattened probability vectors."
186
+ p = _normalize_vector(target_series, epsilon=epsilon)
187
+ q = _normalize_vector(pred_series, epsilon=epsilon)
188
+ return float(-(p * np.log(q)).sum())
189
+
190
+ # %% ../nbs/01_ML.ipynb #e173c2aa
191
+ get_score_ce = partial(get_score, func=calculate_ce)
192
+
193
+ # %% ../nbs/01_ML.ipynb #60892cc6
194
+ def predict_ml(
195
+ df: pd.DataFrame, # dataframe with features
196
+ feat_col: Sequence[str], # feature columns
197
+ target_col: Sequence[str] | None = None,
198
+ model_pth: str | Path = "model.joblib",
199
+ ) -> pd.DataFrame:
200
+ "Predict from a saved sklearn model."
201
+ test = df[list(feat_col)]
202
+ model = load(model_pth)
203
+ pred = model.predict(test)
204
+ columns = list(target_col) if target_col is not None else list(range(pred.shape[1]))
205
+ return pd.DataFrame(pred, index=df.index, columns=columns)
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.4
2
+ Name: kmodel
3
+ Version: 0.0.1
4
+ Summary: A fresh nbdev project for kmodel.
5
+ Author-email: keke <lcai888666@gmail.com>
6
+ License: Apache-2.0
7
+ Project-URL: Repository, https://github.com/sky1ove/kmodel
8
+ Project-URL: Documentation, https://sky1ove.github.io/kmodel/
9
+ Keywords: nbdev
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: fastai>=2.8.7
16
+ Requires-Dist: joblib>=1.5.3
17
+ Requires-Dist: numpy>=2.2.6
18
+ Requires-Dist: pandas>=2.3.3
19
+ Requires-Dist: scikit-learn>=1.7.2
20
+ Requires-Dist: torch>=2.11.0
21
+ Dynamic: license-file
22
+
23
+ # kmodel
24
+
25
+
26
+ <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
27
+
28
+ This file will become your README and also the index of your
29
+ documentation.
30
+
31
+ ## Developer Guide
32
+
33
+ If you are new to using `nbdev` here are some useful pointers to get you
34
+ started.
35
+
36
+ ### Install kmodel in Development mode
37
+
38
+ ``` sh
39
+ # make sure kmodel package is installed in development mode
40
+ $ pip install -e .
41
+
42
+ # make changes under nbs/ directory
43
+ # ...
44
+
45
+ # compile to have changes apply to kmodel
46
+ $ nbdev_prepare
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ ### Installation
52
+
53
+ Install latest from the GitHub
54
+ [repository](https://github.com/sky1ove/kmodel):
55
+
56
+ ``` sh
57
+ $ pip install git+https://github.com/sky1ove/kmodel.git
58
+ ```
59
+
60
+ or from [conda](https://anaconda.org/sky1ove/kmodel)
61
+
62
+ ``` sh
63
+ $ conda install -c sky1ove kmodel
64
+ ```
65
+
66
+ or from [pypi](https://pypi.org/project/kmodel/)
67
+
68
+ ``` sh
69
+ $ pip install kmodel
70
+ ```
71
+
72
+ ### Documentation
73
+
74
+ Documentation can be found hosted on this GitHub
75
+ [repository](https://github.com/sky1ove/kmodel)’s
76
+ [pages](https://sky1ove.github.io/kmodel/). Additionally you can find
77
+ package manager specific guidelines on
78
+ [conda](https://anaconda.org/sky1ove/kmodel) and
79
+ [pypi](https://pypi.org/project/kmodel/) respectively.
80
+
81
+ ## How to use
82
+
83
+ Fill me in please! Don’t forget code examples:
84
+
85
+ ``` python
86
+ 1+1
87
+ ```
88
+
89
+ 2
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ kmodel/__init__.py
6
+ kmodel/_modidx.py
7
+ kmodel/core.py
8
+ kmodel/dnn.py
9
+ kmodel/train.py
10
+ kmodel.egg-info/PKG-INFO
11
+ kmodel.egg-info/SOURCES.txt
12
+ kmodel.egg-info/dependency_links.txt
13
+ kmodel.egg-info/entry_points.txt
14
+ kmodel.egg-info/requires.txt
15
+ kmodel.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [nbdev]
2
+ kmodel = kmodel._modidx:d
@@ -0,0 +1,6 @@
1
+ fastai>=2.8.7
2
+ joblib>=1.5.3
3
+ numpy>=2.2.6
4
+ pandas>=2.3.3
5
+ scikit-learn>=1.7.2
6
+ torch>=2.11.0
@@ -0,0 +1 @@
1
+ kmodel
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "kmodel"
7
+ dynamic = ["version"]
8
+ description = "A fresh nbdev project for kmodel."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = {text = "Apache-2.0"}
12
+ authors = [{name = "keke", email = "lcai888666@gmail.com"}]
13
+ keywords = ['nbdev']
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3 :: Only",
17
+ ]
18
+ dependencies = [
19
+ "fastai>=2.8.7",
20
+ "joblib>=1.5.3",
21
+ "numpy>=2.2.6",
22
+ "pandas>=2.3.3",
23
+ "scikit-learn>=1.7.2",
24
+ "torch>=2.11.0",
25
+ ]
26
+
27
+ [project.urls]
28
+ Repository = "https://github.com/sky1ove/kmodel"
29
+ Documentation = "https://sky1ove.github.io/kmodel/"
30
+
31
+ [project.entry-points.nbdev]
32
+ kmodel = "kmodel._modidx:d"
33
+
34
+ [tool.setuptools.dynamic]
35
+ version = {attr = "kmodel.__version__"}
36
+
37
+ [tool.setuptools.packages.find]
38
+ include = ["kmodel"]
39
+
40
+ [tool.nbdev]
41
+ title = "kmodel"
42
+ lib_path = "kmodel"
43
+
44
+ [dependency-groups]
45
+ dev = [
46
+ "ipykernel>=7.2.0",
47
+ "nbclient>=0.10.4",
48
+ "nbformat>=5.10.4",
49
+ "seaborn>=0.13.2",
50
+ ]
kmodel-0.0.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+