{"id":17030317,"url":"https://github.com/vsoch/watchme-sklearn","last_synced_at":"2026-05-19T09:05:50.189Z","repository":{"id":141668081,"uuid":"186300495","full_name":"vsoch/watchme-sklearn","owner":"vsoch","description":"use watchme psutils monitor wrapper to record metrics for a set of sklearn functions","archived":false,"fork":false,"pushed_at":"2019-05-12T21:01:43.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T00:22:03.778Z","etag":null,"topics":["decorators","monitoring","psutils","python","watchme","watchme-psutils"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vsoch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-12T20:24:48.000Z","updated_at":"2019-05-12T21:01:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"d3f00469-b4c3-428e-b31a-757b88e06b7d","html_url":"https://github.com/vsoch/watchme-sklearn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsoch%2Fwatchme-sklearn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsoch%2Fwatchme-sklearn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsoch%2Fwatchme-sklearn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsoch%2Fwatchme-sklearn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vsoch","download_url":"https://codeload.github.com/vsoch/watchme-sklearn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245016009,"owners_count":20547516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decorators","monitoring","psutils","python","watchme","watchme-psutils"],"created_at":"2024-10-14T08:06:07.345Z","updated_at":"2026-05-19T09:05:45.168Z","avatar_url":"https://github.com/vsoch.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Watchme Sklearn\n\nThis is an example of using [watchme](https://vsoch.github.io/watchme),\nspecifically the [psutils](https://vsoch.github.io/watchme/watchers/psutils/#1-the-monitor-pid-task) decorator, \nto monitor resource usage for various functions run within Python. Since we build the dependencies\ninto a Singularity container, and since Singularity has access to \nour home, the watcher and data are saved on the host with no extra work needed.\n\n**Note** I created the watcher repository with watchme first, and\nthen added the extra files for the README.md and [container](Singularity).\nIf you use a decorator, you don't technically need to do this - the\nPython files being decorated can be separate from the watchme base with\nresults. I wanted to keep them together, so I chose to add these files\nafter.\n\n## 1. Build the Container\n\nFirst, build the Singularity container with Python dependencies installed:\n\n```bash\nsudo singularity build watchme-sklearn.sif Singularity\n```\n\n## 2. Run\n\nNext, running the container is going to create a watcher called \"watchme-sklearn\"\nwhich by default will go into your `$HOME/.watchme` folder.  You'll see\nthe watcher generated, followed by the function runs.\n\n```bash\nsingularity run watchme-sklearn.sif\n\nAdding watcher /home/vanessa/.watchme/watchme-sklearn...\nGenerating watcher config /home/vanessa/.watchme/watchme-sklearn/watchme.cfg\n\n=============================================================================\nManifold learning on handwritten digits: Locally Linear Embedding, Isomap...\n=============================================================================\n\nAn illustration of various embeddings on the digits dataset.\n\nThe RandomTreesEmbedding, from the :mod:`sklearn.ensemble` module, is not\ntechnically a manifold embedding method, as it learn a high-dimensional\nrepresentation on which we apply a dimensionality reduction method.\nHowever, it is often useful to cast a dataset into a representation in\nwhich the classes are linearly-separable.\n\nt-SNE will be initialized with the embedding that is generated by PCA in\nthis example, which is not the default setting. It ensures global stability\nof the embedding, i.e., the embedding does not depend on random\ninitialization.\n\nLinear Discriminant Analysis, from the :mod:`sklearn.discriminant_analysis`\nmodule, and Neighborhood Components Analysis, from the :mod:`sklearn.neighbors`\nmodule, are supervised dimensionality reduction method, i.e. they make use of\nthe provided labels, contrary to other methods.\n\nComputing random projection\nComputing PCA projection\nComputing Linear Discriminant Analysis projection\nComputing Isomap projection\nDone.\nComputing LLE embedding\nDone. Reconstruction error: 1.63546e-06\nComputing modified LLE embedding\nDone. Reconstruction error: 0.360659\nComputing Hessian LLE embedding\nDone. Reconstruction error: 0.212804\nComputing LTSA embedding\nDone. Reconstruction error: 0.212804\nComputing MDS embedding\nDone. Stress: 157308701.864713\nComputing Spectral embedding\nComputing t-SNE embedding\n```\n\nThe functions are run fairly quickly, so we measure every quarter of a second.\nWatchme creates the the git repo and commits data to it (each time the decorator function is run,\na `decorator-psutils-\u003cname\u003e` folder is created with a result.json. Every\ncommit will coincide with a list of timepoints run for a single function. Here is\nwhat the repository looks like after the run (without adding these files\nyet):\n\n\n```bash\n$ tree\n.\n├── decorator-psutils-hessian_lle_embedding\n│   ├── result.json\n│   └── TIMESTAMP\n├── decorator-psutils-isomap_projection\n│   ├── result.json\n│   └── TIMESTAMP\n├── decorator-psutils-lda_projection\n│   ├── result.json\n│   └── TIMESTAMP\n├── decorator-psutils-lle_embedding\n│   ├── result.json\n│   └── TIMESTAMP\n├── decorator-psutils-ltsa_embedding\n│   ├── result.json\n│   └── TIMESTAMP\n├── decorator-psutils-mds_embedding\n│   ├── result.json\n│   └── TIMESTAMP\n├── decorator-psutils-modified_lle_embedding\n│   ├── result.json\n│   └── TIMESTAMP\n├── decorator-psutils-pca_projection\n│   ├── result.json\n│   └── TIMESTAMP\n├── decorator-psutils-plot_digits\n│   ├── result.json\n│   └── TIMESTAMP\n├── decorator-psutils-plot_embedding\n│   ├── result.json\n│   └── TIMESTAMP\n├── decorator-psutils-random_2d_projection\n│   ├── result.json\n│   └── TIMESTAMP\n├── decorator-psutils-spectral_embedding\n│   ├── result.json\n│   └── TIMESTAMP\n├── decorator-psutils-tsne_embedding\n│   ├── result.json\n│   └── TIMESTAMP\n└── watchme.cfg\n\n13 directories, 27 files\n```\n\nAnd you would next be able to push directly to a new GitHub repository:\n\n```bash\ncd $HOME/.watchme/watchme-sklearn\ngit remote add origin https://github.com/vsoch/watchme-sklearn.git\ngit push -u origin master\n``\n\n(add a README to have better documentation about what you've done). \nOr you can export full data for any particular decorator to analyze:\n\n```bash\nwatchme export watchme-sklearn decorator-psutils-plot_digits result.json  --json\n```\n\nWhat is exporter? Each commit coincides \nHere is a programmatic way to export all results to a \"data\" folder in the repository:\n\n```bash\nmkdir -p data\nfor folder in $(find . -maxdepth 1 -type d -name 'decorator*' -print); do\n    folder=\"${folder//.\\/}\"\n    watchme export watchme-sklearn $folder --out data/$folder.json result.json --json --force\ndone\n```\n\n## Advanced\n\nIf you already have a watchme repository, and it's located somewhere non-traditional,\nyou can have watchme generate results in the folder where you happen to be by\nexporting the WATCHME_BASE_DIR first. \n\n```bash\nexport WATCHME_BASE_DIR=$(dirname $PWD)\n```\n\nAnd for a run from within a Singularity, container you would need to have this export as a `SINGULARITYENV_`\n\n```bash\nexport SINGULARITYENV_WATCHME_BASE_DIR=$(dirname $PWD)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsoch%2Fwatchme-sklearn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvsoch%2Fwatchme-sklearn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsoch%2Fwatchme-sklearn/lists"}