foml-toolkit 0.2.0__py3-none-any.whl
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.
- foml_toolkit/__init__.py +56 -0
- foml_toolkit/clustering.py +136 -0
- foml_toolkit/codebook.py +188 -0
- foml_toolkit/labs_code/lab01_linalg.py +77 -0
- foml_toolkit/labs_code/lab01_numpy_basics.py +56 -0
- foml_toolkit/labs_code/lab02_gd_simple.py +46 -0
- foml_toolkit/labs_code/lab02_gd_two_var.py +45 -0
- foml_toolkit/labs_code/lab03_gd_matrix.py +50 -0
- foml_toolkit/labs_code/lab04_logistic_gd.py +63 -0
- foml_toolkit/labs_code/lab05_nn_forward.py +88 -0
- foml_toolkit/labs_code/lab06_nn_scratch.py +96 -0
- foml_toolkit/labs_code/lab07_keras_nn.py +85 -0
- foml_toolkit/labs_code/lab08_pca_manual.py +41 -0
- foml_toolkit/labs_code/lab08_pca_sklearn.py +58 -0
- foml_toolkit/labs_code/lab09_pca_faces.py +49 -0
- foml_toolkit/labs_code/lab09_pca_images.py +64 -0
- foml_toolkit/labs_code/lab10_lda.py +68 -0
- foml_toolkit/labs_code/lab11_kmeans.py +43 -0
- foml_toolkit/labs_code/lab12_hierarchical.py +43 -0
- foml_toolkit/labs_code/lab14_concrete.py +269 -0
- foml_toolkit/regression.py +284 -0
- foml_toolkit-0.2.0.dist-info/METADATA +136 -0
- foml_toolkit-0.2.0.dist-info/RECORD +25 -0
- foml_toolkit-0.2.0.dist-info/WHEEL +4 -0
- foml_toolkit-0.2.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: foml-toolkit
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: All FOML lab code (Labs 1-14) with run("pca") and help() code lookup, plus clustering and regression helpers.
|
|
5
|
+
Project-URL: Homepage, https://github.com/YOUR_USERNAME/foml-toolkit
|
|
6
|
+
Author-email: Your Name <you@example.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Requires-Dist: matplotlib
|
|
11
|
+
Requires-Dist: numpy
|
|
12
|
+
Requires-Dist: pandas
|
|
13
|
+
Requires-Dist: scikit-learn
|
|
14
|
+
Requires-Dist: scipy
|
|
15
|
+
Provides-Extra: cv
|
|
16
|
+
Requires-Dist: opencv-python; extra == 'cv'
|
|
17
|
+
Provides-Extra: deep
|
|
18
|
+
Requires-Dist: tensorflow; extra == 'deep'
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: build; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
22
|
+
Requires-Dist: twine; extra == 'dev'
|
|
23
|
+
Provides-Extra: regression
|
|
24
|
+
Requires-Dist: statsmodels; extra == 'regression'
|
|
25
|
+
Requires-Dist: ucimlrepo; extra == 'regression'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# foml-toolkit
|
|
29
|
+
|
|
30
|
+
All FOML lab code (Labs 1-14) in one library. Type a topic name and get the code.
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import foml_toolkit as ft # or: from foml_toolkit import *
|
|
34
|
+
|
|
35
|
+
ft.run("pca") # prints ALL PCA code (manual, sklearn, faces, your own images)
|
|
36
|
+
ft.run("kmeans") # K-Means (Lab 11)
|
|
37
|
+
ft.run("lda") # LDA (Lab 10)
|
|
38
|
+
ft.run("lab9") # everything from Lab 9
|
|
39
|
+
ft.run(ft.pca) # also works without quotes: run(pca) after from foml_toolkit import *
|
|
40
|
+
ft.run("kmeans", execute=True) # print the code AND run it
|
|
41
|
+
ft.topics() # list every topic
|
|
42
|
+
ft.search("silhouette") # find a topic by keyword
|
|
43
|
+
ft.show_all() # print every code in the library
|
|
44
|
+
help(ft) # opens the full index + ALL code in Python's help viewer
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
| Topic name | Lab | What |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `linalg`, `broadcasting` | 1 | solve/det/singular systems, NumPy speed, broadcasting, shapes |
|
|
50
|
+
| `gd_simple`, `gd_two_var` | 2 | gradient descent (1 and 2 features), SGDRegressor |
|
|
51
|
+
| `gd_matrix` | 3 | matrix gradient descent |
|
|
52
|
+
| `logistic_gd` | 4 | logistic regression from scratch |
|
|
53
|
+
| `nn_forward` | 5 | forward propagation, 2- and 3-layer |
|
|
54
|
+
| `nn_scratch` | 6 | full neural network, backprop, training |
|
|
55
|
+
| `keras_nn` | 7 | TensorFlow/Keras classification + regression |
|
|
56
|
+
| `pca_manual`, `pca_sklearn` | 8 | PCA by hand and with sklearn (Iris) |
|
|
57
|
+
| `pca_faces`, `pca_images` | 9 | image PCA (Olivetti faces, your own pictures) |
|
|
58
|
+
| `lda` | 10 | Linear Discriminant Analysis |
|
|
59
|
+
| `kmeans` | 11 | K-Means |
|
|
60
|
+
| `hierarchical` | 12 | agglomerative clustering, dendrogram, silhouette |
|
|
61
|
+
| `concrete_regression` | 14 | concrete strength, 9 models + GridSearchCV |
|
|
62
|
+
|
|
63
|
+
Groups: `pca`, `gd`, `nn`, `cluster`, `logistic`, `linear_regression`, `numpy_basics`.
|
|
64
|
+
|
|
65
|
+
Some snippets need extras: `pip install "foml-toolkit[regression,cv,deep]"`
|
|
66
|
+
(`regression` = ucimlrepo+statsmodels, `cv` = opencv for `pca_images`, `deep` = tensorflow for `keras_nn`).
|
|
67
|
+
|
|
68
|
+
Small bugs in the original notebooks are fixed and marked with `# NOTE:` comments in the code.
|
|
69
|
+
|
|
70
|
+
The clustering and regression labs are also real, importable functions
|
|
71
|
+
(`ft.run_kmeans`, `ft.compare_linkages`, `ft.evaluate_models`, ... see below).
|
|
72
|
+
|
|
73
|
+
## Install
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install -e . # from the project folder (private / editable)
|
|
77
|
+
pip install -e ".[regression]" # also installs ucimlrepo + statsmodels (Lab 14)
|
|
78
|
+
# or straight from GitHub:
|
|
79
|
+
pip install "foml-toolkit[regression] @ git+https://github.com/YOUR_USERNAME/foml-toolkit.git"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Quick examples
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import foml_toolkit as ft
|
|
86
|
+
|
|
87
|
+
# Lab 11 - K-Means on Wine
|
|
88
|
+
X, y = ft.load_wine_df()
|
|
89
|
+
model, Xs = ft.run_kmeans(X, n_clusters=3, scale=True)
|
|
90
|
+
print(model.labels_, model.cluster_centers_)
|
|
91
|
+
ft.plot_clusters_2d(X, model.labels_, x_index=0, y_index=9,
|
|
92
|
+
xlabel="Alcohol", ylabel="Color Intensity")
|
|
93
|
+
|
|
94
|
+
# Lab 12 - Hierarchical clustering on Iris
|
|
95
|
+
X, y = ft.load_iris_df()
|
|
96
|
+
Xs, _ = ft.scale_features(X)
|
|
97
|
+
ft.plot_dendrogram(Xs)
|
|
98
|
+
print(ft.compare_linkages(Xs))
|
|
99
|
+
_, labels = ft.run_agglomerative(Xs, 3, "ward")
|
|
100
|
+
print(ft.cluster_vs_actual(y, labels))
|
|
101
|
+
|
|
102
|
+
# Lab 14 - Concrete strength
|
|
103
|
+
from sklearn.model_selection import train_test_split
|
|
104
|
+
import pandas as pd
|
|
105
|
+
df = ft.load_concrete()
|
|
106
|
+
X, y = ft.clean_data(df)
|
|
107
|
+
Xtr, Xte, ytr, yte = train_test_split(X, y, test_size=0.2, random_state=42)
|
|
108
|
+
sets = ft.select_feature_sets(Xtr, Xte)
|
|
109
|
+
|
|
110
|
+
results, models = [], {}
|
|
111
|
+
for name, (a, b) in sets.items():
|
|
112
|
+
r, m = ft.evaluate_models(a, b, ytr, yte, name) # slow: full grids
|
|
113
|
+
results.append(r); models[name] = m
|
|
114
|
+
results_all = pd.concat(results, ignore_index=True)
|
|
115
|
+
|
|
116
|
+
model, fs, name, row = ft.select_best_model(results_all, models)
|
|
117
|
+
mix = {"Cement": [350], "Slag": [80], "Fly_Ash": [50], "Water": [180],
|
|
118
|
+
"Superplasticizer": [8], "Coarse_Aggregate": [1000],
|
|
119
|
+
"Fine_Aggregate": [750], "Age": [28]}
|
|
120
|
+
print(ft.predict_new_mix(model, fs, mix), "MPa")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Develop
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pip install -e ".[regression,dev]"
|
|
127
|
+
pytest
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Publish
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
python -m build
|
|
134
|
+
twine upload --repository testpypi dist/* # try first
|
|
135
|
+
twine upload dist/* # real PyPI
|
|
136
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
foml_toolkit/__init__.py,sha256=I3RwZhIpw81QvdTXbITejD6ayuGkzrkkKLUur6EXQvA,1618
|
|
2
|
+
foml_toolkit/clustering.py,sha256=xu_QdbAl5SlU-Wc11I6KYUVlz75JG3_bTX8Y86pucIk,4836
|
|
3
|
+
foml_toolkit/codebook.py,sha256=9KKkfPqNq86VnaU9SCB2ZiZ9xap9xoBW8atdNDxpeDo,6147
|
|
4
|
+
foml_toolkit/regression.py,sha256=eMYlNNMYwjICw9RZyChmW5rPPfnV47DoK9ZTnJPBZOw,11634
|
|
5
|
+
foml_toolkit/labs_code/lab01_linalg.py,sha256=wb770CWsuHA-8DbAEdIVBcwNEySqyYlFeuK6b0nxtXA,2567
|
|
6
|
+
foml_toolkit/labs_code/lab01_numpy_basics.py,sha256=BVOMrh_faFr7_wrj-TiXWS6u26wuaB5BKnC3mGaHYGM,1693
|
|
7
|
+
foml_toolkit/labs_code/lab02_gd_simple.py,sha256=oWD7YnyiAdugW0gy-2_tGzI7ulRjvsKmLvwNA2lpASg,1677
|
|
8
|
+
foml_toolkit/labs_code/lab02_gd_two_var.py,sha256=HDaURPYXW3Bt7SUMHx1LGsieSmSCgMLRntgyeKggCXg,1586
|
|
9
|
+
foml_toolkit/labs_code/lab03_gd_matrix.py,sha256=1eegKIdQZo1ja1A-XPlNG3nQvB2scKaNJf5lG2tTuno,1330
|
|
10
|
+
foml_toolkit/labs_code/lab04_logistic_gd.py,sha256=9qD3ba3lswZ6IRI3O8m45YVN3CRKYH-D4tL_pcUrmBQ,1508
|
|
11
|
+
foml_toolkit/labs_code/lab05_nn_forward.py,sha256=B1BwXjkrWMS3tp7kM_dUXsWm5h2AhwjO2wPsMtNNMQ0,2594
|
|
12
|
+
foml_toolkit/labs_code/lab06_nn_scratch.py,sha256=lr21J-eR4M2sHD-gJBSjeDJ2GV-w78pIUy--oZhyuJg,2841
|
|
13
|
+
foml_toolkit/labs_code/lab07_keras_nn.py,sha256=mXOTrHIbr2XsMbQtVvELD0v5t1arDTYI9MB-x2EPojQ,3708
|
|
14
|
+
foml_toolkit/labs_code/lab08_pca_manual.py,sha256=YxHV2ol74F3sMwFFI1JZXsxDPNHJzofp_-LRcyPlhrs,1289
|
|
15
|
+
foml_toolkit/labs_code/lab08_pca_sklearn.py,sha256=NwdfoO0bS9XRcYvZuWd1yzuO1v0GwTLGlpECwa5aa4s,2183
|
|
16
|
+
foml_toolkit/labs_code/lab09_pca_faces.py,sha256=cvu2hTu5JsMOIhA4b3G3qhxYd9justOsK-0IhN2_Rec,1857
|
|
17
|
+
foml_toolkit/labs_code/lab09_pca_images.py,sha256=E08aaipgJvWRKfaJnk_FJo8shmAAhn4ZnOBfPmPD4Dw,2648
|
|
18
|
+
foml_toolkit/labs_code/lab10_lda.py,sha256=1cwaNZyEeepYDr5N-IatviXBVrrc0Bgpd7xnFz1YqMw,2208
|
|
19
|
+
foml_toolkit/labs_code/lab11_kmeans.py,sha256=U5RwrCvA9vfnypeW9GCeqRIDTVGOWHnGmH2AJSLl170,1751
|
|
20
|
+
foml_toolkit/labs_code/lab12_hierarchical.py,sha256=U_HUphAX7eFGeLh7pKNxIS7GMjGtDjYRilNpQLzmJqI,1750
|
|
21
|
+
foml_toolkit/labs_code/lab14_concrete.py,sha256=ldFMe7X1Qr5gKfad_w08-ybN0mb-Tc-NX-sv2JSCLr8,12939
|
|
22
|
+
foml_toolkit-0.2.0.dist-info/METADATA,sha256=oH65ObGw4gHPkTvm5miO-KAJdC6Pw3nXbum6gfcNCww,5002
|
|
23
|
+
foml_toolkit-0.2.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
24
|
+
foml_toolkit-0.2.0.dist-info/licenses/LICENSE,sha256=v2spsd7N1pKFFh2G8wGP_45iwe5S0DYiJzG4im8Rupc,1066
|
|
25
|
+
foml_toolkit-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Your Name
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|