A collection of useful mixins for machine learning development code.
Project description
ML Mixins
This package contains some useful python mixin classes for use in ML / data science, including a mixin for
seeding (SeedableMixin), timing (TimeableMixin), and memory tracking (MemTrackableMixin).
Installation
this package can be installed via pip:
pip install ml-mixins
Usage
You can use these mixins either by (1) Defining your classes to inherit from them, then leveraging their included methods in your derived class, or (2) Adding them post-hoc to an existing class for use in secondary applications such as benchmarking or debugging without overhead in production code. Below, we show how to use each mixin directly first, then we show how to add them to an existing class at the end, as that process will still leverage the same decorator methods and class member variables in the resulting modified classes.
Mixin Documentation
SeedableMixin
from mixins import SeedableMixin
class MyModel(SeedableMixin):
...
@SeedableMixin.WithSeed
def fit(self, X, y):
# This function can now be called with a seed kwarg, or it will use a pseudo-random seed which will be
# saved to a class member variable if a seed is not passed.
...
TimeableMixin
TODO
MemTrackableMixin
TODO
Adding Mixins Post-Hoc
from mixins import TimeableMixin, add_mixin
class MyModel:
...
def fit(self, X, y): ...
# Add the mixin to the class
TimedModel = add_mixin(
MyModel, TimeableMixin, decorate_methods={"fit": TimeableMixin.TimeAs}
)
# Now, the class `TimedModel` will have the same methods as `MyModel`, but with the added timing
# functionality:
model = TimedModel()
model.fit(X, y)
model._profile_durations() # will print durations...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ml_mixins-0.2.2.tar.gz.
File metadata
- Download URL: ml_mixins-0.2.2.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2761d8edbeba3958430ec62f24e0592ecfda0e38347065801ece6b3ff0f01953
|
|
| MD5 |
ed0ee8e83099514ff5f000f7c0be80af
|
|
| BLAKE2b-256 |
31c414c3c2af765bf54f200c5071f034b8a477c36748116cd1d9ced470710056
|
Provenance
The following attestation bundles were made for ml_mixins-0.2.2.tar.gz:
Publisher:
python-build.yaml on mmcdermott/ML_mixins
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ml_mixins-0.2.2.tar.gz -
Subject digest:
2761d8edbeba3958430ec62f24e0592ecfda0e38347065801ece6b3ff0f01953 - Sigstore transparency entry: 175515225
- Sigstore integration time:
-
Permalink:
mmcdermott/ML_mixins@37abad4f306677a08355513b3d2fb534d099f989 -
Branch / Tag:
refs/tags/0.2.2 - Owner: https://github.com/mmcdermott
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-build.yaml@37abad4f306677a08355513b3d2fb534d099f989 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ml_mixins-0.2.2-py3-none-any.whl.
File metadata
- Download URL: ml_mixins-0.2.2-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5da20a9c0cbe62df798e83b27acbe9247db245269e91870febebc4a84c10084
|
|
| MD5 |
b8adadf399a9fca3b4c139a0e8147598
|
|
| BLAKE2b-256 |
508892e0f8a1bb1d56d090ff2f79c23812917e1ad4d0f1b83a3185bbada63a3c
|
Provenance
The following attestation bundles were made for ml_mixins-0.2.2-py3-none-any.whl:
Publisher:
python-build.yaml on mmcdermott/ML_mixins
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ml_mixins-0.2.2-py3-none-any.whl -
Subject digest:
e5da20a9c0cbe62df798e83b27acbe9247db245269e91870febebc4a84c10084 - Sigstore transparency entry: 175515233
- Sigstore integration time:
-
Permalink:
mmcdermott/ML_mixins@37abad4f306677a08355513b3d2fb534d099f989 -
Branch / Tag:
refs/tags/0.2.2 - Owner: https://github.com/mmcdermott
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-build.yaml@37abad4f306677a08355513b3d2fb534d099f989 -
Trigger Event:
push
-
Statement type: