aliases.R 2.24 KB
Newer Older
1
2
3
# Central location for parameter aliases.
# See https://lightgbm.readthedocs.io/en/latest/Parameters.html#core-parameters

4
5
6
# [description] List of respected parameter aliases specific to lgb.Dataset. Wrapped in a function to
#               take advantage of lazy evaluation (so it doesn't matter what order
#               R sources files during installation).
Nikita Titov's avatar
Nikita Titov committed
7
# [return] A named list, where each key is a parameter relevant to lgb.Dataset and each value is a character
8
9
#          vector of corresponding aliases.
.DATASET_PARAMETERS <- function() {
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    all_aliases <- .PARAMETER_ALIASES()
    return(all_aliases[c(
        "bin_construct_sample_cnt"
        , "categorical_feature"
        , "data_random_seed"
        , "enable_bundle"
        , "feature_pre_filter"
        , "forcedbins_filename"
        , "group_column"
        , "header"
        , "ignore_column"
        , "is_enable_sparse"
        , "label_column"
        , "linear_tree"
        , "max_bin"
        , "max_bin_by_feature"
        , "min_data_in_bin"
        , "pre_partition"
        , "precise_float_parser"
        , "two_round"
        , "use_missing"
        , "weight_column"
        , "zero_as_missing"
    )])
34
35
}

36
37
38
39
# [description] List of respected parameter aliases. Wrapped in a function to take advantage of
#               lazy evaluation (so it doesn't matter what order R sources files during installation).
# [return] A named list, where each key is a main LightGBM parameter and each value is a character
#          vector of corresponding aliases.
40
.PARAMETER_ALIASES <- function() {
41
42
43
    params_to_aliases <- jsonlite::fromJSON(
        .Call(
            LGBM_DumpParamAliases_R
44
        )
45
    )
46
47
48
49
50
    for (main_name in names(params_to_aliases)) {
        aliases_with_main_name <- c(main_name, unlist(params_to_aliases[[main_name]]))
        params_to_aliases[[main_name]] <- aliases_with_main_name
    }
    return(params_to_aliases)
51
}
52
53
54
55
56
57
58

# [description]
#     Per https://github.com/microsoft/LightGBM/blob/master/docs/Parameters.rst#metric,
#     a few different strings can be used to indicate "no metrics".
# [returns]
#     A character vector
.NO_METRIC_STRINGS <- function() {
59
60
61
62
63
64
65
66
    return(
        c(
            "na"
            , "None"
            , "null"
            , "custom"
        )
    )
67
}