I have a prediction problem where each row/entity contains data over a range of time and features can change in importance over time even for a single entity. I am wondering if machine learning models are flexible in learning feature importances with respect to time.

Example: Let's say we want to predict whether or not a home will sell. The home is the entity and after the home is put on the market, we receive observations of the number of bids and the value of bids. Intuitively, when the home is first on the market, there are no bids and there are many features (such as location, size, asking price for sq footage etc) that are important for prediction. As time passes, the number of bids and the associated prices are important in determining the probability a house will sell (perhaps even more important than the location/size etc).

The goal is to build a model so that at any point in time after the home is put on the market, we can make a prediction to if the house will sell or not.

Currently, my strategy is to truncate the data at random points in time: for each home, I have $n$ samples, representing the $n$ different time points after the home is put on the market. I then train a tree-based machine learning on this new dataset.

But this leads to the conceptual question of are machine learning (boosted tree-based mostly) models flexible enough to capture that a feature maybe be increasingly/decreasingly important as time passes? And, what does it mean if after analyzing my model using SHAP that I find that my model does not see a relationship between feature importance and time?

Also very open to other suggestions and techniques.


1 Answer 1


Yes, models with enough flexibility can learn this.

This is not conceptually different from any other kind of interaction. Yes, here you consider the specific interaction between some feature and time, but think in terms of interactions in general. In particular, think in terms of classifying the colors of the points below, knowing just their coordinates.

enter image description here

A sufficiently flexible model will figure out that being on the right suggests red when the point is down low but suggests blue when the point is up high. In that sense, the way that left/right (and up/down) is predictive changes according to the values of the other features.

You would be doing the same, just with time as one of those features.

# To make the plot

N <- 1000
X0 <- MASS::mvrnorm(N, c(0,0), matrix(c(1, 0.95, 0.95, 1), 2, 2))
X1 <- MASS::mvrnorm(N, c(0,0), matrix(c(1, -0.95, -0.95, 1), 2, 2))
d0 <- data.frame(
    x = X0[, 1],
    y = X0[, 2],
    Group = "Slash"
d1 <- data.frame(
    x = X1[, 1],
    y = X1[, 2],
    Group = "Backslash"
d <- rbind(d0, d1)
ggplot(d, aes(x, y, col = Group)) +

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.