{ "info": { "author": "Adam Jones", "author_email": "ajones173@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6" ], "description": "# pymoth\n\n[![Build Status](https://travis-ci.org/meccaLeccaHi/pymoth.svg?branch=master)](https://travis-ci.org/meccaLeccaHi/pymoth)\n[![Documentation Status](https://readthedocs.org/projects/pymoth/badge/?version=latest)](https://pymoth.readthedocs.io/?badge=latest)\n[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)\n\nThis package contains a Python version of [MothNet](https://github.com/charlesDelahunt/PuttingABugInML)\n\n\n\nNeural network modeled after the olfactory system of the hawkmoth, _Manduca sexta_ (shown above).\n> This repository contains a Python version of the code used in:\n> - [\"Putting a bug in ML: The moth olfactory network learns to read MNIST\"](https://doi.org/10.1016/j.neunet.2019.05.012), _Neural Networks_ 2019\n\n---\n[Docs (via Sphinx)](https://pymoth.readthedocs.io/)\n---\n\n## Installation\nBuilt for use with Mac/Linux systems - not tested in Windows.\n- Requires Python 3.6+\n\n### Via `pip`\n```console\npip install mothnet\n```\n\n### From source\nFirst, clone this repo and `cd` into it. Then run:\n```console\n# Install dependencies: \npip install -r pymoth/docs/requirements.txt\n# Run sample experiment:\npython pymoth/examples.py\n```\n\n#### Dependencies (also see [`requirements.txt`](./docs/requirements.txt))\n- [scipy](https://www.scipy.org/)\n- [matplotlib](https://matplotlib.org/)\n- [scikit-learn](https://scikit-learn.org/)(for kNN and SVM models)\n- [pillow](https://pillow.readthedocs.io/en/stable/)\n- [keras](https://keras.io/) (for loading MNIST)\n- [tensorflow](https://www.tensorflow.org/) (_also_ for loading MNIST)\n\n---\n\n### Example experiment (also see [`examples.py`](examples.py))\n```python\n\nimport os\nimport pymoth\n\ndef experiment():\n\n # instantiate the MothNet object\n mothra = pymoth.MothNet({\n 'screen_size': (1920, 1080), # screen size (width, height)\n 'num_runs': 1, # how many runs you wish to do with this moth\n 'goal': 15, # defines the moth's learning rates\n 'tr_per_class': 1, # (try 3) the number of training samples per class\n 'num_sniffs': 1, # (try 2) number of exposures each training sample\n 'num_neighbors': 1, # optimization param for nearest neighbors\n 'box_constraint': 1e1, # optimization parameter for svm\n 'n_thumbnails': 1, # show N experiment inputs from each class\n 'show_acc_plots': True, # True to plot, False to ignore\n 'show_time_plots': True, # True to plot, False to ignore\n 'show_roc_plots': True, # True to plot, False to ignore\n 'results_folder': 'results', # string\n 'results_filename': 'results', # will get the run number appended to it\n 'data_folder': 'MNIST_all', # string\n 'data_filename': 'MNIST_all', # string\n })\n\n # loop through the number of simulations specified:\n for run in range(mothra.NUM_RUNS):\n\n # generate dataset\n feature_array = mothra.load_mnist()\n train_X, test_X, train_y, test_y = mothra.train_test_split(feature_array)\n\n # load parameters\n mothra.load_moth() # define moth model parameters\n mothra.load_exp() # define parameters of a time-evolution experiment\n\n # run simulation (SDE time-step evolution)\n sim_results = mothra.simulate(feature_array)\n # future: mothra.fit(X_train, y_train)\n\n # collect response statistics:\n # process the sim results to group EN responses by class and time\n EN_resp_trained = mothra.collect_stats(sim_results, mothra.experiment_params,\n mothra._class_labels, mothra.SHOW_TIME_PLOTS, mothra.SHOW_ACC_PLOTS,\n images_filename=mothra.RESULTS_FILENAME, images_folder=mothra.RESULTS_FOLDER,\n screen_size=mothra.SCREEN_SIZE)\n\n # reveal scores\n # score MothNet\n mothra.score_moth_on_MNIST(EN_resp_trained)\n # score KNN\n mothra.score_knn(train_X, train_y, test_X, test_y)\n # score SVM\n mothra.score_svm(train_X, train_y, test_X, test_y)\n\n # plot each model in a subplot of a single figure\n if mothra.SHOW_ROC_PLOTS:\n mothra.show_multi_roc(['MothNet', 'SVM', 'KNN'], mothra._class_labels,\n images_filename=mothra.RESULTS_FOLDER+os.sep+mothra.RESULTS_FILENAME+'_ROC_multi')\n```\n\n### Sample results\n\n\n### Dataset\n[MNIST Data](http://yann.lecun.com/exdb/mnist/)\n\n### Modules\n- [*classify.py*](./pymoth/modules/classify.py) Classify output from MothNet model.\n- [*generate.py*](./pymoth/modules/generate.py) Download (if absent) and prepare down-sampled MNIST dataset.\n- [*params.py*](./pymoth/modules/params.py) Experiment and model parameters.\n- [*sde.py*](./pymoth/modules/sde.py) Run stochastic differential equation simulation.\n- [*show_figs.py*](./pymoth/modules/show_figs.py) Figure generation module.\n- [*MNIST_make_all.py*](./pymoth/MNIST_all/MNIST_make_all.py) Downloads and saves MNIST data to .npy file.\n\n---\n\nQuestions, comments, criticisms? Feel free to drop us an [e-mail](\n mailto:ajones173@gmail.com?subject=pymoth)!\n\n\nBug reports, suggestions, or requests are also welcome! Feel free to [create an issue](\n https://github.com/meccaLeccaHi/pymoth/issues/new). \n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/meccaLeccaHi/pymoth", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "mothnet", "package_url": "https://pypi.org/project/mothnet/", "platform": "", "project_url": "https://pypi.org/project/mothnet/", "project_urls": { "Homepage": "https://github.com/meccaLeccaHi/pymoth" }, "release_url": "https://pypi.org/project/mothnet/0.0.5/", "requires_dist": [ "matplotlib", "scikit-learn", "scikit-image", "pillow", "keras", "tensorflow" ], "requires_python": "", "summary": "Neural network modeled after the olfactory system of the hawkmoth.", "version": "0.0.5" }, "last_serial": 5689851, "releases": { "0.0.5": [ { "comment_text": "", "digests": { "md5": "e49c288f8d57723d4874bbca817c9405", "sha256": "29430ceb75d6a3852ee8efa5f65432d8975980946d3794a8dd07cd19f3935b66" }, "downloads": -1, "filename": "mothnet-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "e49c288f8d57723d4874bbca817c9405", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 49773, "upload_time": "2019-08-16T21:32:27", "url": "https://files.pythonhosted.org/packages/d5/e3/39593fadd0ea2ccff1c36b3eb300db8e65d26b71b108d4ad0b5f230ce607/mothnet-0.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a32f5732082257a4c19cb104a6ed2c24", "sha256": "afefec33fdff9d13a74538c7fc70bb1b89df4a7c36083e23ef950ca215d8f6e4" }, "downloads": -1, "filename": "mothnet-0.0.5.tar.gz", "has_sig": false, "md5_digest": "a32f5732082257a4c19cb104a6ed2c24", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 44435, "upload_time": "2019-08-16T21:32:28", "url": "https://files.pythonhosted.org/packages/57/9c/0f25210d2189391c4a246e6fb0fc2ffee7b8723fd091d9290da9e2a80900/mothnet-0.0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e49c288f8d57723d4874bbca817c9405", "sha256": "29430ceb75d6a3852ee8efa5f65432d8975980946d3794a8dd07cd19f3935b66" }, "downloads": -1, "filename": "mothnet-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "e49c288f8d57723d4874bbca817c9405", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 49773, "upload_time": "2019-08-16T21:32:27", "url": "https://files.pythonhosted.org/packages/d5/e3/39593fadd0ea2ccff1c36b3eb300db8e65d26b71b108d4ad0b5f230ce607/mothnet-0.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a32f5732082257a4c19cb104a6ed2c24", "sha256": "afefec33fdff9d13a74538c7fc70bb1b89df4a7c36083e23ef950ca215d8f6e4" }, "downloads": -1, "filename": "mothnet-0.0.5.tar.gz", "has_sig": false, "md5_digest": "a32f5732082257a4c19cb104a6ed2c24", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 44435, "upload_time": "2019-08-16T21:32:28", "url": "https://files.pythonhosted.org/packages/57/9c/0f25210d2189391c4a246e6fb0fc2ffee7b8723fd091d9290da9e2a80900/mothnet-0.0.5.tar.gz" } ] }