{ "info": { "author": "Kapil Sachdeva", "author_email": "not@anemail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "==========\nscikit-nni\n==========\n\n\n.. image:: https://img.shields.io/pypi/v/scikit-nni.svg\n :target: https://pypi.python.org/pypi/scikit-nni\n\n.. image:: https://img.shields.io/travis/ksachdeva/scikit-nni.svg\n :target: https://travis-ci.org/ksachdeva/scikit-nni\n\n.. image:: https://readthedocs.org/projects/scikit-nni/badge/?version=latest\n :target: https://scikit-nni.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n\nHyper parameters search for scikit-learn components using Microsoft NNI\n\n\n* Free software: Apache Software License 2.0\n* Documentation: https://scikit-nni.readthedocs.io.\n\n\nIntroduction\n-------------\n\nMicrosoft NNI (Neural Network Intelligence) is a toolkit to help users run automated machine learning (AutoML) experiments.\nThe tool dispatches and runs trial jobs generated by tuning algorithms to search the best neural architecture and/or hyper-parameters in different environments like local machine, remote servers and cloud.\n\nRead and explore more about Microsoft NNI here - https://github.com/microsoft/nni\n\nscikit-nni is a helper tool (and a package) that :\n\n - generates the configuration (config.yaml & search-space.json) required for NNI\n - automatically builds the scikit-learn pipelines based on your specification and becomes an experiment/trial code for Microsoft NNI to run.\n\nWhat value does this tool add to Microsoft NNI ?\n###################################################\n\nFirst note that this tool is specifically written to only help with scikit-learn pipelines and to tune classification algorithms. In near future,\nI would add the support for regression algorithms as well.\n\nNow when you use Microsoft NNI you need to specify (at minimum) 3 files :\n\n - A search space (json) file that contains the parameters that you want to search/tune.\n\n - Your code/experiment. In your experiment code, you perform these tasks in sequence :\n - Request for the parameters from NNI server\n - Create your model using these parameters\n - Fit your model\n - Score your model\n - Report the score to NNI server.\n\n - a configuration file where you specify the tuner, which mode to use to run, path to your code file and search space file.\n\n`scikit-nni` eliminiates the second step i.e. it builds the scikit pipelines, request NNI server for parameters and also report back the score of your model. It also simplifies (in IMHO) the input\nspecification by only requiring one file instead of 3.\n\nSounds interesting ? Then read the documentation below, install scikit-nni, and more importantly provide feedback if it does not work for you and/or you think it can be improved.\n\nFeatures\n--------\n\n* Hyperparameters search for scikit-learn pipelines using Microsoft NNI\n* No code required to define the pipelines\n* Built-in datasource reader for reading npz files for classification\n* Support for using custom datasource reader\n* Single configuration file to define NNI configuration and search space\n\nI plan to add more datasource readers (e.g. CSV, libSVM format files etc). Contributions are always welcome !\n\nUsage\n-----\n\n.. image:: https://github.com/ksachdeva/scikit-nni/raw/master/images/demo.gif\n\n\nStep 1 - Write a specification file\n###################################\n\nThe specification file is essentially a YAML file but with extension `.nni.yml`\n\nThere are 4 parts (sections) in the configuration file.\n\n******************\nDatasource Section\n******************\n\nThis is where you will specify the (python) callable that `sknni` would be invoking to get the training\nand test dataset.\n\nThe callable **must** return two values where each value is a `tuple` of two items. The first tuple\nconsists of training data `(X_train, y_train)` and the second tuple consists of test data `(X_test, y_test)`.\n\nAn example callable would look like this::\n\n import numpy as np\n\n from sklearn.datasets import load_digits\n from sklearn.model_selection import train_test_split\n\n class ACustomDataSource(object):\n def __init__(self):\n pass\n\n def __call__(self, test_size:float=0.25):\n digits = load_digits()\n X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target, random_state=99, test_size=test_size)\n\n return (X_train, y_train), (X_test, y_test)\n\nIn the above example, the callable generates the train and test dataset. The callable can even have paramaters for e.g. in this\nexample you could optionally pass the fraction of data to be used for testing.\n\nNow let's see how you would add it in the specification file.\n\n.. code-block:: yaml\n\n # Datasource is how you specify which callable\n # sknni will invoke to get the data\n dataSource:\n reader: yourmodule.ACustomDataSource\n params:\n test_size: 0.30\n\nMake sure that during the exeuction of the experiment your datasource (i.e. in this case `yourmodule.ACustomDataSource`)\nis available in the PYTHONPATH.\n\nHere is an additional example showing the usage of a built-in datasource reader\n\n.. code-block:: yaml\n\n dataSource:\n reader: sknni.datasource.NpzClassificationSource\n params:\n dir_path: /Users/ksachdeva/Desktop/Dev/myoss/scikit-nni/examples/data/multiclass-classification\n\n\n`NpzClassificationSource` expects that at `dir_path` you have two folders - train and test. In each folder are the files\nnamed as 0.npz, 1.npz etc. Every file contains that features for that corresponding class.\n\nThe repository contains two such datasources to do binary and multiclass classifications.\n\n**************************\nPipline definition Section\n**************************\n\nBelow is an example of this type of section. You simply specify the list of steps of your scikit-learn Pipeline.\n\nNote - The sequence of steps is very important.\n\nWhat you **MUST** ensure is that the full qualified name of your scikit-learn preprocessors, transformers and\nestimators is correctly specified & spelled. `sknni` uses reflection and introspection to create the instances of these components\nso if you have a typo in the names and/or they are not available in your PYTHONPATH you will get an error at experiment execution time.\n\n.. code-block:: yaml\n\n sklearnPipeline:\n name: normalizer_svc\n steps:\n normalizer:\n type: sklearn.preprocessing.Normalizer\n classArgs:\n norm: l2\n svc:\n type: sklearn.svm.SVC\n\nIn above example, there are 2 steps. The first step is to normalize the data and the second step is train a classifier using Support\nVector Machine.\n\n********************\nSearch Space Section\n********************\n\nThis section corresponds to the search space for your hyperparameters. When you use ```nnictrl``` this is typically\nspecified in search-space.json file.\n\nSee https://nni.readthedocs.io/en/latest/Tutorial/SearchSpaceSpec.html to learn more about the search space syntax.\n\nHere are the important things to note about this section -\n\n- The syntax is the same (except we are using YAML here instead of JSON) for specifiying parameter types and ranges.\n- You **MUST** specifiy the parameters corresponding to the step in your scikit pipeline.\n- You **MUST** use the names of the parameters that are **same as** the ones accepted by the constructors of scikit-learn components (i.e. preprocessors, estimators etc).\n\n\nBelow is an example of this type of section.\n\n.. code-block:: yaml\n\n nniConfigSearchSpace:\n - normalizer:\n norm:\n _type: choice\n _value: [l2, l1]\n - svc:\n C:\n _type: uniform\n _value: [0.1,0.0]\n kernel:\n _type: choice\n _value: [linear,rbf,poly,sigmoid]\n degree:\n _type: choice\n _value: [1,2,3,4]\n gamma:\n _type: uniform\n _value: [0.01,0.1]\n coef0:\n _type: uniform\n _value: [0.01,0.1]\n\nNote that `sklearn.svm.SVC` takes C, kernel, degree, gamman and coef0 is the paramaters and hence we have used here\nthe same names (keys) in the search space specification. You can add as many or as little parameters to search for.\n\n******************\nNNI Config Section\n******************\n\nThis is the simplest of all sections as there is nothing new here from sknni perspective. You just copy-paste\nhere your NNI's config.yaml here. You do not have to specify `codedir` and `command` field in the `trial` subsection as\nthis is added by the sknni in the generated configuration files.\n\nSee https://nni.readthedocs.io/en/latest/Tutorial/ExperimentConfig.html\n\nHere is an example of this type of section.\n\n.. code-block:: yaml\n\n # This is exactly same as the one that of NNI\n # except that you do not have to specify the command\n # and code fields. They are automatically added by the sknni generator\n nniConfig:\n authorName: default\n experimentName: example_sklearn-classification\n trialConcurrency: 1\n maxExecDuration: 1h\n maxTrialNum: 100\n trainingServicePlatform: local\n useAnnotation: false\n tuner:\n builtinTunerName: TPE\n classArgs:\n optimize_mode: maximize\n trial:\n gpuNum: 0\n\nYou can look at the various examples in the repository to learn how to define your own specification file.\n\nStep 2 - Generate your experiment\n#################################\n\n.. code-block:: bash\n\n sknni generate-experiment --spec example/basic_svc.nni.yml --output-dir experiments\n\n\nAbove command will create a directory experiments/svc-classification with the following files\n\n - The original specification file i.e. basic_svc.nni.yml (used during experiment run as well)\n - Generated Microsoft NNI's config.yml\n - Generated Microsoft NNI's search-space.json\n\nNote - there is no python file as typically shown in the examples of Microsoft NNI as the command\nin ends up invoking `sknni` entry point when the experiment is run.\n\nStep 3 - Run your experiment\n#################################\n\nThis is same as running `nnitctl`\n\n.. code-block:: bash\n\n nnictl create --config experiments/svc-classification/config.yml\n\n\nTroubleshooting\n---------------\n\nMy trials are failing what is wrong ?\n#####################################\n\nYour trial could fail for many reasons -\n\n* Bug in your DataSource code resulting the exception/error\n\n* Wrong inputs to your (or built-in) DataSources resulting in exception/error\n\n* Your DataSource (python callable) could not be found\n\nHere is what I would recommend -\n\n* Test your DataSource code\n\n* The webui does not always display all the errors/logs so look at the log of your trials and more specifically stderr file\n\n .. code-block:: bash\n\n cat $HOME/nni/experiments//trials//stderr\n\n cat $HOME/nni/experiments//trials//trial.log\n\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n=======\nHistory\n=======\n\n0.1.1 (2019-10-20)\n------------------\n\n* First release on PyPI.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ksachdeva/scikit-nni", "keywords": "sknni,scikit-nni", "license": "Apache Software License 2.0", "maintainer": "", "maintainer_email": "", "name": "scikit-nni", "package_url": "https://pypi.org/project/scikit-nni/", "platform": "", "project_url": "https://pypi.org/project/scikit-nni/", "project_urls": { "Homepage": "https://github.com/ksachdeva/scikit-nni" }, "release_url": "https://pypi.org/project/scikit-nni/0.2.1/", "requires_dist": [ "Click (>=7.0)", "scikit-learn", "nni", "pymongo", "absl-py", "pyyaml" ], "requires_python": ">=3.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "summary": "Hyper parameters search for scikit-learn components using Microsoft NNI", "version": "0.2.1", "yanked": false, "yanked_reason": null }, "last_serial": 6009360, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "8663acdc2e67ee326a358e9d1e72e5fa", "sha256": "d1c2ca5ddc8420f2911387f15d8f96aa9aaff23fe3a88ad89e1d4c8226a1a048" }, "downloads": -1, "filename": "scikit_nni-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8663acdc2e67ee326a358e9d1e72e5fa", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 9759, "upload_time": "2019-10-20T22:07:10", "upload_time_iso_8601": "2019-10-20T22:07:10.513925Z", "url": "https://files.pythonhosted.org/packages/2c/7c/192a4cc0c102ba0532b16f66279dd957576896da7a8b8ef708e25a1bf29c/scikit_nni-0.1.1-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "67a19ac43f21a220df41b12f6f5ae099", "sha256": "408fe1faa1c8c718a4beab9edbab14620dcd0f57e7ef1f13d34282e9762f906b" }, "downloads": -1, "filename": "scikit-nni-0.1.1.tar.gz", "has_sig": false, "md5_digest": "67a19ac43f21a220df41b12f6f5ae099", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 15722, "upload_time": "2019-10-20T22:07:13", "upload_time_iso_8601": "2019-10-20T22:07:13.203728Z", "url": "https://files.pythonhosted.org/packages/76/00/8041c3f83650da3f43e1aba40d118ade1aca48ea17eb750a80db17b36a87/scikit-nni-0.1.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "7e116f38aeddb7a4e752bc96266b3666", "sha256": "6b474697823867b47b7c471888982efcc6bba213c8ba09df5ccd9f8f8d586283" }, "downloads": -1, "filename": "scikit_nni-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7e116f38aeddb7a4e752bc96266b3666", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 11104, "upload_time": "2019-10-21T21:09:36", "upload_time_iso_8601": "2019-10-21T21:09:36.894255Z", "url": "https://files.pythonhosted.org/packages/07/75/ddb13db7b23707a580407aa17929e003cd8c3f7adc905e3d5bb5dc8dfa4e/scikit_nni-0.2.1-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "ec9e77e85c5758b192339dc246b31610", "sha256": "133f36f58b73bcae0a6ee0ab932a4001927cd3f5aab55659c0276e853bbe8a36" }, "downloads": -1, "filename": "scikit-nni-0.2.1.tar.gz", "has_sig": false, "md5_digest": "ec9e77e85c5758b192339dc246b31610", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 18353, "upload_time": "2019-10-21T21:09:39", "upload_time_iso_8601": "2019-10-21T21:09:39.050929Z", "url": "https://files.pythonhosted.org/packages/24/b2/7fa0a36c4d9623403182bb701ec94c44be866c68d5ddcb17762bf779fcb5/scikit-nni-0.2.1.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7e116f38aeddb7a4e752bc96266b3666", "sha256": "6b474697823867b47b7c471888982efcc6bba213c8ba09df5ccd9f8f8d586283" }, "downloads": -1, "filename": "scikit_nni-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7e116f38aeddb7a4e752bc96266b3666", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 11104, "upload_time": "2019-10-21T21:09:36", "upload_time_iso_8601": "2019-10-21T21:09:36.894255Z", "url": "https://files.pythonhosted.org/packages/07/75/ddb13db7b23707a580407aa17929e003cd8c3f7adc905e3d5bb5dc8dfa4e/scikit_nni-0.2.1-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "ec9e77e85c5758b192339dc246b31610", "sha256": "133f36f58b73bcae0a6ee0ab932a4001927cd3f5aab55659c0276e853bbe8a36" }, "downloads": -1, "filename": "scikit-nni-0.2.1.tar.gz", "has_sig": false, "md5_digest": "ec9e77e85c5758b192339dc246b31610", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 18353, "upload_time": "2019-10-21T21:09:39", "upload_time_iso_8601": "2019-10-21T21:09:39.050929Z", "url": "https://files.pythonhosted.org/packages/24/b2/7fa0a36c4d9623403182bb701ec94c44be866c68d5ddcb17762bf779fcb5/scikit-nni-0.2.1.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }