{ "info": { "author": "Stefan Binder", "author_email": "", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# hypernotes \n[](https://pypi.python.org/pypi/hypernotes/) []()\n\nhypernotes is a lightweight Python package for taking notes on your machine learning experiments. It provides a simple way to store hyperparameters, their corresponding evaluation metrics, as well as additional information and retrieve them again later for analyzing. It is written in pure Python and requires no additional dependencies.\n\n# Table of contents \n- [Installation](#installation)\n- [Basic Usage](#basic-usage)\n - [Create note and add to store](#create-note-and-add-to-store)\n - [Load notes](#load-notes)\n - [Update notes](#update-notes)\n - [Remove notes](#remove-notes)\n - [Create note from another one](#create-note-from-another-one)\n- [Bonus](#bonus)\n - [View content of a store in your browser](#view-content-of-a-store-in-your-browser)\n - [Store additional objects](#store-additional-objects)\n- [Alternatives](#alternatives)\n- [Development](#development)\n\n[Changelog for this package](CHANGELOG.md)\n\n# Installation\n```bash\npip install hypernotes\n```\n\nPython 3.6+ is required\n\n# Basic Usage\nhypernotes implements a *Note* and a *Store* class. A *Note* is a small wrapper around Python dictionaries. This means that you can do everything with it, that you could do with a normal dictionary, but in addition, it stores:\n\n* the path to your Python executable,\n* information about the current state of your Git repository (if there is one) such as the last commit, current branch, etc.,\n* start (upon initialization) and end datetime (call note.end() or add to store)\n\nand it provides:\n\n* a useful default dictionary structure\n* access to all initial dictionary keys as attributes for better auto-completion support and readability (for example `note.parameters`, `note.features`)\n\nIf you print a note, you can see what's inside. A note right after initialization looks like this:\n```python\nNote(content={'text': '',\n 'model': None,\n 'parameters': {},\n 'features': {'identifier': [],\n 'binary': [],\n 'categorical': [],\n 'numerical': []},\n 'target': None,\n 'metrics': {},\n 'info': {},\n 'start_datetime': datetime.datetime(2019, 5, 21, 11, 3, 20),\n 'end_datetime': None,\n 'identifier': '3228fe02-d1c8-4251-8b35-bb8ae3d5f227',\n 'python_path': 'C:/example_path/python.exe',\n 'git': {'repo_name': 'C:/path_to_your_repo',\n 'branch': 'master',\n 'commit': '6bbdf31'}}\n```\n\nThe notes are then saved with a *Store* instance, which uses a json file. Due to this, you should only add [json-serializable objects](https://docs.python.org/3/library/json.html#py-to-json-table) + *datetime.datetime* instances to a *Note*.\n\nA note is uniquely identifiable by its `identifier` attribute.\n\n## Create note and add to store\n```python\nfrom hypernotes import Note, Store\n\nnote = Note(\"Some descriptive text about your experiment\")\n\n# Add name of used algorithm\nnote.model = \"randomforest\"\n\n# Add hyperparameters about model training, preprocessing, etc.\nnote.parameters[\"num_estimators\"] = 100\nnote.parameters[\"impute_missings\"] = True\n\n# Add the names of the features and of the target variable\nnote.features[\"identifier\"] = [\"id\"]\nnote.features[\"binary\"] = [\"bool1\"]\nnote.features[\"categorical\"] = [\"cat1\", \"cat2\"]\nnote.features[\"numerical\"] = [\"num1\"]\nnote.target = \"target\"\n\n# Some additional information\nnote.info[\"important_stuff\"] = \"something noteworthy\"\n\n# ... Rest of your code ...\n# train_recall, train_precision test_recall, test_precision = train_and_evaluate_model(\n# parameters=note.params,\n# feature_names=note.features,\n# target_name=note.target)\n# ...\n\n# Add your calculated evaluation metrics\nnote.metrics[\"train\"] = {\"recall\": train_recall, \"precision\": train_precision}\nnote.metrics[\"test\"] = {\"recall\": test_recall, \"precision\": test_precision}\n\nstore = Store(\"hyperstore.json\")\nstore.add(note)\n```\n\n## Load notes\nA Store instance provides the `load` method, which can be used to retrieve the whole store. By default it returns a sorted list (most recent note first).\n```python\nnotes = store.load()\nmost_recent_note = notes[0]\n```\n\nIf you have [pandas](https://github.com/pandas-dev/pandas) installed, you can use the `return_dataframe` argument to return a pandas dataframe.\n```python\nnotes_df = store.load(return_dataframe=True)\nnotes_df.head()\n```\nExample of a returned pandas dataframe:\n
| \n | start_datetime | \nend_datetime | \ntext | \nmodel | \nidentifier | \nmetrics.test.precision | \nmetrics.test.recall | \nmetrics.train.precision | \nmetrics.train.recall | \nparameters.min_sample_split | \nparameters.num_estimators | \nparameters.sample_weight | \nfeatures.binary | \nfeatures.categorical | \nfeatures.identifier | \nfeatures.numerical | \ntarget | \ngit.branch | \ngit.commit | \ngit.repo_name | \ninfo.important_stuff | \npython_path | \n
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n2019-05-21 16:44:48 | \n2019-05-21 17:05:21 | \nAnother useful description | \nrandomforest | \n0f84217d-e01b-466d-9a73-001827c60584 | \n0.29 | \n0.29 | \n0.40 | \n0.50 | \n7 | \n150 | \nNone | \n[bool1] | \n[cat1, cat2] | \n[id] | \n[num1] | \ntarget | \nmaster | \n5e098ab | \nC:/path_to_your_repo | \nsomething noteworthy | \nC:/example_path/python.exe | \n
| 1 | \n2019-05-21 16:12:53 | \n2019-05-21 16:30:16 | \nUseful description | \nrandomforest | \ndd8bbc32-ff8f-433d-9eec-a24a7859622f | \n0.82 | \n0.29 | \n0.91 | \n0.98 | \n7 | \n100 | \nbalanced | \n[bool1] | \n[cat1, cat2] | \n[id] | \n[num1] | \ntarget | \nmaster | \n5e098ab | \nC:/path_to_your_repo | \nsomething noteworthy | \nC:/example_path/python.exe | \n