首页 > 解决方案 > 在 AutoMLConfig (azureml) 中使用“cv_splits_indices”

问题描述

当使用 AutoMLConfig 训练回归模型时,n_cross_validations 是一个正常的 int,我没有遇到任何问题。

现在我想使用 TimeSeriesSplit 作为使用 AutoMLConfig 训练模型的交叉验证方法。为此,有一个“cv_splits_indices”参数,当 TimeSeriesSplit 中的 n_splits=5 时,我在其中放入一个索引列表列表,如下所示:

array([[array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10]),
        array([11, 12, 13, 14])],
       [array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14]),
        array([15, 16, 17, 18])],
       [array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
       17, 18]),
        array([19, 20, 21, 22])],
       [array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
       17, 18, 19, 20, 21, 22]),
        array([23, 24, 25, 26])],
       [array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
       17, 18, 19, 20, 21, 22, 23, 24, 25, 26]),
        array([27, 28, 29, 30])]], dtype=object)

不幸的是,在运行以下单元格时:

automl_settings = {
    "iteration_timeout_minutes": 15,
    "experiment_timeout_hours": 0.3,
    "max_cores_per_iteration" : -1,
    "enable_early_stopping": True,
    "primary_metric": 'normalized_root_mean_squared_error',
    "featurization": 'auto',
    "verbosity": logging.INFO,
    "cv_splits_indices": idxs
}

automl_config = AutoMLConfig(task='regression',
                             debug_log=f'automated_ml_errors_.log',
                             training_data=train,
                             validation_data=train,
                             label_column_name=y_var,
                             **automl_settings)

我收到以下错误:

ConfigException: ConfigException:
 Message: cv_splits_indices should be a List of List[numpy.ndarray]. Each List[numpy.ndarray] corresponds to a CV fold and should have just 2 elements: The indices for training set and for the validation set.
 InnerException: None
 ErrorResponse 
{
    "error": {
        "code": "UserError",
        "message": "cv_splits_indices should be a List of List[numpy.ndarray]. Each List[numpy.ndarray] corresponds to a CV fold and should have just 2 elements: The indices for training set and for the validation set.",
        "details_uri": "https://aka.ms/AutoMLConfig",
        "target": "cv_splits_indices",
        "inner_error": {
            "code": "BadArgument",
            "inner_error": {
                "code": "ArgumentInvalid"
            }
        },
        "reference_code": "XXXXXXREDACTEDXXXX"
    }
}

这里出了什么问题?我的输入看起来正确吗?

标签: azurescikit-learnazure-machine-learning-studioazureml-python-sdk

解决方案


推荐阅读