Skip to content

A Featuretools alternative for scikit-learn ​

If you use Featuretools to aggregate related tables for a scikit-learn model, scikit-link computes the same kind of features as a scikit-learn transformer that is fitted inside each cross-validation fold. It also offers trees and forests that learn the conditions inside aggregates, such as "orders above 100 of type express", instead of choosing them from a fixed list.

Featuretools introduced Deep Feature Synthesis: aggregations and transformations stacked along the relationships of an EntitySet. scikit-link keeps that idea and changes where it runs: inside the estimator, so that Pipeline, GridSearchCV and cross_val_score handle it like any other step.

Side by side ​

Featuretoolsscikit-link
Describe the tablesEntitySet, add_dataframe, add_relationshipDatabase(tables=..., primary_keys=..., relationships=...)
Compute featuresft.dfs(...) returns a feature matrixRelationalFeaturizer(db, entity=..., key=...), a transformer
When categories and features are chosenOnce, on the data passed to dfs (often all of it), unless you split it yourselfIn fit, from the training rows of each fold
Conditions inside aggregateswhere_primitives on values you mark as interestingConditional means and sums by default (conditional=True), or learned by relational trees and forests
Point-in-time featurescutoff_time data frame, training_windowA cutoff column in X with time=, and windows=["30D"]
Models that read the tablesNone; you pick a model for the matrixRelational decision trees, random forests and gradient boosting
Catalog of primitivesLarge, including transform primitives such as monthAggregations; add transforms as columns, or register a primitive

The same feature in both ​

With customers and orders as pandas data frames and y one label per customer, in Featuretools:

python
import featuretools as ft

es = ft.EntitySet(id="shop")
es = es.add_dataframe(
    dataframe_name="customers", dataframe=customers, index="customer_id"
)
es = es.add_dataframe(dataframe_name="orders", dataframe=orders, index="order_id")
es = es.add_relationship("customers", "customer_id", "orders", "customer_id")
matrix, definitions = ft.dfs(
    entityset=es, target_dataframe_name="customers", agg_primitives=["count", "mean"]
)

scikit-link, fitted inside a pipeline:

python
from sklearn.ensemble import HistGradientBoostingClassifier
from sklearn.pipeline import make_pipeline
from sklink import Database
from sklink.feature_extraction import RelationalFeaturizer

db = Database(
    tables={"customers": customers, "orders": orders},
    primary_keys={"customers": "customer_id", "orders": "order_id"},
    relationships=[("orders.customer_id", "customers.customer_id")],
)
model = make_pipeline(
    RelationalFeaturizer(
        db, entity="customers", key="customer_id", primitives=["count", "mean"]
    ),
    HistGradientBoostingClassifier(),
)
model.fit(customers[["customer_id"]], y)

When Featuretools is the better fit ​

Choose Featuretools when you need its catalog of transform primitives, such as date parts, or features computed once for a whole dataset outside a scikit-learn workflow.

Move your code ​

The migration guide maps each Featuretools step to scikit-link on the same data, including where primitives, cutoff times, training windows and saved feature definitions. The comparison covers getML, skrub and relational deep learning too.

Released under the MIT License.