Skip to main content

End-to-end machine learning on your desktop or server.

Project description

PyDataSci (wide)


Mission

  • Automated
    AIdb is an autoML tool that keeps track of the moving parts of machine learning (model tuning, feature selection, dataset splitting, and cross validation) so that data scientists can perform best practice ML without the coding overhead.

  • Local-first
    We empower non-cloud users (academic/ institute HPCs, private cloud companies, desktop hackers, or even remote server SSH'ers) with the same quality ML services as present in public clouds (e.g. SageMaker).

  • Integrated
    We don’t force your entire workflow into the confines of a GUI app or specific IDE because we integrate with your existing code.

  • Reproducible
    No more black boxes. Every row and column of every fold in every hypertuning training session is accounted for.

Functionality:

  • Calculates and saves model metrics in a local SQLite file.
  • Visually compare model metrics to find the best model.
  • Queue for hypertuning jobs and batches.
  • Treats cross-validated splits (k-fold) and validation sets (3rd split) as first-level citizens.
  • Feature engineering to select the most informative columns.
  • If you need to scale (data size, training time) just switch to cloud_queue = True.

Installation:

Requires Python 3+. You will only need to perform these steps the first time you use the package.

Enter the following commands one-by-one and follow any instructions returned by the command prompt to resolve errors should they arise.

Starting from the command line:

$ pip install --upgrade pydatasci
$ python

Once inside the Python shell:

>>> import pydatasci as pds
>>> pds.create_folder()
>>> pds.create_config()
>>> from pydatasci import aidb
>>> aidb.create_db()

PyDataSci makes use of the Python package, appdirs, for an operating system (OS) agnostic location to store configuration and database files. This not only keeps your $HOME directory clean, but also helps prevent careless users from deleting your database.

The installation process checks not only that the corresponding appdirs folder exists on your system but also that you have the permissions neceessary to read from and write to that location. If these conditions are not met, then you will be provided instructions during the installation about how to create the folder and/ or grant yourself the appropriate permissions.

We have attempted to support both Windows (icacls permissions and backslashes C:\\) as well as POSIX including Mac and Linux (chmod letters permissions and slashes /). Note: due to variations in the ordering of appdirs author and app directories in different OS', we do not make use of the appdirs appauthor directory, only the appname directory.

If you run into trouble with the installation process on your OS, please submit a GitHub issue so that we can attempt to resolve, document, and release a fix as quickly as possible.

Installation Location Based on OS
import appdirs; appdirs.user_data_dir('pydatasci');:

  • Mac:
    /Users/Username/Library/Application Support/pydatasci

  • Linux - Alpine and Ubuntu:
    /root/.local/share/pydatasci

  • Windows:
    C:\Users\Username\AppData\Local\pydatasci

create_db() is equivalent to a migration in Django or Rails in that it creates the tables found in the Object Relational Model (ORM). We use the peewee ORM as it is simpler than SQLAlchemy, has good documentation, and found the project to be actively maintained (saw same-day GitHub response to issues on a Saturday). With the addition of Dash-Plotly, this will make for a full-stack experience that also works directly in an IDE like Jupyter or VS Code.

Deleting & Recreating the Database:

When deleting the database, you need to either reload the aidb module or restart the Python shell before you can attempt to recreate the database.

>>> from pydatasci import aidb
>>> aidb.delete_db(True)
>>> from importlib import reload
>>> reload(aidb)
>>> create_db()

Usage

If you've already completed the Installation section above, let's get started.

import pydatasci as pds
from pydatasci import aidb

1. Add a Dataset.

Supported tabular file formats include: CSV, TSV, Apache Parquet. At this point, the project's support for Parquet is extremely minimal.

The bytes of the file will be stored as a BlobField in the SQLite database file. Storing the data in the database not only (a) provides an entity that we can use to keep track of experiments and link relational data to but also (b) makes the data less mutable than keeping it in the open filesystem.

dataset = aidb.Dataset.create_from_file(
	path = 'iris.tsv'
	,file_format = 'tsv'
	,name = 'tab-separated plants'
	,perform_gzip = True
)

You can choose whether or not you want to gzip compress the file when importing it with the perform_gzip=bool parameter. This compression not only enables you to store up to 90% more data on your local machine, but also helps overcome the maximum BlobField size of 2.147 GB. We handle the zipping and unzipping on the fly for you, so you don't even notice it.

Fetch a Dataset.

Supported in-memory formats include: NumPy Structured Array and Pandas DataFrame.

Pandas

df = dataset.read_to_pandas()
df.head()

df2 = aidb.Dataset.read_to_pandas(id = 1)
df2.head()

NumPy

arr = dataset.read_to_numpy()
arr[:4]

arr2 = aidb.Dataset.read_to_numpy(id = 1)
arr2[:4]

We chose structured array because it keeps track of column names. For the sake of simplicity, we are reading into NumPy via Pandas. That way, if we want to revert to a simpler ndarray in the future, then we won't have to rewrite the function to read NumPy.

2. Create a Label if you want to perform supervised learning (aka predict a specific column).

From a Dataset, pick a column that you want to train against/ predict. If you are planning on training an unsupervised model, then you don't need to do this.

label = aidb.Label.create_from_dataset(
	dataset_id = 1
	,column_name = 'species'
)

3. Derive a Featureset of columns from a Dataset.

This won't duplicate your data. It simply records the columns to be used in training.

a) For supervised learning, be sure to pass in the Label you want to predict.

