Skip to main content

foml-toolkit

All FOML lab code (Labs 1-14) in one library. Type a topic name and get the code.

import foml_toolkit as ft      # or:  from foml_toolkit import *

ft.run("pca")             # prints ALL PCA code (manual, sklearn, faces, your own images)
ft.run("kmeans")          # K-Means (Lab 11)
ft.run("lda")             # LDA (Lab 10)
ft.run("lab9")            # everything from Lab 9
ft.run(ft.pca)            # also works without quotes:  run(pca)  after  from foml_toolkit import *
ft.run("kmeans", execute=True)   # print the code AND run it
ft.topics()               # list every topic
ft.search("silhouette")   # find a topic by keyword
ft.show_all()             # print every code in the library
help(ft)                  # opens the full index + ALL code in Python's help viewer
Topic name Lab What
linalg, broadcasting 1 solve/det/singular systems, NumPy speed, broadcasting, shapes
gd_simple, gd_two_var 2 gradient descent (1 and 2 features), SGDRegressor
gd_matrix 3 matrix gradient descent
logistic_gd 4 logistic regression from scratch
nn_forward 5 forward propagation, 2- and 3-layer
nn_scratch 6 full neural network, backprop, training
keras_nn 7 TensorFlow/Keras classification + regression
pca_manual, pca_sklearn 8 PCA by hand and with sklearn (Iris)
pca_faces, pca_images 9 image PCA (Olivetti faces, your own pictures)
lda 10 Linear Discriminant Analysis
kmeans 11 K-Means
hierarchical 12 agglomerative clustering, dendrogram, silhouette
concrete_regression 14 concrete strength, 9 models + GridSearchCV

Groups: pca, gd, nn, cluster, logistic, linear_regression, numpy_basics.

Some snippets need extras: pip install "foml-toolkit[regression,cv,deep]" (regression = ucimlrepo+statsmodels, cv = opencv for pca_images, deep = tensorflow for keras_nn).

Small bugs in the original notebooks are fixed and marked with # NOTE: comments in the code.

The clustering and regression labs are also real, importable functions (ft.run_kmeans, ft.compare_linkages, ft.evaluate_models, ... see below).

Install

pip install -e .                 # from the project folder (private / editable)
pip install -e ".[regression]"   # also installs ucimlrepo + statsmodels (Lab 14)
# or straight from GitHub:
pip install "foml-toolkit[regression] @ git+https://github.com/YOUR_USERNAME/foml-toolkit.git"

Quick examples

import foml_toolkit as ft

# Lab 11 - K-Means on Wine
X, y = ft.load_wine_df()
model, Xs = ft.run_kmeans(X, n_clusters=3, scale=True)
print(model.labels_, model.cluster_centers_)
ft.plot_clusters_2d(X, model.labels_, x_index=0, y_index=9,
                    xlabel="Alcohol", ylabel="Color Intensity")

# Lab 12 - Hierarchical clustering on Iris
X, y = ft.load_iris_df()
Xs, _ = ft.scale_features(X)
ft.plot_dendrogram(Xs)
print(ft.compare_linkages(Xs))
_, labels = ft.run_agglomerative(Xs, 3, "ward")
print(ft.cluster_vs_actual(y, labels))

# Lab 14 - Concrete strength
from sklearn.model_selection import train_test_split
import pandas as pd
df = ft.load_concrete()
X, y = ft.clean_data(df)
Xtr, Xte, ytr, yte = train_test_split(X, y, test_size=0.2, random_state=42)
sets = ft.select_feature_sets(Xtr, Xte)

results, models = [], {}
for name, (a, b) in sets.items():
    r, m = ft.evaluate_models(a, b, ytr, yte, name)   # slow: full grids
    results.append(r); models[name] = m
results_all = pd.concat(results, ignore_index=True)

model, fs, name, row = ft.select_best_model(results_all, models)
mix = {"Cement": [350], "Slag": [80], "Fly_Ash": [50], "Water": [180],
       "Superplasticizer": [8], "Coarse_Aggregate": [1000],
       "Fine_Aggregate": [750], "Age": [28]}
print(ft.predict_new_mix(model, fs, mix), "MPa")

Develop

pip install -e ".[regression,dev]"
pytest

Publish

python -m build
twine upload --repository testpypi dist/*   # try first
twine upload dist/*                          # real PyPI

Metadata

Release files for foml-toolkit 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foml-toolkit 0.2.0
File Size Uploaded Provenance Actions
foml_toolkit-0.2.0.tar.gz 26.7 kB Without provenance Details for foml_toolkit-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for foml-toolkit 0.2.0
File Interpreter ABI Platform Actions
foml_toolkit-0.2.0-py3-none-any.whl Python 3 none any Details for foml_toolkit-0.2.0-py3-none-any.whl

Total release size: 61.0 kB

Release files / foml_toolkit-0.2.0.tar.gz

Download URL foml_toolkit-0.2.0.tar.gz
Size 26.7 kB
Tags Source
SHA-256 checksum
How to use checksums
340276b79b962c5d8f8f75f374f120467c3e4c3c25f888f63678bc2eb99d90bb
BLAKE2b-256 checksum
How to use checksums
6c2376cba3985fd1a4f38699266f58f2f28b708f5526454971e25027e01b300e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / foml_toolkit-0.2.0-py3-none-any.whl

Download URL foml_toolkit-0.2.0-py3-none-any.whl
Size 34.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7cb0f6a599e7ad77a44f740fc18f3aeddb6061cad7d3727fff4f1e4457cbe3e9
BLAKE2b-256 checksum
How to use checksums
2d26d4b38248fb88beca907a8e8bbc03b9f7c230b1e22cfe0d4ff008475bbcb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for foml-toolkit 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page