---
url: /compare/featuretools.md
description: >-
  scikit-link as a Featuretools alternative: relational features fitted in each
  cross-validation fold, learned conditions, and models that read related
  tables.
---

# 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

| | Featuretools | scikit-link |
| --- | --- | --- |
| Describe the tables | `EntitySet`, `add_dataframe`, `add_relationship` | `Database(tables=..., primary_keys=..., relationships=...)` |
| Compute features | `ft.dfs(...)` returns a feature matrix | `RelationalFeaturizer(db, entity=..., key=...)`, a transformer |
| When categories and features are chosen | Once, on the data passed to `dfs` (often all of it), unless you split it yourself | In `fit`, from the training rows of each fold |
| Conditions inside aggregates | `where_primitives` on values you mark as interesting | Conditional means and sums by default (`conditional=True`), or learned by relational trees and forests |
| Point-in-time features | `cutoff_time` data frame, `training_window` | A cutoff column in `X` with `time=`, and `windows=["30D"]` |
| Models that read the tables | None; you pick a model for the matrix | Relational decision trees, random forests and gradient boosting |
| Catalog of primitives | Large, including transform primitives such as `month` | Aggregations; 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](https://scikit-link.rodrigo-arenas.com/stable/guides/migrate-from-featuretools)
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.
