h2o AutoML结果令人困惑

时间:2018-09-01 02:10:55

标签: metrics h2o automl

我在Java代码中使用AutoML,并且将AUC用作我的sort_metric。经过20分钟的训练,我得到了以下训练总结:

09-01 09:51:05.872 127.0.0.1:54321       18273  FJ-1-9    INFO: 09:51:05.869 Info  ModelTraining    Built: 1 models for search: DeepLearning hyperparameter search 1
09-01 09:51:05.872 127.0.0.1:54321       18273  FJ-1-9    INFO: 09:51:05.869 Info  ModelTraining    New leader: DeepLearning_grid_0_AutoML_20180901_092939_model_0, AUC: 0.9170303558590623
09-01 09:51:05.872 127.0.0.1:54321       18273  FJ-1-9    INFO: 09:51:05.869 Info  ModelTraining    DeepLearning hyperparameter search 1 complete
09-01 09:51:05.872 127.0.0.1:54321       18273  FJ-1-9    INFO: 09:51:05.869 Info  ModelTraining    AutoML: out of time; skipping DL hyperparameter search
09-01 09:51:05.872 127.0.0.1:54321       18273  FJ-1-9    INFO: 09:51:05.870 Info  ModelTraining    AutoML: out of time; skipping DL hyperparameter search
09-01 09:51:05.872 127.0.0.1:54321       18273  FJ-1-9    INFO: 09:51:05.870 Info  ModelTraining    StackedEnsemble builds skipped due to the exclude_algos option.
09-01 09:51:05.872 127.0.0.1:54321       18273  FJ-1-9    INFO: 09:51:05.870 Info  Workflow         AutoML: build done; built 2 models
09-01 09:51:05.872 127.0.0.1:54321       18273  FJ-1-9    INFO: Leaderboard for project my.proj (models sorted in order of AUC, best first):
09-01 09:51:05.872 127.0.0.1:54321       18273  FJ-1-9    INFO: #                                            model_id       auc   logloss  mean_per_class_error      rmse       mse
09-01 09:51:05.872 127.0.0.1:54321       18273  FJ-1-9    INFO: 0  DeepLearning_grid_0_AutoML_20180901_092939_model_0  0.917030  0.273277              0.147665  0.189239  0.035812
09-01 09:51:05.872 127.0.0.1:54321       18273  FJ-1-9    INFO: 1  DeepLearning_0_AutoML_20180901_092939               0.937039  0.150729              0.214383  0.193596  0.037479
09-01 09:51:05.872 127.0.0.1:54321       18273  FJ-1-9    INFO: 2  DeepLearning_0_AutoML_20180901_092936               0.958391  0.127028              0.181791  0.179389  0.032180

“ DeepLearning_0_AutoML_20180901_092936”似乎是最好的,因为它具有最高的AUC值,但实际上“ DeepLearning_grid_0_AutoML_20180901_092939_model_0”是第一个,并且  AtuoML.leader()也会返回模型“ DeepLearning_grid_0_AutoML_20180901_092939_model_0”。那么哪一个最好呢?

以下是运行AutoML的代码:

    AutoMLBuildSpec autoMLBuildSpec = new AutoMLBuildSpec();

    autoMLBuildSpec.input_spec.training_frame = frame._key;
    autoMLBuildSpec.input_spec.response_column = "class";
    autoMLBuildSpec.input_spec.sort_metric = "AUC";

    autoMLBuildSpec.build_control.balance_classes = true;
    autoMLBuildSpec.build_control.class_sampling_factors = new float[2];
    autoMLBuildSpec.build_control.class_sampling_factors[0] = 1.0f;
    autoMLBuildSpec.build_control.class_sampling_factors[1] = 1.0f;
    autoMLBuildSpec.build_control.nfolds = nfolds;
    autoMLBuildSpec.build_control.keep_cross_validation_models = true;
    autoMLBuildSpec.build_control.keep_cross_validation_predictions = true;
    autoMLBuildSpec.build_control.project_name = "my.proj";
    HyperSpaceSearchCriteria.RandomDiscreteValueSearchCriteria randomDiscreteValueSearchCriteria = new HyperSpaceSearchCriteria.RandomDiscreteValueSearchCriteria();
    randomDiscreteValueSearchCriteria.set_max_runtime_secs(Double.parseDouble(autoModelRuntimeSeconds));
    randomDiscreteValueSearchCriteria.set_stopping_metric(ScoreKeeper.StoppingMetric.AUTO);
    randomDiscreteValueSearchCriteria.set_stopping_tolerance(0.0);
    autoMLBuildSpec.build_control.stopping_criteria = randomDiscreteValueSearchCriteria;

    AutoMLBuildSpec.AutoMLBuildModels autoMLBuildModels = new AutoMLBuildSpec.AutoMLBuildModels();
    autoMLBuildModels.exclude_algos = new AutoML.algo[4];
    autoMLBuildModels.exclude_algos[0] = AutoML.algo.DRF;
    autoMLBuildModels.exclude_algos[1] = AutoML.algo.GBM;
    autoMLBuildModels.exclude_algos[2] = AutoML.algo.GLM;
    autoMLBuildModels.exclude_algos[3] = AutoML.algo.StackedEnsemble;

    autoMLBuildSpec.build_models = autoMLBuildModels;

    logger.info("begin training ...");
    AutoML aml = AutoML.makeAutoML(Key.make(), new Date(), autoMLBuildSpec);
    AutoML.startAutoML(aml);
    AutoML.startAutoML(autoMLBuildSpec).get();
    logger.info("training finished.");

    for (Model model: aml.leaderboard().getModels()) {
            logger.info("========================================================================================================");
            logger.info("model key: {}", model._key);
            logger.info("_scoring_history");
            logger.info(model._output._scoring_history.toString(10, true));
            logger.info("model auc: {}", Utils.doubleToString(model.auc(), 6));
            logger.info("========================================================================================================");
    }
    logger.info("leader model scoring history:");
    logger.info(aml.leader()._output._scoring_history.toString(10, true));

1 个答案:

答案 0 :(得分:1)

请尝试将指标指定为小写字母,以使排行榜在使用“ auc”时按降序排序(我们似乎并没有强制要求这样做,我已提交了JIRA票证进行修复这个):

autoMLBuildSpec.input_spec.sort_metric = "auc";

也供您参考,您无需“启动” automl 2次。 基本上

AutoML aml = AutoML.makeAutoML(Key.make(), new Date(), autoMLBuildSpec);
AutoML.startAutoML(aml);
AutoML.startAutoML(autoMLBuildSpec).get();

可以替换为

AutoML.startAutoML(autoMLBuildSpec).get();

希望这会有所帮助!