{ "info": { "author": "Simon Frid", "author_email": "simon.frid@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.9", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Scientific/Engineering :: Artificial Intelligence", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Version Control" ], "description": ".. image:: https://travis-ci.org/fridiculous/django-estimators.svg?branch=master\n :target: https://travis-ci.org/fridiculous/django-estimators\n\n.. image:: https://coveralls.io/repos/github/fridiculous/django-estimators/badge.svg?branch=master\n :target: https://coveralls.io/github/fridiculous/django-estimators?branch=master\n\n.. image:: https://landscape.io/github/fridiculous/django-estimators/master/landscape.svg?style=flat\n :target: https://landscape.io/github/fridiculous/django-estimators/master\n\n\nDjango-Estimators\n=================\n\nTidy Persistence and Retrieval for Machine Learning\n\n\nIntro\n-----\nDjango-Estimators helps persist and track machine learning models (aka estimators) and datasets.\n\n\nThis library provides a series of proxy objects that wrap common python machine learning objects and dataset objects. As a result, this library can be used to version, track progress and deploy models. It's highly extensible and can be used with almost any python object (scikit-learn, numpy arrays, modules, methods).\n\nThis repo utilizes django as an ORM. If you'd like to work outside of django, try the sqlalchemy-based `estimators `_ library instead.\n\n\nInstallation\n------------\n\n\nDjango-estimators is on PyPI, so just run: ::\n\n pip install django-estimators\n\n\nQuick start\n-----------\n\n1. Add \"estimators\" to your INSTALLED_APPS django setting like this\n::\n\n INSTALLED_APPS = [\n ...\n 'estimators',\n ]\n\n2. To create the estimators table, run\n::\n\n python manage.py migrate\n\n3. Run ``python manage.py shell`` and get create new models like so\n::\n\n from sklearn.ensemble import RandomForestClassifier\n rfc = RandomForestClassifier()\n\n from estimators.models import Estimator\n est = Estimator(estimator=rfc)\n est.description = 'a simple forest'\n est.save()\n\n4. Retrieve your model, using the classic django orm, we can pull the last Estimator \n::\n\n est = Estimator.objects.last()\n # now use your estimator\n est.estimator.predict(X)\n\n\nUse Case: Retrieving Models/Estimators\n--------------------------------------\n\nIf you aren't sure if it exists, the recommended method is to use the `get_or_create` method\n::\n\n est = Estimator.objects.get_or_create(estimator=object)\n # or potentially update it with update_or_create\n est = Estimator.objects.update_or_create(estimator=object)\n\nIf you already have the model, in this case of type object\n::\n\n est = Estimator.objects.filter(estimator=object).first()\n\nIf you know the unique hash of the model\n::\n\n est = Estimator.objects.filter(object_hash='d9c9f286391652b89978a6961b52b674').first()\n\n\n\nUse Case: Persisting and Retrieving DataSets\n--------------------------------------------\n\nThe `DataSet` class functions just like the `Estimator` class. If you have\na numpy matrix or a pandas dataframe, you can wrap it with a DataSet object\n::\n\n import numpy as np\n import pandas as pd\n\n df = pd.DataFrame(np.random.randint(0,10,(100,8)))\n\n from estimators.models import DataSet\n\n ds = DataSet(data=df)\n ds.save()\n\nYou can pull that same DataSet object later with\n::\n\n ds = DataSet.objects.latest('create_date')\n\nAnd if you already have the dataset\n::\n\n ds = DataSet.objects.filter(data=df).first()\n\n\nUse Case: Persisting Predictions and Results \n--------------------------------------------\n\nSometimes the most valuable part of a machine learning is the whole process.\nUsing an ``Evaluator`` object, we can define the relationships between X_test, y_test and\ny_predicted ahead of time.\n\nThen we can evaluate the evaluation plan, which in turn calls the ``predict`` method on the estimator\nand then presists all the wrapped objects.\n\nHere's a demo of using an Evaluator.\n::\n\n from sklearn.datasets import load_digits\n from sklearn.ensemble import RandomForestClassifier\n\n digits = load_digits() # 1797 by 64\n X = digits.data\n y = digits.target\n\n # simple splitting for validation testing\n X_train, X_test = X[:1200], X[1200:]\n y_train, y_test = y[:1200], y[1200:]\n\n rfc = RandomForestClassifier()\n rfc.fit(X_train, y_train)\n\nNow create your evaluation plan\n::\n\n from estimators.models import Evaluator\n plan = Evaluator(X_test=X_test, y_test=y_test, estimator=rfc)\n\n result = plan.evaluate() # executes `predict` method on X_test\n\nAnd you can view all the atributes on the evaluation result\n::\n\n result.estimator\n result.X_test\n result.y_test # optional, used with supervised classifiers\n result.y_predicted\n\n\nUsing with Jupyter Notebook (or without a django app)\n-----------------------------------------------------\n\nDjango-Estimators can run as a standalone django app.In order to have access to the django db, you'll need to set up the environment variable to load up your django project. In ipython, by default you can set the environment variable ``DJANGO_SETTINGS_MODULE`` to ``estimators.template_settings`` like so\n::\n\n import os\n import django\n os.environ['DJANGO_SETTINGS_MODULE'] = \"estimators.template_settings\"\n django.setup()\n\nIf you're creating a new database (by default it's ``db.sqlite3``). Therefore we need to run migrations, so in python\n::\n\n from django.core.management import call_command\n call_command('migrate')\n\n\nNow you can continue you as usual... ::\n\n from estimators.models import Estimator\n\n\nTo use your own custom settings, make a copy of the ``estimators.template_settings`` and edit the fields. Like above, run ``os.environ['DJANGO_SETTINGS_MODULE'] = \"custom_settings_file\"`` before running ``django.setup()``.\n\n\nDevelopment Installation \n------------------------\n\nTo install the latest version of django-estimators, clone the repo, change directory to the repo, and pip install it into your current virtual environment.::\n\n $ git clone git@github.com:fridiculous/django-estimators.git\n $ cd django-estimators\n $ \n (virtualenv) $ pip install -e . # the dot specifies for this current repo", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/fridiculous/django-estimators", "keywords": "scikit-learn,sklearn,machine learning,artificial intelligence,ml,ai,estimators,version,versioning,benchmark,persist,storage,track,models,repository,evaluation,workflow", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "django-estimators", "package_url": "https://pypi.org/project/django-estimators/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-estimators/", "project_urls": { "Homepage": "https://github.com/fridiculous/django-estimators" }, "release_url": "https://pypi.org/project/django-estimators/0.2.1/", "requires_dist": [ "dill (==0.2.5)" ], "requires_python": "", "summary": "A django model to persist and track machine learning models", "version": "0.2.1" }, "last_serial": 2495258, "releases": { "0.1.0.dev0": [ { "comment_text": "", "digests": { "md5": "a3018ae4b19242543c49e102b9323641", "sha256": "aa8ae3e32dafb9d8c35cd5874b1f58a22c9f14be11811a6a85f4991a3c2075da" }, "downloads": -1, "filename": "django_estimators-0.1.0.dev0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a3018ae4b19242543c49e102b9323641", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12344, "upload_time": "2016-09-16T01:16:00", "url": "https://files.pythonhosted.org/packages/55/72/65dc68cdee3555482ac02418b4faa50409aa7eb895252583e110165760e5/django_estimators-0.1.0.dev0-py2.py3-none-any.whl" } ], "0.2.0": [], "0.2.1": [ { "comment_text": "", "digests": { "md5": "f968830124682787e9f0b8199acff674", "sha256": "ef815e906fb420c83b9d45c49ad2e459590e7f7f6404151c21033a123495abfb" }, "downloads": -1, "filename": "django_estimators-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f968830124682787e9f0b8199acff674", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 20077, "upload_time": "2016-12-02T06:02:41", "url": "https://files.pythonhosted.org/packages/a3/b2/012305703e2ad1736a44c47c4d9fe7fd722baed41c77bfd0636b12cf42e3/django_estimators-0.2.1-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f968830124682787e9f0b8199acff674", "sha256": "ef815e906fb420c83b9d45c49ad2e459590e7f7f6404151c21033a123495abfb" }, "downloads": -1, "filename": "django_estimators-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f968830124682787e9f0b8199acff674", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 20077, "upload_time": "2016-12-02T06:02:41", "url": "https://files.pythonhosted.org/packages/a3/b2/012305703e2ad1736a44c47c4d9fe7fd722baed41c77bfd0636b12cf42e3/django_estimators-0.2.1-py2.py3-none-any.whl" } ] }