Skip to content

Working out the features

H.P. Gansevoort edited this page Oct 5, 2026 · 2 revisions

Step 4 — Working out the features

A feature is worked out from the columns as they stand, row by row, and it stands above the split for a reason worth saying plainly: a feature must be what the split divides, not something added to one part of it. Work it out after the rows are divided and you have three slightly different feature sets, one per part, each made by its own code path.

using DeepSharp.Pipelines;

var prepared = Pdd.Create()
    .ReadCsv("bikes.csv")
    .Declare(schema => schema.Timestamp("dteday").Number("temp", "hum", "cnt"))
    .Cyclical(cyclical => cyclical                   // one line, a period a column
        .DayOfWeek("dteday")
        .MonthOfYear("dteday"))
    .AddFeature("warmth", "temp", Arithmetic.Minus, "hum")
    .SplitByTime("dteday", train: 0.70, validation: 0.15)
    .Target("cnt")
    .Drop("dteday")                                  // a moment is not a number a model takes
    .Normalise("temp", "hum", "warmth")
    .Build()
    .Run();

Console.WriteLine(string.Join(", ", prepared.Batch(Part.Train).FeatureNames));

Nothing here learns anything. warmth is one subtraction a row at a time; the day of the week is written as a place on a circle so that Monday and Sunday are neighbours, which is arithmetic on a date and not a fact about the data set. That is why these may stand above the line and a mean may not.

The date stays behind. Once the day of the week and the month are written from dteday, it has done its work, and a moment is not a number a model takes — so it is dropped below the split, before what learns, and what was worked out from it stays.

The one thing to watch. A feature inherits the gaps of what it was made from. If temp had gaps, warmth would have them in the same rows, and nothing below the split reaches back into it. That is the whole reason Settling the gaps comes before this step rather than after it; the handover will say so by name if you forget, naming the columns a feature came from rather than only that a gap is a gap.

Indicators that read a window of rows — a moving average, a band — live in a package of their own and bring their own rule: the rows at the start that an indicator cannot yet speak for are dropped, above the split, by .DropWarmUp().

Next: Splitting the rows · Every feature verb, and the indicators: Pipeline

Clone this wiki locally