Skip to content

Commit 94d0c3f

Browse files
committed
Update Core API docstring and default values
- replace "None" with "none" as acceptable values for discretization_method and grouping_method, following Khiops Core PR KhiopsML/khiops#695 - use "MODL" as default value instead of Python None for the same two parameters - in train_recoder, fix documented default value of keep_initial_categorical_variables and keep_initial_numerical_variables to False, according to the function signature.
1 parent 9758a3d commit 94d0c3f

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

khiops/core/api.py

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -321,23 +321,11 @@ def _preprocess_task_arguments(task_args):
321321
task_args["dictionary_file_path_or_domain"], task_args["trace"]
322322
)
323323

324-
# Set the default discretization method for unsupervised analysis
325-
# "target_variable" is mandatory if "discretization_method" or
326-
# "grouping_method" are present
327-
if "discretization_method" in task_args and task_args["target_variable"] == "":
328-
if task_args["discretization_method"] is None:
329-
task_args["discretization_method"] = "MODL"
330-
331324
# Remove discretization method if specified for supervised analysis:
332325
# it is always MODL
333326
if "discretization_method" in task_args and task_args["target_variable"] != "":
334327
del task_args["discretization_method"]
335328

336-
# Set the default grouping method for unsupervised analysis
337-
if "grouping_method" in task_args and task_args["target_variable"] == "":
338-
if task_args["grouping_method"] is None:
339-
task_args["grouping_method"] = "MODL"
340-
341329
# Remove grouping method if specified for supervised analysis: it is always MODL
342330
if "grouping_method" in task_args and task_args["target_variable"] != "":
343331
del task_args["grouping_method"]
@@ -691,8 +679,8 @@ def train_predictor(
691679
all_possible_pairs=True,
692680
specific_pairs=None,
693681
group_target_value=False,
694-
discretization_method=None,
695-
grouping_method=None,
682+
discretization_method="MODL",
683+
grouping_method="MODL",
696684
max_parts=0,
697685
log_file_path=None,
698686
output_scenario_path=None,
@@ -797,13 +785,13 @@ def train_predictor(
797785
group_target_value : bool, default ``False``
798786
Allows grouping of the target variable values in classification. It can
799787
substantially increase the training time.
800-
discretization_method : str
788+
discretization_method : str, default "MODL"
801789
Name of the discretization method, for unsupervised analysis only.
802-
Its valid values are: "MODL" (default), "EqualWidth", "EqualFrequency"
803-
or "None". Ignored for supervised analysis.
804-
grouping_method : str
790+
Its valid values are: "MODL", "EqualWidth", "EqualFrequency" or "none".
791+
Ignored for supervised analysis.
792+
grouping_method : str, default "MODL"
805793
Name of the grouping method, for unsupervised analysis only.
806-
Its valid values are: "MODL" (default), "BasicGrouping" or "None".
794+
Its valid values are: "MODL", "BasicGrouping" or "none".
807795
Ignored for supervised analysis.
808796
max_parts : int, default 0
809797
Maximum number of variable parts produced by preprocessing methods. If equal
@@ -1124,8 +1112,8 @@ def train_recoder(
11241112
numerical_recoding_method="part Id",
11251113
pairs_recoding_method="part Id",
11261114
group_target_value=False,
1127-
discretization_method=None,
1128-
grouping_method=None,
1115+
discretization_method="MODL",
1116+
grouping_method="MODL",
11291117
max_parts=0,
11301118
log_file_path=None,
11311119
output_scenario_path=None,
@@ -1227,9 +1215,9 @@ def train_recoder(
12271215
If ``True`` keeps only informative variables.
12281216
max_variables : int, default 0
12291217
Maximum number of variables to keep. If equal to 0 keeps all variables.
1230-
keep_initial_categorical_variables : bool, default ``True``
1218+
keep_initial_categorical_variables : bool, default ``False``
12311219
If ``True`` keeps the initial categorical variables.
1232-
keep_initial_numerical_variables : bool, default ``True``
1220+
keep_initial_numerical_variables : bool, default ``False``
12331221
If ``True`` keeps initial numerical variables.
12341222
categorical_recoding_method : str
12351223
Type of recoding for categorical variables. Types available:
@@ -1256,13 +1244,13 @@ def train_recoder(
12561244
- "0-1 binarization": A 0's and 1's coding the interval/group id
12571245
- "conditional info": Conditional information of the interval/group
12581246
- "none": Keeps the variable as-is
1259-
discretization_method : str
1247+
discretization_method : str, default "MODL"
12601248
Name of the discretization method, for unsupervised analysis only.
1261-
Its valid values are: "MODL" (default), "EqualWidth", "EqualFrequency"
1262-
or "None". Ignored for supervised analysis.
1263-
grouping_method : str
1249+
Its valid values are: "MODL", "EqualWidth", "EqualFrequency" or "none".
1250+
Ignored for supervised analysis.
1251+
grouping_method : str, default "MODL"
12641252
Name of the grouping method, for unsupervised analysis only.
1265-
Its valid values are: "MODL" (default), "BasicGrouping" or "None".
1253+
Its valid values are: "MODL", "BasicGrouping" or "none".
12661254
Ignored for supervised analysis.
12671255
max_parts : int, default 0
12681256
Maximum number of variable parts produced by preprocessing methods. If equal

0 commit comments

Comments
 (0)