Skip to main content

Trane is a software package for automatically generating prediction problems and generating labels for supervised learning.

Project description


Trane is a software package for automatically generating prediction problems and generating labels for supervised learning. Trane is a system designed to advance the automation of the machine learning problem solving pipeline.

Prediction Problems

In data science, people usually have a few records of an entity and want to predict what will happen to that entity in the future. Trane is designed to generate time-related prediction problems. Trane transforms data meta information into lists of relevant prediction problems and cutoff times. Prediction problems are structured in a formal language described in Operations below. Cutoff times are defined as the last time in the data used for training the classifier. Data after the cutoff time is used for evaluating the classifiers accuracy. Cutoff times are necessary to prevent the classifier from training to test data.


A bank wants to predict how many transactions over 100$ a customer will make in the next year. Assume we have all the transaction records for each client from 2015 to 2017. We want to build a machine learning method to solve the prediction problem. Here is the example database.

User_id Time Transaction_id Amount
u1 2015 1-2015-1 10
u1 2015 1-2015-2 200
u2 2015 2-2015-1 50
u1 2016 1-2016-1 10
u1 2017 1-2017-1 1000
u1 2017 1-2017-2 20
u2 2017 2-2017-1 10

First, we seperate the data by entity. Here the entity is user_id. User u1 for example, has

User_id Time Transaction_id Amount
u1 2015 1-2015-1 10
u1 2015 1-2015-2 200
u1 2016 1-2016-1 10
u1 2017 1-2017-1 1000
u1 2017 1-2017-2 20

Let's consider a cutoff time equal to 2016. The data from 2015-2016 will be used as training data in the machine learning model. Data after 2016, that is data from 2016-2017 will be used to evaluate the trained model. Trane outputs a tuple of (entity, cutoff, label) for each prediction problem. A prediction problem is applied to entity data to generate the label. The data from Trane can be fed directly into Feature Tools to perform feature engineering.

Prediction Problem Generation

As shown in the example, a prediction problem is a sequence of operations applied to data as well as a cutoff time.

In Trane, we generate prediction problems with four operations: Filter Operations, Row Operations, Transformation Operations and Aggregation Operations. Filter operations are applied on the filter_column. Row, Transformation and Aggregation Operations are applied on the label_generating_column.


The workflow of using Trane on a database is as follows:

  • Data scientist writes a meta.json describing columns and data types in the new database.
  • PredictionProblemGenerator reads the meta data and generates possible prediction problems. The prediction problems are saved to problems.json.
  • The data scientist can change parameters to the prediction problems in problems.json.
  • The labeler applies prediction problems in problems.json to the database data.csv

Built-in Operations

  • FilterOp
    • IdentityFilterOp
    • GreaterFilterOp
  • RowOp
    • IdentityRowOp
    • GreaterRowOp
  • TransformationOp
    • IdentityTransformationOp
    • DiffTransformationOp
  • AggregationOp
    • FirstAggregationOp
    • CountAggregationOp
    • SumAggregationOp
    • LastAggregationOp
    • LMFAggregationOp

Unit Testing

We use pytest to automatically collecting unit testings and pytest-cov to measure the coverage of unit testing. The application code is in Trane/trane/. The unit testing code is in Trane/tests/. To run all unit testing, change directory to Trane and execute

> pytest --cov=trane tests


Clone from Git

> git clone

Run pip install

> pip3 install Trane/

Quick Usage

We have a tutorial notebook here.


  • Need an easier way to add customize operations. Currently, external plugin operations are not allowed. The bottleneck is we need to maintain a list of operations so that we can save, load, and iterate over operations. It's not easy to add an external operation into operation list.
  • Currently, all operations are in-place operations. The aggregation ops simply take a record, change the value in the column and return. May not be a good design.
  • API for setting thresholds.
  • Some NotImplementedError.
  • NL system should be independent of Trane. Seems better to generate NL from JSON.


0.1.0 (2018-04-12)

  • First release on PyPI.

Project details

Download files

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

Files for trane, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size trane-0.1.0-py3.6.egg (70.9 kB) File type Egg Python version 3.6 Upload date Hashes View
Filename, size trane-0.1.0-py3.5.egg (72.2 kB) File type Egg Python version 3.5 Upload date Hashes View
Filename, size trane-0.1.0-py3.4.egg (72.4 kB) File type Egg Python version 3.4 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page