This release is a pre-release and may not be stable for production use.
microcosm-sagemaker
Opinionated machine learning with SageMaker
Usage
For best practices, see
cookiecutter-microcosm-sagemaker.
Profiling
Make sure pyinstrument is installed, either using pip install pyinstrument or by installing microcosm-sagemaker with profiling extra dependencies:
pip install -e '.[profiling]'
To enable profiling of the app, use the --profile flag with runserver:
runserver --profile
The service will log that it is in profiling mode and announce the directory to which it is exporting. Each call to the endpoint will be profiled and its results with be stored in a time-tagged html file in the profiling directory.
Experiment Tracking
To use Weights and Biases, install microcosm-sagemaker with wandb extra depdency:
pip install -e '.[wandb]'
To enable experiment tracking in an ML repository:
-
Choose the experiment tracking stores for your ML model. It is recommended to store metrics in both
wandband Amazoncloudwatch. To do so, addwandbandcloudwatchtograph.use()inapp_hooks/train/app.pyandapp_hooks/evaluate/app.py. -
Add the API key for
wandbto your ML model'sconfig.jsonfile:
{
"wandb": {
"api_key": "XXXXXX"
}
}
- To define hyperparameters for your model:
from microcosm.api import defaults, binding
from microcosm_sagemaker.bundle import Bundle
from microcosm_sagemaker.hyperparameters import hyperparameter
@binding("my_classifier")
@defaults(
param = 10,
hyperparam = hyperparameter(20),
)
class MyClassifier(Bundle):
...
That automatically adds the hyperparameters to your experiment, which simplifies hyperparameter optimization and tuning.
- To report a static metric:
class MyClassifier(Bundle):
...
def fit(self, input_data):
...
self.experiment_metrics.log_static(<metric_name>=<metric_value>)
- To report a time-series metric:
class MyClassifier(Bundle):
...
def fit(self, input_data):
...
self.experiment_metrics.log_timeseries(
<metric_name>=<metric_value>,
step=<step_number>
)
Note that the step keyword argument must be provided for logging time-series.
Release files for microcosm-sagemaker 0.2065.dev2065
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| microcosm-sagemaker-0.2065.dev2065.tar.gz | 26.2 kB | Details |
Release files / microcosm-sagemaker-0.2065.dev2065.tar.gz
| Download URL | microcosm-sagemaker-0.2065.dev2065.tar.gz |
|---|---|
| Size | 26.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c99fac8f14a269212d695600f506cd921913d108e226762992fd2653049a2d12
|
|
BLAKE2b-256 checksum How to use checksums |
cd01e9bc6034912bac00c0f9428e3f1e8de01f87af76df7dea378a45947cb984
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.45.0 CPython/3.7.7
|