Skip to main content

Machine learning in one line of code

Project description

traintool

Train off-the-shelf machine learning models with one line of code

DocumentationGithubContact

build docs codecov Code style: black


traintool is a Python library for applied machine learning. It allows you to train off-the-shelf models with minimum code: You just give your data and say which model you want to train, and traintool takes care of the rest. It has pre-implemented models for most major use cases, works with different data formats and follows best practices for experiment tracking and deployment.

Alpha Release: Note that traintool is in an early alpha release. The API can and will change without notice. If you find a bug, please file an issue on Github or write me.

Installation

pip install git+https://github.com/jrieke/traintool

Is traintool for you?

YES if you...

  • need to solve standard ML tasks with standard, off-the-shelf models
  • prefer 98 % accuracy with one line of code over 98.1 % with 1000 lines
  • want to compare different model types (e.g. deep network vs. SVM)
  • care about experiment tracking & deployment

NO if you...

  • need to customize every aspect of your model, e.g. in basic research
  • want to chase state of the art

Features

  • Minimum coding — traintool is designed from the ground up to require as few lines of code as possible. It offers a sleek and intuitive interface that gets you started in seconds. Training a model just takes a single line:

    traintool.train("resnet18", train_data, test_data)
    
  • Pre-implemented models — traintool offers fully implemented and tested models – from simple classifiers to deep neural networks. The alpha version supports image classification only but we will add more models soon. Here are only a few of the models you can use:

    "svm", "random-forest", "alexnet", "resnet50", "inception_v3", ...
    
  • Easy, yet fully customizable — You can customize every aspect of the model training and hyperparameters. Simply pass along a config dictionary:

    traintool.train(..., config={"optimizer": "adam", "lr": 0.1})
    
  • Automatic experiment tracking — traintool automatically calculates metrics and stores them – without requiring you to write any code. You can visualize the results with tensorboard or stream directly to comet.ml.

  • Automatic saving and checkpoints — traintool automatically stores model checkpoints, logs, and experiment information in an intuitive directory structure. No more worrying about where you've put that one good experiment or which configuration it had.

  • Works with multiple data formats — traintool understands numpy arrays, pytorch datasets, or files and automatically converts them to the correct format for the model you train.

  • Instant deployment — You can deploy your model with one line of code to a REST API that you can query from anywhere. Just call:

    model.deploy()
    
  • Built on popular ML libraries — Under the hood, traintool uses common open-source frameworks like pytorch, tensorflow, and scikit-learn. You can always access the raw models from these frameworks if you want to do more complex analysis:

    torch_model = model.raw()["model"]
    

Example: Image classification on MNIST

import mnist
import traintool

# Load MNIST data as numpy arrays (also works with torch/tensorflow datasets, files, ...)
train_data = [mnist.train_images(), mnist.train_labels()]
test_data = [mnist.test_images(), mnist.test_labels()]

# Train SVM
svm = traintool.train("svm", train_data=train_data, test_data=test_data)

# Train ResNet with custom hyperparameters & track metrics to tensorboard
config = {"lr": 0.1, "optimizer": "adam"}
resnet = traintool.train("resnet", train_data=train_data, test_data=test_data, 
                         config=config, tensorboard=True)

# Make prediction
result = resnet.predict(test_data[0][0])
print(result["predicted_class"])

# Deploy to REST API (with fastapi)
resnet.deploy()

# Get underlying pytorch model (e.g. for custom analysis)
pytorch_model = resnet.raw()["model"]

Interested? Have a look at the tutorial or check out available models.

Get in touch!

You have a question on traintool, want to use it in production, or miss a feature? I'm happy to hear from you! Write me at johannes.rieke@gmail.com.

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

traintool-0.0.1.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

traintool-0.0.1-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file traintool-0.0.1.tar.gz.

File metadata

  • Download URL: traintool-0.0.1.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.6

File hashes

Hashes for traintool-0.0.1.tar.gz
Algorithm Hash digest
SHA256 41931a32ff9c3dae1f553ed47d059b03ff559f877ff3261bc1972e34eae2a3df
MD5 51045a67772f27a21bb942d9e827f16a
BLAKE2b-256 5a81123bd40c0e17184e80149e9616b8dcb54a8a27cf529e64f4bf255e053abf

See more details on using hashes here.

File details

Details for the file traintool-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: traintool-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.6

File hashes

Hashes for traintool-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 99ae3c8eb4abfe170c5096160c87c6a203ed2c2c8b53a3e381c5570f8bff18f8
MD5 142caf28ded398828bbd3828249abb1f
BLAKE2b-256 d398dd829d512506618d09e9a3dcafa6cea35e3b2126046c3fc8361519e0962c

See more details on using hashes here.

Supported by

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