Skip to main content

Featuretools Transformer for Scikit-Learn Pipeline use.

Project description

featuretools-sklearn-transformer

CircleCI codecov

Featuretools' DFS as a scikit-learn transformer

Install

pip install featuretools_sklearn_transformer

Use

import featuretools as ft
import pandas as pd

from featuretools.wrappers import DFSTransformer
from sklearn.pipeline import Pipeline
from sklearn.ensemble import ExtraTreesClassifier

# Get examle data
n_customers = 3
es = ft.demo.load_mock_customer(return_entityset=True, n_customers=5)
y = [True, False, True]

# Build pipeline
pipeline = Pipeline(steps=[
    ('ft', DFSTransformer(entityset=es,
                            target_entity="customers",
                            max_features=2)),
    ('et', ExtraTreesClassifier(n_estimators=100))
])

# Fit and predict
pipeline.fit([1, 2, 3], y=y) # fit on first 3 customers
pipeline.predict_proba([4,5]) # predict probability of each class on last 2
pipeline.predict([4,5]) # predict on last 2

# Same as above, but using cutoff times
ct = pd.DataFrame()
ct['customer_id'] = [1, 2, 3, 4, 5]
ct['time'] = pd.to_datetime(['2014-1-1 04:00',
                                '2014-1-2 17:20',
                                '2014-1-4 09:53',
                                '2014-1-4 13:48',
                                '2014-1-5 15:32'])

pipeline.fit(ct.head(3), y=y)
pipeline.predict_proba(ct.tail(2))
pipeline.predict(ct.tail(2))

Feature Labs

Featuretools

featuretools-sklearn-transformer is an open source project created by Feature Labs. To see the other open source projects we're working on visit Feature Labs Open Source. If building impactful data science pipelines is important to you or your business, please get in touch.

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

featuretools_sklearn_transformer-0.1.1.tar.gz (6.6 kB view hashes)

Uploaded Source

Built Distribution

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