Temporal feature extraction
Feature extraction for temporal columns
ExpandDate
ExpandDate(self, inputs, components=('dow', 'month', 'year'))
A step for expanding date columns into one or more features.
New features will be named {input_column}_{component}
. For example, if expanding a "year"
component from column "x"
, the feature column would be named "x_year"
.
Parameters
Name | Type | Description | Default |
---|---|---|---|
inputs |
SelectionType | A selection of date columns to expand into new features. | required |
components |
Sequence[Literal[‘day’, ‘week’, ‘month’, ‘year’, ‘dow’, ‘doy’]] | A sequence of components to expand. Options include - day : the day of the month as a numeric value - week : the week of the year as a numeric value - month : the month of the year as a categorical value - year : the year as a numeric value - dow : the day of the week as a categorical value - doy : the day of the year as a numeric value Defaults to ["dow", "month", "year"] . |
('dow', 'month', 'year') |
Examples
>>> import ibis_ml as ml
Expand date columns using the default components
>>> step = ml.ExpandDate(ml.date())
Expand specific columns using specific components
>>> step = ml.ExpandDate(["x", "y"], ["day", "year"])
ExpandTime
ExpandTime(self, inputs, components=('hour', 'minute', 'second'))
A step for expanding time columns into one or more features.
New features will be named {input_column}_{component}
. For example, if expanding an "hour"
component from column "x"
, the feature column would be named "x_hour"
.
Parameters
Name | Type | Description | Default |
---|---|---|---|
inputs |
SelectionType | A selection of time columns to expand into new features. | required |
components |
Sequence[Literal[‘hour’, ‘minute’, ‘second’, ‘millisecond’]] | A sequence of components to expand. Options include hour , minute , second , and millisecond . Defaults to ["hour", "minute", "second"] . |
('hour', 'minute', 'second') |
Examples
>>> import ibis_ml as ml
Expand time columns using the default components
>>> step = ml.ExpandTime(ml.time())
Expand specific columns using specific components
>>> step = ml.ExpandTime(["x", "y"], ["hour", "minute"])
ExpandTimestamp
ExpandTimestamp(self, inputs, components=('dow', 'month', 'year', 'hour', 'minute', 'second'))
A step for expanding timestamp columns into one or more features.
New features will be named {input_column}_{component}
. For example, if expanding a "year"
component from column "x"
, the feature column would be named "x_year"
.
Parameters
Name | Type | Description | Default |
---|---|---|---|
inputs |
SelectionType | A selection of timestamp columns to expand into new features. | required |
components |
list[Literal[‘day’, ‘week’, ‘month’, ‘year’, ‘dow’, ‘doy’, ‘hour’, ‘minute’, ‘second’, ‘millisecond’]] | A sequence of date or time components to expand. Options include - day : the day of the month as a numeric value - week : the week of the year as a numeric value - month : the month of the year as a categorical value - year : the year as a numeric value - dow : the day of the week as a categorical value - doy : the day of the year as a numeric value - hour : the hour as a numeric value - minute : the minute as a numeric value - second : the second as a numeric value - millisecond : the millisecond as a numeric value Defaults to ["dow", "month", "year", "hour", "minute", "second"] . |
('dow', 'month', 'year', 'hour', 'minute', 'second') |
Examples
>>> import ibis_ml as ml
Expand timestamp columns using the default components
>>> step = ml.ExpandTimestamp(ml.timestamp())
Expand specific columns using specific components
>>> step = ml.ExpandTimestamp(["x", "y"], ["day", "year", "hour"])