Partitioning
- class datarobot.RandomCV
A partition in which observations are randomly assigned to cross-validation groups and the holdout set.
- Parameters:
holdout_pct (
int
) – the desired percentage of dataset to assign to holdout setreps (
int
) – number of cross validation folds to useseed (
int
) – a seed to use for randomization
- class datarobot.StratifiedCV
A partition in which observations are randomly assigned to cross-validation groups and the holdout set, preserving in each group the same ratio of positive to negative cases as in the original data.
- Parameters:
holdout_pct (
int
) – the desired percentage of dataset to assign to holdout setreps (
int
) – number of cross validation folds to useseed (
int
) – a seed to use for randomization
- class datarobot.GroupCV
A partition in which one column is specified, and rows sharing a common value for that column are guaranteed to stay together in the partitioning into cross-validation groups and the holdout set.
- Parameters:
holdout_pct (
int
) – the desired percentage of dataset to assign to holdout setreps (
int
) – number of cross validation folds to usepartition_key_cols (
list
) – a list containing a single string, where the string is the name of the column whose values should remain together in partitioningseed (
int
) – a seed to use for randomization
- class datarobot.UserCV
A partition where the cross-validation folds and the holdout set are specified by the user.
- Parameters:
user_partition_col (
string
) – the name of the column containing the partition assignmentscv_holdout_level – the value of the partition column indicating a row is part of the holdout set
seed (
int
) – a seed to use for randomization
- class datarobot.RandomTVH
Specifies a partitioning method in which rows are randomly assigned to training, validation, and holdout.
- Parameters:
holdout_pct (
int
) – the desired percentage of dataset to assign to holdout setvalidation_pct (
int
) – the desired percentage of dataset to assign to validation setseed (
int
) – a seed to use for randomization
- class datarobot.UserTVH
Specifies a partitioning method in which rows are assigned by the user to training, validation, and holdout sets.
- Parameters:
user_partition_col (
string
) – the name of the column containing the partition assignmentstraining_level – the value of the partition column indicating a row is part of the training set
validation_level – the value of the partition column indicating a row is part of the validation set
holdout_level – the value of the partition column indicating a row is part of the holdout set (use None if you want no holdout set)
seed (
int
) – a seed to use for randomization
- class datarobot.StratifiedTVH
A partition in which observations are randomly assigned to train, validation, and holdout sets, preserving in each group the same ratio of positive to negative cases as in the original data.
- Parameters:
holdout_pct (
int
) – the desired percentage of dataset to assign to holdout setvalidation_pct (
int
) – the desired percentage of dataset to assign to validation setseed (
int
) – a seed to use for randomization
- class datarobot.GroupTVH
A partition in which one column is specified, and rows sharing a common value for that column are guaranteed to stay together in the partitioning into the training, validation, and holdout sets.
- Parameters:
holdout_pct (
int
) – the desired percentage of dataset to assign to holdout setvalidation_pct (
int
) – the desired percentage of dataset to assign to validation setpartition_key_cols (
list
) – a list containing a single string, where the string is the name of the column whose values should remain together in partitioningseed (
int
) – a seed to use for randomization
- class datarobot.DatetimePartitioningSpecification
Uniquely defines a DatetimePartitioning for some project
Includes only the attributes of DatetimePartitioning that are directly controllable by users, not those determined by the DataRobot application based on the project dataset and the user-controlled settings.
This is the specification that should be passed to
Project.analyze_and_model
via thepartitioning_method
parameter. To see the full partitioning based on the project dataset, useDatetimePartitioning.generate
.All durations should be specified with a duration string such as those returned by the
partitioning_methods.construct_duration_string
helper method. Please see datetime partitioned project documentation for more information on duration strings.Note that either (
holdout_start_date
,holdout_duration
) or (holdout_start_date
,holdout_end_date
) can be used to specify holdout partitioning settings.- Variables:
datetime_partition_column (
str
) – the name of the column whose values as dates are used to assign a row to a particular partitionautopilot_data_selection_method (
str
) – one ofdatarobot.enums.DATETIME_AUTOPILOT_DATA_SELECTION_METHOD
. Whether models created by the autopilot should use “rowCount” or “duration” as their data_selection_method.validation_duration (
str
orNone
) – the default validation_duration for the backtestsholdout_start_date (
datetime.datetime
orNone
) – The start date of holdout scoring data. Ifholdout_start_date
is specified, eitherholdout_duration
orholdout_end_date
must also be specified. Ifdisable_holdout
is set toTrue
,holdout_start_date
,holdout_duration
, andholdout_end_date
may not be specified.holdout_duration (
str
orNone
) – The duration of the holdout scoring data. Ifholdout_duration
is specified,holdout_start_date
must also be specified. Ifdisable_holdout
is set toTrue
,holdout_duration
,holdout_start_date
, andholdout_end_date
may not be specified.holdout_end_date (
datetime.datetime
orNone
) – The end date of holdout scoring data. Ifholdout_end_date
is specified,holdout_start_date
must also be specified. Ifdisable_holdout
is set toTrue
,holdout_end_date
,holdout_start_date
, andholdout_duration
may not be specified.disable_holdout (
bool
orNone
) – (New in version v2.8) Whether to suppress allocating a holdout fold. If set toTrue
,holdout_start_date
,holdout_duration
, andholdout_end_date
may not be specified.gap_duration (
str
orNone
) – The duration of the gap between training and holdout scoring datanumber_of_backtests (
int
orNone
) – the number of backtests to usebacktests (
list
ofBacktestSpecification
) – the exact specification of backtests to use. The indices of the specified backtests should range from 0 to number_of_backtests - 1. If any backtest is left unspecified, a default configuration will be chosen.use_time_series (
bool
) – (New in version v2.8) Whether to create a time series project (ifTrue
) or an OTV project which uses datetime partitioning (ifFalse
). The default behavior is to create an OTV project.default_to_known_in_advance (
bool
) – (New in version v2.11) Optional, defaultFalse
. Used for time series projects only. Sets whether all features default to being treated as known in advance. Known in advance features are expected to be known for dates in the future when making predictions, e.g., “is this a holiday?”. Individual features can be set to a value different than the default using thefeature_settings
parameter.default_to_do_not_derive (
bool
) – (New in v2.17) Optional, defaultFalse
. Used for time series projects only. Sets whether all features default to being treated as do-not-derive features, excluding them from feature derivation. Individual features can be set to a value different than the default by using thefeature_settings
parameter.feature_derivation_window_start (
int
orNone
) – (New in version v2.8) Only used for time series projects. Offset into the past to define how far back relative to the forecast point the feature derivation window should start. Expressed in terms of thewindows_basis_unit
and should be negative value or zero.feature_derivation_window_end (
int
orNone
) – (New in version v2.8) Only used for time series projects. Offset into the past to define how far back relative to the forecast point the feature derivation window should end. Expressed in terms of thewindows_basis_unit
and should be a negative value or zero.feature_settings (
list
ofFeatureSettings
) – (New in version v2.9) Optional, a list specifying per feature settings, can be left unspecified.forecast_window_start (
int
orNone
) – (New in version v2.8) Only used for time series projects. Offset into the future to define how far forward relative to the forecast point the forecast window should start. Expressed in terms of thewindows_basis_unit
.forecast_window_end (
int
orNone
) – (New in version v2.8) Only used for time series projects. Offset into the future to define how far forward relative to the forecast point the forecast window should end. Expressed in terms of thewindows_basis_unit
.windows_basis_unit (
string
, optional) – (New in version v2.14) Only used for time series projects. Indicates which unit is a basis for feature derivation window and forecast window. Valid options are detected time unit (one of thedatarobot.enums.TIME_UNITS
) or “ROW”. If omitted, the default value is the detected time unit.treat_as_exponential (
string
, optional) – (New in version v2.9) defaults to “auto”. Used to specify whether to treat data as exponential trend and apply transformations like log-transform. Use values from thedatarobot.enums.TREAT_AS_EXPONENTIAL
enum.differencing_method (
string
, optional) – (New in version v2.9) defaults to “auto”. Used to specify which differencing method to apply of case if data is stationary. Use values fromdatarobot.enums.DIFFERENCING_METHOD
enum.periodicities (
list
ofPeriodicity
, optional) – (New in version v2.9) a list ofdatarobot.Periodicity
. Periodicities units should be “ROW”, if thewindows_basis_unit
is “ROW”.multiseries_id_columns (
List[str]
ornull
) – (New in version v2.11) a list of the names of multiseries id columns to define series within the training data. Currently only one multiseries id column is supported.use_cross_series_features (
bool
) – (New in version v2.14) Whether to use cross series features.aggregation_type (
Optional[str]
) – (New in version v2.14) The aggregation type to apply when creating cross series features. Optional, must be one of “total” or “average”.cross_series_group_by_columns (
list
ofOptional[str]
) – (New in version v2.15) List of columns (currently of length 1). Optional setting that indicates how to further split series into related groups. For example, if every series is sales of an individual product, the series group-by could be the product category with values like “men’s clothing”, “sports equipment”, etc.. Can only be used in a multiseries project withuse_cross_series_features
set toTrue
.calendar_id (
Optional[str]
) – (New in version v2.15) The id of theCalendarFile
to use with this project.unsupervised_mode (
Optional[bool]
) – (New in version v2.20) defaults to False, indicates whether partitioning should be constructed for the unsupervised project.model_splits (
Optional[int]
) – (New in version v2.21) Sets the cap on the number of jobs per model used when building models to control number of jobs in the queue. Higher number of model splits will allow for less downsampling leading to the use of more post-processed data.allow_partial_history_time_series_predictions (
Optional[bool]
) – (New in version v2.24) Whether to allow time series models to make predictions using partial historical data.unsupervised_type (
Optional[str]
) – (New in version v3.2) The unsupervised project type, only valid ifunsupervised_mode
is True. Use values fromdatarobot.enums.UnsupervisedTypeEnum
enum. If not specified then the project defaults to ‘anomaly’ whenunsupervised_mode
is True.
- collect_payload()
Set up the dict that should be sent to the server when setting the target
- Returns:
partitioning_spec
- Return type:
dict
- prep_payload(project_id, max_wait=600)
Run any necessary validation and prep of the payload, including async operations
Mainly used for the datetime partitioning spec but implemented in general for consistency
- Return type:
None
- update(**kwargs)
Update this instance, matching attributes to kwargs
Mainly used for the datetime partitioning spec but implemented in general for consistency
- Return type:
None
- class datarobot.BacktestSpecification
Uniquely defines a Backtest used in a DatetimePartitioning
Includes only the attributes of a backtest directly controllable by users. The other attributes are assigned by the DataRobot application based on the project dataset and the user-controlled settings.
There are two ways to specify an individual backtest:
Option 1: Use
index
,gap_duration
,validation_start_date
, andvalidation_duration
. All durations should be specified with a duration string such as those returned by thepartitioning_methods.construct_duration_string
helper method.import datarobot as dr partitioning_spec = dr.DatetimePartitioningSpecification( backtests=[ # modify the first backtest using option 1 dr.BacktestSpecification( index=0, gap_duration=dr.partitioning_methods.construct_duration_string(), validation_start_date=datetime(year=2010, month=1, day=1), validation_duration=dr.partitioning_methods.construct_duration_string(years=1), ) ], # other partitioning settings... )
Option 2 (New in version v2.20): Use
index
,primary_training_start_date
,primary_training_end_date
,validation_start_date
, andvalidation_end_date
. In this case, note that settingprimary_training_end_date
andvalidation_start_date
to the same timestamp will result with no gap being created.import datarobot as dr partitioning_spec = dr.DatetimePartitioningSpecification( backtests=[ # modify the first backtest using option 2 dr.BacktestSpecification( index=0, primary_training_start_date=datetime(year=2005, month=1, day=1), primary_training_end_date=datetime(year=2010, month=1, day=1), validation_start_date=datetime(year=2010, month=1, day=1), validation_end_date=datetime(year=2011, month=1, day=1), ) ], # other partitioning settings... )
All durations should be specified with a duration string such as those returned by the
partitioning_methods.construct_duration_string
helper method. Please see datetime partitioned project documentation for more information on duration strings.- Variables:
index (
int
) – the index of the backtest to updategap_duration (
str
) – a duration string specifying the desired duration of the gap between training and validation scoring data for the backtestvalidation_start_date (
datetime.datetime
) – the desired start date of the validation scoring data for this backtestvalidation_duration (
str
) – a duration string specifying the desired duration of the validation scoring data for this backtestvalidation_end_date (
datetime.datetime
) – the desired end date of the validation scoring data for this backtestprimary_training_start_date (
datetime.datetime
) – the desired start date of the training partition for this backtestprimary_training_end_date (
datetime.datetime
) – the desired end date of the training partition for this backtest
- class datarobot.FeatureSettings
Per feature settings
- Variables:
feature_name (
string
) – name of the featureknown_in_advance (
bool
) – (New in version v2.11) Optional, for time series projects only. Sets whether the feature is known in advance, i.e., values for future dates are known at prediction time. If not specified, the feature uses the value from the default_to_known_in_advance flag.do_not_derive (
bool
) – (New in v2.17) Optional, for time series projects only. Sets whether the feature is excluded from feature derivation. If not specified, the feature uses the value from the default_to_do_not_derive flag.
- collect_payload(use_a_priori=False)
- Parameters:
use_a_priori (
bool
) – Switch to using the older a_priori key name instead of known_in_advance. DefaultFalse
- Return type:
BacktestSpecification dictionary representation
- class datarobot.Periodicity
Periodicity configuration
- Parameters:
time_steps (
int
) – Time step valuetime_unit (
string
) – Time step unit, valid options are values from datarobot.enums.TIME_UNITS
Examples
from datarobot as dr periodicities = [ dr.Periodicity(time_steps=10, time_unit=dr.enums.TIME_UNITS.HOUR), dr.Periodicity(time_steps=600, time_unit=dr.enums.TIME_UNITS.MINUTE)] spec = dr.DatetimePartitioningSpecification( # ... periodicities=periodicities )
- class datarobot.DatetimePartitioning
Full partitioning of a project for datetime partitioning.
To instantiate, use
DatetimePartitioning.get(project_id)
.Includes both the attributes specified by the user, as well as those determined by the DataRobot application based on the project dataset. In order to use a partitioning to set the target, call
to_specification
and pass the resultingDatetimePartitioningSpecification
toProject.analyze_and_model
via thepartitioning_method
parameter.The available training data corresponds to all the data available for training, while the primary training data corresponds to the data that can be used to train while ensuring that all backtests are available. If a model is trained with more data than is available in the primary training data, then all backtests may not have scores available.
All durations are specified with a duration string such as those returned by the
partitioning_methods.construct_duration_string
helper method. Please see datetime partitioned project documentation for more information on duration strings.- Variables:
project_id (
str
) – the id of the project this partitioning applies todatetime_partitioning_id (
str
orNone
) – the id of the datetime partitioning it is an optimized partitioningdatetime_partition_column (
str
) – the name of the column whose values as dates are used to assign a row to a particular partitiondate_format (
str
) – the format (e.g. “%Y-%m-%d %H:%M:%S”) by which the partition column was interpreted (compatible with strftime)autopilot_data_selection_method (
str
) – one ofdatarobot.enums.DATETIME_AUTOPILOT_DATA_SELECTION_METHOD
. Whether models created by the autopilot use “rowCount” or “duration” as their data_selection_method.validation_duration (
str
orNone
) – the validation duration specified when initializing the partitioning - not directly significant if the backtests have been modified, but used as the default validation_duration for the backtests. Can be absent if this is a time series project with an irregular primary date/time feature.available_training_start_date (
datetime.datetime
) – The start date of the available training data for scoring the holdoutavailable_training_duration (
str
) – The duration of the available training data for scoring the holdoutavailable_training_row_count (
int
orNone
) – The number of rows in the available training data for scoring the holdout. Only available when retrieving the partitioning after setting the target.available_training_end_date (
datetime.datetime
) – The end date of the available training data for scoring the holdoutprimary_training_start_date (
datetime.datetime
orNone
) – The start date of primary training data for scoring the holdout. Unavailable when the holdout fold is disabled.primary_training_duration (
str
) – The duration of the primary training data for scoring the holdoutprimary_training_row_count (
int
orNone
) – The number of rows in the primary training data for scoring the holdout. Only available when retrieving the partitioning after setting the target.primary_training_end_date (
datetime.datetime
orNone
) – The end date of the primary training data for scoring the holdout. Unavailable when the holdout fold is disabled.gap_start_date (
datetime.datetime
orNone
) – The start date of the gap between training and holdout scoring data. Unavailable when the holdout fold is disabled.gap_duration (
str
) – The duration of the gap between training and holdout scoring datagap_row_count (
int
orNone
) – The number of rows in the gap between training and holdout scoring data. Only available when retrieving the partitioning after setting the target.gap_end_date (
datetime.datetime
orNone
) – The end date of the gap between training and holdout scoring data. Unavailable when the holdout fold is disabled.disable_holdout (
bool
orNone
) – Whether to suppress allocating a holdout fold. If set toTrue
,holdout_start_date
,holdout_duration
, andholdout_end_date
may not be specified.holdout_start_date (
datetime.datetime
orNone
) – The start date of holdout scoring data. Unavailable when the holdout fold is disabled.holdout_duration (
str
) – The duration of the holdout scoring dataholdout_row_count (
int
orNone
) – The number of rows in the holdout scoring data. Only available when retrieving the partitioning after setting the target.holdout_end_date (
datetime.datetime
orNone
) – The end date of the holdout scoring data. Unavailable when the holdout fold is disabled.number_of_backtests (
int
) – the number of backtests used.backtests (
list
ofBacktest
) – the configured backtests.total_row_count (
int
) – the number of rows in the project dataset. Only available when retrieving the partitioning after setting the target.use_time_series (
bool
) – (New in version v2.8) Whether to create a time series project (ifTrue
) or an OTV project which uses datetime partitioning (ifFalse
). The default behavior is to create an OTV project.default_to_known_in_advance (
bool
) – (New in version v2.11) Optional, defaultFalse
. Used for time series projects only. Sets whether all features default to being treated as known in advance. Known in advance features are expected to be known for dates in the future when making predictions, e.g., “is this a holiday?”. Individual features can be set to a value different from the default using thefeature_settings
parameter.default_to_do_not_derive (
bool
) – (New in v2.17) Optional, defaultFalse
. Used for time series projects only. Sets whether all features default to being treated as do-not-derive features, excluding them from feature derivation. Individual features can be set to a value different from the default by using thefeature_settings
parameter.feature_derivation_window_start (
int
orNone
) – (New in version v2.8) Only used for time series projects. Offset into the past to define how far back relative to the forecast point the feature derivation window should start. Expressed in terms of thewindows_basis_unit
.feature_derivation_window_end (
int
orNone
) – (New in version v2.8) Only used for time series projects. Offset into the past to define how far back relative to the forecast point the feature derivation window should end. Expressed in terms of thewindows_basis_unit
.feature_settings (
list
ofFeatureSettings
) – (New in version v2.9) Optional, a list specifying per feature settings, can be left unspecified.forecast_window_start (
int
orNone
) – (New in version v2.8) Only used for time series projects. Offset into the future to define how far forward relative to the forecast point the forecast window should start. Expressed in terms of thewindows_basis_unit
.forecast_window_end (
int
orNone
) – (New in version v2.8) Only used for time series projects. Offset into the future to define how far forward relative to the forecast point the forecast window should end. Expressed in terms of thewindows_basis_unit
.windows_basis_unit (
string
, optional) – (New in version v2.14) Only used for time series projects. Indicates which unit is a basis for feature derivation window and forecast window. Valid options are detected time unit (one of thedatarobot.enums.TIME_UNITS
) or “ROW”. If omitted, the default value is detected time unit.treat_as_exponential (
string
, optional) – (New in version v2.9) defaults to “auto”. Used to specify whether to treat data as exponential trend and apply transformations like log-transform. Use values from thedatarobot.enums.TREAT_AS_EXPONENTIAL
enum.differencing_method (
string
, optional) – (New in version v2.9) defaults to “auto”. Used to specify which differencing method to apply of case if data is stationary. Use values from thedatarobot.enums.DIFFERENCING_METHOD
enum.periodicities (
list
ofPeriodicity
, optional) – (New in version v2.9) a list ofdatarobot.Periodicity
. Periodicities units should be “ROW”, if thewindows_basis_unit
is “ROW”.multiseries_id_columns (
List[str]
ornull
) – (New in version v2.11) a list of the names of multiseries id columns to define series within the training data. Currently only one multiseries id column is supported.number_of_known_in_advance_features (
int
) – (New in version v2.14) Number of features that are marked as known in advance.number_of_do_not_derive_features (
int
) – (New in v2.17) Number of features that are excluded from derivation.use_cross_series_features (
bool
) – (New in version v2.14) Whether to use cross series features.aggregation_type (
Optional[str]
) – (New in version v2.14) The aggregation type to apply when creating cross series features. Optional, must be one of “total” or “average”.cross_series_group_by_columns (
list
ofOptional[str]
) – (New in version v2.15) List of columns (currently of length 1). Optional setting that indicates how to further split series into related groups. For example, if every series is sales of an individual product, the series group-by could be the product category with values like “men’s clothing”, “sports equipment”, etc.. Can only be used in a multiseries project withuse_cross_series_features
set toTrue
.calendar_id (
Optional[str]
) – (New in version v2.15) Only available for time series projects. The id of theCalendarFile
to use with this project.calendar_name (
Optional[str]
) – (New in version v2.17) Only available for time series projects. The name of theCalendarFile
used with this project.model_splits (
Optional[int]
) – (New in version v2.21) Sets the cap on the number of jobs per model used when building models to control number of jobs in the queue. Higher number of model splits will allow for less downsampling leading to the use of more post-processed data.allow_partial_history_time_series_predictions (
Optional[bool]
) – (New in version v2.24) Whether to allow time series models to make predictions using partial historical data.unsupervised_mode (
Optional[bool]
) – (New in version v3.1) Whether the date/time partitioning is for an unsupervised projectunsupervised_type (
Optional[str]
) – (New in version v3.2) The unsupervised project type, only valid ifunsupervised_mode
is True. Use values fromdatarobot.enums.UnsupervisedTypeEnum
enum. If not specified then the project defaults to ‘anomaly’ whenunsupervised_mode
is True.
- classmethod generate(project_id, spec, max_wait=600, target=None)
Preview the full partitioning determined by a DatetimePartitioningSpecification
Based on the project dataset and the partitioning specification, inspect the full partitioning that would be used if the same specification were passed into
Project.analyze_and_model
.- Parameters:
project_id (
str
) – the id of the projectspec (
DatetimePartitioningSpec
) – the desired partitioningmax_wait (
Optional[int]
) – For some settings (e.g. generating a partitioning preview for a multiseries project for the first time), an asynchronous task must be run to analyze the dataset. max_wait governs the maximum time (in seconds) to wait before giving up. In all non-multiseries projects, this is unused.target (
Optional[str]
) – the name of the target column. For unsupervised projects target may be None. Providing a target will ensure that partitions are correctly optimized for your dataset.
- Returns:
the full generated partitioning
- Return type:
- classmethod get(project_id)
Retrieve the DatetimePartitioning from a project
Only available if the project has already set the target as a datetime project.
- Parameters:
project_id (
str
) – the id of the project to retrieve partitioning for- Returns:
DatetimePartitioning
- Return type:
the full partitioning for the project
- classmethod generate_optimized(project_id, spec, target, max_wait=600)
Preview the full partitioning determined by a DatetimePartitioningSpecification
Based on the project dataset and the partitioning specification, inspect the full partitioning that would be used if the same specification were passed into Project.analyze_and_model.
- Parameters:
project_id (
str
) – the id of the projectspec (
DatetimePartitioningSpecification
) – the desired partitioningtarget (
str
) – the name of the target column. For unsupervised projects target may be None.max_wait (
Optional[int]
) – Governs the maximum time (in seconds) to wait before giving up.
- Returns:
the full generated partitioning
- Return type:
- classmethod get_optimized(project_id, datetime_partitioning_id)
Retrieve an Optimized DatetimePartitioning from a project for the specified datetime_partitioning_id. A datetime_partitioning_id is created by using the
generate_optimized
function.- Parameters:
project_id (
str
) – the id of the project to retrieve partitioning fordatetime_partitioning_id (
ObjectId
) – the ObjectId associated with the project to retrieve from Mongo
- Returns:
DatetimePartitioning
- Return type:
the full partitioning for the project
- classmethod feature_log_list(project_id, offset=None, limit=None)
Retrieve the feature derivation log content and log length for a time series project.
The Time Series Feature Log provides details about the feature generation process for a time series project. It includes information about which features are generated and their priority, as well as the detected properties of the time series data such as whether the series is stationary, and periodicities detected.
This route is only supported for time series projects that have finished partitioning.
The feature derivation log will include information about:
- Detected stationarity of the series:e.g. ‘Series detected as non-stationary’
- Detected presence of multiplicative trend in the series:e.g. ‘Multiplicative trend detected’
- Detected presence of multiplicative trend in the series:e.g. ‘Detected periodicities: 7 day’
- Maximum number of feature to be generated:e.g. ‘Maximum number of feature to be generated is 1440’
- Window sizes used in rolling statistics / lag extractorse.g. ‘The window sizes chosen to be: 2 months(because the time step is 1 month and Feature Derivation Window is 2 months)’
- Features that are specified as known-in-advancee.g. ‘Variables treated as apriori: holiday’
- Details about why certain variables are transformed in the input datae.g. ‘Generating variable “y (log)” from “y” because multiplicative trendis detected’
- Details about features generated as timeseries features, and their prioritye.g. ‘Generating feature “date (actual)” from “date” (priority: 1)’
- Parameters:
project_id (
str
) – project id to retrieve a feature derivation log for.offset (
int
) – optional, defaults is 0, this many results will be skipped.limit (
int
) – optional, defaults to 100, at most this many results are returned. To specify no limit, use 0. The default may change without notice.
- classmethod feature_log_retrieve(project_id)
Retrieve the feature derivation log content and log length for a time series project.
The Time Series Feature Log provides details about the feature generation process for a time series project. It includes information about which features are generated and their priority, as well as the detected properties of the time series data such as whether the series is stationary, and periodicities detected.
This route is only supported for time series projects that have finished partitioning.
The feature derivation log will include information about:
- Detected stationarity of the series:e.g. ‘Series detected as non-stationary’
- Detected presence of multiplicative trend in the series:e.g. ‘Multiplicative trend detected’
- Detected presence of multiplicative trend in the series:e.g. ‘Detected periodicities: 7 day’
- Maximum number of feature to be generated:e.g. ‘Maximum number of feature to be generated is 1440’
- Window sizes used in rolling statistics / lag extractorse.g. ‘The window sizes chosen to be: 2 months(because the time step is 1 month and Feature Derivation Window is 2 months)’
- Features that are specified as known-in-advancee.g. ‘Variables treated as apriori: holiday’
- Details about why certain variables are transformed in the input datae.g. ‘Generating variable “y (log)” from “y” because multiplicative trendis detected’
- Details about features generated as timeseries features, and their prioritye.g. ‘Generating feature “date (actual)” from “date” (priority: 1)’
- Parameters:
project_id (
str
) – project id to retrieve a feature derivation log for.- Return type:
str
- to_specification(use_holdout_start_end_format=False, use_backtest_start_end_format=False)
Render the DatetimePartitioning as a
DatetimePartitioningSpecification
The resulting specification can be used when setting the target, and contains only the attributes directly controllable by users.
- Parameters:
use_holdout_start_end_format (
Optional[bool]
) – Defaults toFalse
. IfTrue
, will useholdout_end_date
when configuring the holdout partition. IfFalse
, will useholdout_duration
instead.use_backtest_start_end_format (
Optional[bool]
) – Defaults toFalse
. IfFalse
, will use a duration-based approach for specifying backtests (gap_duration
,validation_start_date
, andvalidation_duration
). IfTrue
, will use a start/end date approach for specifying backtests (primary_training_start_date
,primary_training_end_date
,validation_start_date
,validation_end_date
). In contrast, projects created in the Web UI will use the start/end date approach for specifying backtests. Set this parameter toTrue
to mirror the behavior in the Web UI.
- Returns:
the specification for this partitioning
- Return type:
- to_dataframe()
Render the partitioning settings as a dataframe for convenience of display
Excludes project_id, datetime_partition_column, date_format, autopilot_data_selection_method, validation_duration, and number_of_backtests, as well as the row count information, if present.
Also excludes the time series specific parameters for use_time_series, default_to_known_in_advance, default_to_do_not_derive, and defining the feature derivation and forecast windows.
- Return type:
DataFrame
- classmethod datetime_partitioning_log_retrieve(project_id, datetime_partitioning_id)
Retrieve the datetime partitioning log content for an optimized datetime partitioning.
The datetime partitioning log provides details about the partitioning process for an OTV or time series project.
- Parameters:
project_id (
str
) – The project ID of the project associated with the datetime partitioning.datetime_partitioning_id (
str
) – id of the optimized datetime partitioning
- Return type:
Any
- classmethod datetime_partitioning_log_list(project_id, datetime_partitioning_id, offset=None, limit=None)
Retrieve the datetime partitioning log content and log length for an optimized datetime partitioning.
The Datetime Partitioning Log provides details about the partitioning process for an OTV or Time Series project.
- Parameters:
project_id (
str
) – project id of the project associated with the datetime partitioning.datetime_partitioning_id (
str
) – id of the optimized datetime partitioningoffset (
int
orNone
) – optional, defaults is 0, this many results will be skipped.limit (
int
orNone
) – optional, defaults to 100, at most this many results are returned. To specify no limit, use 0. The default may change without notice.
- Return type:
Any
- classmethod get_input_data(project_id, datetime_partitioning_id)
Retrieve the input used to create an optimized DatetimePartitioning from a project for the specified datetime_partitioning_id. A datetime_partitioning_id is created by using the
generate_optimized
function.- Parameters:
project_id (
str
) – The ID of the project to retrieve partitioning for.datetime_partitioning_id (
ObjectId
) – The ObjectId associated with the project to retrieve from Mongo.
- Returns:
DatetimePartitioningInput
- Return type:
The input
tooptimized datetime partitioning.
- class datarobot.helpers.partitioning_methods.DatetimePartitioningId
Defines a DatetimePartitioningId used for datetime partitioning.
This class only includes the datetime_partitioning_id that identifies a previously optimized datetime partitioning and the project_id for the associated project.
This is the specification that should be passed to
Project.analyze_and_model
via thepartitioning_method
parameter. To see the full partitioning useDatetimePartitioning.get_optimized
.- Variables:
datetime_partitioning_id (
str
) – The ID of the datetime partitioning to use.project_id (
str
) – The ID of the project that the datetime partitioning is associated with.
- collect_payload()
Set up the dict that should be sent to the server when setting the target
- Returns:
partitioning_spec
- Return type:
dict
- prep_payload(project_id, max_wait=600)
Run any necessary validation and prep of the payload, including async operations
Mainly used for the datetime partitioning spec but implemented in general for consistency
- Return type:
None
- update(**kwargs)
Update this instance, matching attributes to kwargs
Mainly used for the datetime partitioning spec but implemented in general for consistency
- Return type:
NoReturn
- class datarobot.helpers.partitioning_methods.Backtest
A backtest used to evaluate models trained in a datetime partitioned project
When setting up a datetime partitioning project, backtests are specified by a
BacktestSpecification
.The available training data corresponds to all the data available for training, while the primary training data corresponds to the data that can be used to train while ensuring that all backtests are available. If a model is trained with more data than is available in the primary training data, then all backtests may not have scores available.
All durations are specified with a duration string such as those returned by the
partitioning_methods.construct_duration_string
helper method. Please see datetime partitioned project documentation for more information on duration strings.- Variables:
index (
int
) – the index of the backtestavailable_training_start_date (
datetime.datetime
) – the start date of the available training data for this backtestavailable_training_duration (
str
) – the duration of available training data for this backtestavailable_training_row_count (
int
orNone
) – the number of rows of available training data for this backtest. Only available when retrieving from a project where the target is set.available_training_end_date (
datetime.datetime
) – the end date of the available training data for this backtestprimary_training_start_date (
datetime.datetime
) – the start date of the primary training data for this backtestprimary_training_duration (
str
) – the duration of the primary training data for this backtestprimary_training_row_count (
int
orNone
) – the number of rows of primary training data for this backtest. Only available when retrieving from a project where the target is set.primary_training_end_date (
datetime.datetime
) – the end date of the primary training data for this backtestgap_start_date (
datetime.datetime
) – the start date of the gap between training and validation scoring data for this backtestgap_duration (
str
) – the duration of the gap between training and validation scoring data for this backtestgap_row_count (
int
orNone
) – the number of rows in the gap between training and validation scoring data for this backtest. Only available when retrieving from a project where the target is set.gap_end_date (
datetime.datetime
) – the end date of the gap between training and validation scoring data for this backtestvalidation_start_date (
datetime.datetime
) – the start date of the validation scoring data for this backtestvalidation_duration (
str
) – the duration of the validation scoring data for this backtestvalidation_row_count (
int
orNone
) – the number of rows of validation scoring data for this backtest. Only available when retrieving from a project where the target is set.validation_end_date (
datetime.datetime
) – the end date of the validation scoring data for this backtesttotal_row_count (
int
orNone
) – the number of rows in this backtest. Only available when retrieving from a project where the target is set.
- to_specification(use_start_end_format=False)
Render this backtest as a
BacktestSpecification
.The resulting specification includes only the attributes users can directly control, not those indirectly determined by the project dataset.
- Parameters:
use_start_end_format (
bool
) – DefaultFalse
. IfFalse
, will use a duration-based approach for specifying backtests (gap_duration
,validation_start_date
, andvalidation_duration
). IfTrue
, will use a start/end date approach for specifying backtests (primary_training_start_date
,primary_training_end_date
,validation_start_date
,validation_end_date
). In contrast, projects created in the Web UI will use the start/end date approach for specifying backtests. Set this parameter toTrue
to mirror the behavior in the Web UI.- Returns:
the specification for this backtest
- Return type:
- to_dataframe()
Render this backtest as a dataframe for convenience of display
- Returns:
backtest_partitioning – the backtest attributes, formatted into a dataframe
- Return type:
pandas.Dataframe
- class datarobot.helpers.partitioning_methods.FeatureSettingsPayload
- datarobot.helpers.partitioning_methods.construct_duration_string(years=0, months=0, days=0, hours=0, minutes=0, seconds=0)
Construct a valid string representing a duration in accordance with ISO8601
A duration of six months, 3 days, and 12 hours could be represented as P6M3DT12H.
- Parameters:
years (
int
) – the number of years in the durationmonths (
int
) – the number of months in the durationdays (
int
) – the number of days in the durationhours (
int
) – the number of hours in the durationminutes (
int
) – the number of minutes in the durationseconds (
int
) – the number of seconds in the duration
- Returns:
duration_string – The duration string, specified compatibly with ISO8601
- Return type:
str