supervised_bruteforce = aidb.Featureset.create_all_columns(
	dataset_id = 1
	,label_id = 1
)

supervised_selective = aidb.Featureset.create_from_dataset_columns(
	dataset_id = 1
	,label_id = 1
	,columns = ['petal_width', 'petal_length']
)

b) For unsupervised learning (aka studying variance within a Dataset), leave the Label blank.

Feature selection is about finding out which columns in your data are most informative. In performing feature engineering, a data scientist reduces the dimensionality of the data by determining the effect each feature has on the variance of the data. This makes for simpler models in the form of faster training and reduces overfitting by making the model more generalizable to future data.

unsupervised_bruteforce = aidb.Featureset.create_all_columns(
	dataset_id = 1
)

unsupervised_selective = aidb.Featureset.create_from_dataset_columns(
	dataset_id = 1
	,columns = ['petal_width', 'petal_width', 'sepal_length']
)

4. Split the Dataset rows into Splitsets based on how you want to train, test, and validate your models.

a) One set containing train-test splits.

b) One set containing train-validate-test splits.

c) k-fold sets containing train-test splits.

d) k-fold sets containing train-validate-test splits.

5. Create an Algorithm aka model to fit to your splits.

6. Create combinations of Hyperparamsets for your algorithms.

7. Create a Batch of Job's to keep track of training.


PyPI Package

Steps to Build & Upload:

$ pyenv activate pydatasci
$ pip3 install --upgrade wheel twine
$ python3 setup.py sdist bdist_wheel
$ python3 -m twine upload --repository pypi dist/*
$ rm -r build dist pydatasci.egg-info
# proactively update the version number in setup.py next time
$ pip install --upgrade pydatasci; pip install --upgrade pydatasci

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydatasci-0.0.49.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydatasci-0.0.49-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file pydatasci-0.0.49.tar.gz.

File metadata

  • Download URL: pydatasci-0.0.49.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.6

File hashes

Hashes for pydatasci-0.0.49.tar.gz
Algorithm Hash digest
SHA256 9de03f0571ddbc437aad8a7f9a1bd2b62c2d29ff1959aacd4a8c806c68256c9d
MD5 e59187e572abed780dca9d6540511803
BLAKE2b-256 e2cf64ba5e216c95627379ea4cec9e1dff7428140f51e531040ab50805d44ea2

See more details on using hashes here.

File details

Details for the file pydatasci-0.0.49-py3-none-any.whl.

File metadata

  • Download URL: pydatasci-0.0.49-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.6

File hashes

Hashes for pydatasci-0.0.49-py3-none-any.whl
Algorithm Hash digest
SHA256 a45f4d03a814141b50fd17f77daa4257539c4010895a5a81e795f5ccf39e8857
MD5 0c7e9a63dfc6fd525f0e399739f37584
BLAKE2b-256 2547449f2ad54e49f851ac100e0947eb0a7c8213254a8f9227e8d4aa65745dd4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page