khiops.core.api
Submodule of khiops.core
API for the execution of the Khiops AutoML suite
The methods in this module allow to execute all Khiops and Khiops Coclustering tasks.
| FUNCTION | DESCRIPTION |
|---|---|
get_khiops_version |
Returns the Khiops version |
get_samples_dir |
Returns the Khiops' samples directory path |
export_dictionary_as_json |
Exports a Khiops dictionary file to JSON format ( |
build_dictionary_from_data_table |
Builds a dictionary file by analyzing a data table file |
check_database |
Checks if a data table is compatible with a dictionary file |
train_predictor |
Trains a model from a data table |
interpret_predictor |
Builds an interpretation dictionary from a predictor |
reinforce_predictor |
Builds a reinforced predictor from a predictor |
evaluate_predictor |
Evaluates the predictors in a dictionary file on a database |
train_recoder |
Trains a recoding model from a data table |
deploy_model |
Deploys a model on a data table |
build_deployed_dictionary |
Builds a dictionary file to read the output table of a deployed model |
sort_data_table |
Sorts a data table |
extract_keys_from_data_table |
Extracts from data table unique occurrences of a key variable |
train_coclustering |
Trains a coclustering model from a data table |
train_instance_variable_coclustering |
Trains an instance-variable coclustering model from a data table |
simplify_coclustering |
Simplifies a coclustering model |
prepare_coclustering_deployment |
Prepares a individual-variable coclustering deployment |
extract_clusters |
Extracts clusters to a tab separated (TSV) file |
detect_data_table_format |
Detects the format of a data table |
| ATTRIBUTE | DESCRIPTION |
|---|---|
DEFAULT_CONSTRUCTION_RULES |
List of construction rules that Khiops uses by default
|
CALENDRICAL_CONSTRUCTION_RULES |
List of calendrical construction rules
|
Attributes
DEFAULT_CONSTRUCTION_RULES = ['GetValue', 'GetValueC', 'TableCount', 'TableCountDistinct', 'TableMax', 'TableMean', 'TableMedian', 'TableMin', 'TableMode', 'TableSelection', 'TableStdDev', 'TableSum']
module-attribute
List of construction rules that Khiops uses by default
Note
These are all the multi-table rules.
CALENDRICAL_CONSTRUCTION_RULES = ['Day', 'DecimalTime', 'DecimalWeekDay', 'DecimalYear', 'DecimalYearTS', 'GetDate', 'GetTime', 'LocalTimestamp', 'WeekDay', 'YearDay']
module-attribute
List of calendrical construction rules
These rules include: date, time and timestamp rules.
Note
These rules are not enabled by default. The user needs to explicitly
select each of them via the construction_rules parameter of the
relevant Core API functions.
Classes
Functions:
get_khiops_version()
Returns the Khiops version
| RETURNS | DESCRIPTION |
|---|---|
str
|
The Khiops version of the current KhiopsRunner backend. |
get_samples_dir()
Returns the Khiops' samples directory path
| RETURNS | DESCRIPTION |
|---|---|
str
|
The path of the Khiops samples directory. |
export_dictionary_as_json(dictionary_file_path_or_domain, json_dictionary_file_path, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='')
Exports a Khiops dictionary file to JSON format (.kdicj)
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
json_dictionary_file_path
|
Path (absolute path recommended) to the output dictionary file, in the JSON format. Note that a relative path will produce a file in the current working directory.
TYPE:
|
See Also
Examples:
See the following function of the samples.py documentation script:
- samples.export_dictionary_files()
build_dictionary_from_data_table(data_table_path, output_dictionary_name, output_dictionary_file_path, detect_format=True, header_line=None, field_separator=None, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Builds a dictionary file by analyzing a data table file
| PARAMETER | DESCRIPTION |
|---|---|
data_table_path
|
Path of the data table file.
TYPE:
|
output_dictionary_name
|
Name dictionary to be created.
TYPE:
|
output_dictionary_file_path
|
Path (absolute path recommended) of the output dictionary file. Note that a relative path will produce a file in the current working directory.
TYPE:
|
detect_format
|
If
TYPE:
|
header_line
|
If
TYPE:
|
field_separator
|
A field separator character. "" has the same effect as "\t". Sets
TYPE:
|
See Also
check_database(dictionary_file_path_or_domain, dictionary_name, data_table_path, detect_format=True, header_line=None, field_separator=None, sample_percentage=100.0, sampling_mode='Include sample', selection_variable='', selection_value='', additional_data_tables=None, max_messages=20, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Checks if a data table is compatible with a dictionary file
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
dictionary_name
|
Name of the dictionary of the table to be checked.
TYPE:
|
data_table_path
|
Path of the data table file.
TYPE:
|
detect_format
|
If
TYPE:
|
header_line
|
If
TYPE:
|
field_separator
|
A field separator character. "" has the same effect as "\t". Sets
TYPE:
|
sample_percentage
|
See the
TYPE:
|
sampling_mode
|
If equal to "Include sample" it checks
TYPE:
|
selection_variable
|
It checks only the records such that the value of
TYPE:
|
selection_value
|
See
DEFAULT:
|
additional_data_tables
|
A dictionary containing the data paths and file paths for a multi-table dictionary file. For more details see Multi-Table Learning Primer.
TYPE:
|
max_messages
|
Maximum number of error messages to write in the log file.
TYPE:
|
See Also
Examples:
See the following function of the samples.py documentation script:
- samples.check_database()
train_predictor(dictionary_file_path_or_domain, dictionary_name, data_table_path, target_variable, analysis_report_file_path, detect_format=True, header_line=None, field_separator=None, sample_percentage=70.0, sampling_mode='Include sample', use_complement_as_test=True, selection_variable='', selection_value='', additional_data_tables=None, do_data_preparation_only=False, main_target_value='', keep_selected_variables_only=True, max_evaluated_variables=0, max_selected_variables=0, max_constructed_variables=1000, construction_rules=None, max_text_features=10000, text_features='words', max_trees=10, max_pairs=0, all_possible_pairs=True, specific_pairs=None, group_target_value=False, discretization_method='MODL', grouping_method='MODL', max_parts=0, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Trains a model from a data table
Note
For all input dictionaries, this function creates model dictionaries whose
names are prefixed with SNB_. For regression models, additional
dictionaries are created and their names are prefixed with Baseline_.
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
dictionary_name
|
Name of the dictionary to be analyzed.
TYPE:
|
data_table_path
|
Path of the data table file.
TYPE:
|
target_variable
|
Name of the target variable. If the specified variable is categorical it constructs a classifier and if it is numerical a regressor. If equal to "" it performs an unsupervised analysis.
TYPE:
|
analysis_report_file_path
|
Path (absolute path recommended) to the analysis report file,
in the JSON format. An additional dictionary file with the same name and
extension
TYPE:
|
detect_format
|
If
TYPE:
|
header_line
|
If
TYPE:
|
field_separator
|
A field separator character. "" has the same effect as "\t". Sets
TYPE:
|
sample_percentage
|
See the
TYPE:
|
sampling_mode
|
If equal to "Include sample" it trains the predictor on
TYPE:
|
use_complement_as_test
|
Uses the complement of the sampled database as test database for computing the model's performance metrics.
TYPE:
|
selection_variable
|
It trains with only the records such that the value of
TYPE:
|
selection_value
|
See
DEFAULT:
|
additional_data_tables
|
A dictionary containing the data paths and file paths for a multi-table dictionary file. For more details see Multi-Table Learning Primer.
TYPE:
|
do_data_preparation_only
|
If
TYPE:
|
main_target_value
|
If this target value is specified then it guarantees the calculation of lift curves for it.
TYPE:
|
keep_selected_variables_only
|
Keeps only predictor-selected variables in the supervised analysis report.
TYPE:
|
max_evaluated_variables
|
Maximum number of variables to be evaluated in the SNB predictor training. If equal to 0 it evaluates all informative variables.
TYPE:
|
max_selected_variables
|
Maximum number of variables to be selected in the SNB predictor. If equal to 0 it selects all the variables kept in the training.
TYPE:
|
max_constructed_variables
|
Maximum number of variables to construct.
TYPE:
|
construction_rules
|
Allowed rules for the automatic variable construction. If not set, Khiops uses the multi-table construction rules listed in DEFAULT_CONSTRUCTION_RULES.
TYPE:
|
max_text_features
|
Maximum number of text features to construct.
TYPE:
|
text_features
|
Type of the text features. Can be either one of:
TYPE:
|
max_trees
|
Maximum number of trees to construct.
TYPE:
|
max_pairs
|
Maximum number of variable pairs to construct.
TYPE:
|
specific_pairs
|
User-specified pairs as a list of 2-tuples of feature names. If a given tuple
contains only one non-empty feature name, then it generates all the pairs
containing it (within the maximum limit
TYPE:
|
all_possible_pairs
|
If
TYPE:
|
group_target_value
|
Allows grouping of the target variable values in classification. It can substantially increase the training time.
TYPE:
|
discretization_method
|
Name of the discretization method in case of unsupervised analysis. Its valid values are: "MODL", "EqualWidth", "EqualFrequency" or "none". Ignored for supervised analysis.
TYPE:
|
grouping_method
|
Name of the grouping method in case of unsupervised analysis. Its valid values are: "MODL", "BasicGrouping" or "none". Ignored for supervised analysis.
TYPE:
|
max_parts
|
Maximum number of variable parts produced by preprocessing methods. If equal to 0 it is automatically calculated. Special default values for unsupervised analysis:
TYPE:
|
See Also
| RETURNS | DESCRIPTION |
|---|---|
tuple
|
A 2-tuple containing: - The reports file path - The modeling dictionary file path in the supervised case. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
Invalid values of an argument |
TypeError
|
Invalid type of an argument |
Examples:
See the following functions of the samples.py documentation script:
- samples.train_predictor()
- samples.train_predictor_file_paths()
- samples.train_predictor_error_handling()
- samples.train_predictor_mt()
- samples.train_predictor_mt_with_specific_rules()
- samples.train_predictor_with_train_percentage()
- samples.train_predictor_with_trees()
- samples.train_predictor_with_pairs()
- samples.train_predictor_with_multiple_parameters()
- samples.train_predictor_detect_format()
- samples.train_predictor_with_cross_validation()
- samples.multiple_train_predictor()
interpret_predictor(dictionary_file_path_or_domain, predictor_dictionary_name, interpretor_file_path, max_variable_importances=100, importance_ranking='Global', log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Builds an interpretation dictionary from a predictor
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
predictor_dictionary_name
|
Name of the predictor dictionary used while building the interpretation model.
TYPE:
|
interpretor_file_path
|
Path to the interpretor dictionary file.
TYPE:
|
max_variable_importances
|
Maximum number of variable importances to be selected in the interpretation model. If the predictor contains fewer variables than this number, then all the variables of the predictor are considered.
TYPE:
|
importance_ranking
|
Ranking of the Shapley values produced by the interpretor. Ca be one of: - "Global": predictor variables are ranked by decreasing global importance. - "Individual": predictor variables are ranked by decreasing individual Shapley value.
TYPE:
|
See Also
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
Invalid values of an argument |
TypeError
|
Invalid type of an argument |
Examples:
See the following functions of the samples.py documentation script:
- samples.interpret_predictor()
- samples.deploy_model_mt_with_interpretation()
reinforce_predictor(dictionary_file_path_or_domain, predictor_dictionary_name, reinforced_predictor_file_path, reinforcement_target_value='', reinforcement_lever_variables=None, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Builds a reinforced predictor from a predictor
A reinforced predictor is a model which increases the importance of specified lever variables in order to increase the probability of occurrence of the specified target value.
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
predictor_dictionary_name
|
Name of the predictor dictionary used while building the reinforced predictor.
TYPE:
|
reinforced_predictor_file_path
|
Path to the reinforced predictor dictionary file.
TYPE:
|
reinforcement_target_value
|
If this target value is specified, then its probability of occurrence is tentatively increased.
TYPE:
|
reinforcement_lever_variables
|
The names of variables to use as lever variables while building the reinforced predictor. Min length: 1. Max length: the total number of variables in the prediction model.
TYPE:
|
See Also
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
Invalid values of an argument |
TypeError
|
Invalid type of an argument |
Examples:
See the following functions of the samples.py documentation script:
- samples.reinforce_predictor()
- samples.deploy_reinforced_model_mt()
evaluate_predictor(dictionary_file_path_or_domain, train_dictionary_name, data_table_path, evaluation_report_file_path, detect_format=True, header_line=None, field_separator=None, sample_percentage=100.0, sampling_mode='Include sample', selection_variable='', selection_value='', additional_data_tables=None, main_target_value='', log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Evaluates the predictors in a dictionary file on a database
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
train_dictionary_name
|
Name of the main dictionary used while training the models.
TYPE:
|
data_table_path
|
Path of the evaluation data table file.
TYPE:
|
evaluation_report_file_path
|
Path (absolute path recommended) to the evaluation report file, in the JSON format. Note that a relative path will produce a report file in the current working directory.
TYPE:
|
detect_format
|
If
TYPE:
|
header_line
|
If
TYPE:
|
field_separator
|
A field separator character. "" has the same effect as "\t". Sets
TYPE:
|
sample_percentage
|
See
TYPE:
|
sampling_mode
|
If equal to "Include sample" it evaluates the predictor on
TYPE:
|
selection_variable
|
It trains with only the records such that the value of
TYPE:
|
selection_value
|
See
DEFAULT:
|
additional_data_tables
|
A dictionary containing the data paths and file paths for a multi-table dictionary file. For more details see Multi-Table Learning Primer. Note For external tables, use the initial dictionary name in the data paths, which is the same as the one used for training the predictor.
TYPE:
|
main_target_value
|
If this target value is specified then it guarantees the calculation of lift curves for it.
TYPE:
|
See Also
| RETURNS | DESCRIPTION |
|---|---|
str
|
The path of the JSON evaluation report (extension |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
Invalid type of an argument. |
Examples:
See the following functions of the samples.py documentation script:
- samples.evaluate_predictor()
- samples.access_predictor_evaluation_report()
- samples.train_predictor_with_cross_validation()
train_recoder(dictionary_file_path_or_domain, dictionary_name, data_table_path, target_variable, analysis_report_file_path, detect_format=True, header_line=None, field_separator=None, sample_percentage=100.0, sampling_mode='Include sample', selection_variable='', selection_value='', additional_data_tables=None, max_constructed_variables=100, construction_rules=None, max_text_features=10000, text_features='words', max_trees=10, max_pairs=0, all_possible_pairs=True, specific_pairs=None, informative_variables_only=True, max_variables=0, keep_initial_categorical_variables=False, keep_initial_numerical_variables=False, categorical_recoding_method='part Id', numerical_recoding_method='part Id', pairs_recoding_method='part Id', group_target_value=False, discretization_method='MODL', grouping_method='MODL', max_parts=0, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Trains a recoding model from a data table
A recoding model consists in the discretization of numerical variables and the grouping of categorical variables.
If the target_variable is specified these partitions are constructed in
supervised mode, meaning that each resulting discretizations/groupings best
separates the target variable while maintaining a simple interval/group model of the
data. Different recoding methods can be specified via the
numerical_recoding_method, categorical_recoding_method and
pairs_recoding_method options.
The output files of this process contain a dictionary file (.kdic) that can be
used to recode databases with the deploy_model function.
Note
For all input dictionaries, this function creates model dictionaries whose names
are prefixed with R_.
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
dictionary_name
|
Name of the dictionary to be recoded.
TYPE:
|
data_table_path
|
Path of the data table file.
TYPE:
|
target_variable
|
Name of the target variable. If equal to "" it trains an unsupervised recoder.
TYPE:
|
analysis_report_file_path
|
Path (absolute path recommended) to the analysis report file,
in the JSON format. An additional dictionary file with the same name and
extension
TYPE:
|
detect_format
|
If
TYPE:
|
header_line
|
If
TYPE:
|
field_separator
|
A field separator character. "" has the same effect as "\t". Sets
TYPE:
|
sample_percentage
|
See
TYPE:
|
sampling_mode
|
If equal to "Include sample" it trains the recoder on
TYPE:
|
selection_variable
|
It trains with only the records such that the value of
TYPE:
|
selection_value
|
See
DEFAULT:
|
additional_data_tables
|
A dictionary containing the data paths and file paths for a multi-table dictionary file. For more details see Multi-Table Learning Primer.
TYPE:
|
max_constructed_variables
|
Maximum number of variables to construct.
TYPE:
|
construction_rules
|
Allowed rules for the automatic variable construction. If not set, Khiops uses the multi-table construction rules listed in DEFAULT_CONSTRUCTION_RULES.
TYPE:
|
max_text_features
|
Maximum number of text features to construct.
TYPE:
|
text_features
|
Type of the text features. Can be either one of:
TYPE:
|
max_trees
|
Maximum number of trees to construct.
TYPE:
|
max_pairs
|
Maximum number of variable pairs to construct.
TYPE:
|
specific_pairs
|
User-specified pairs as a list of 2-tuples of feature names. If a given tuple
contains only one non-empty feature name, then it generates all the pairs
containing it (within the maximum limit
TYPE:
|
all_possible_pairs
|
If
TYPE:
|
group_target_value
|
Allows grouping of the target variable values in classification. It can substantially increase the training time.
TYPE:
|
informative_variables_only
|
If
TYPE:
|
max_variables
|
Maximum number of variables to keep. If equal to 0 keeps all variables.
TYPE:
|
keep_initial_categorical_variables
|
If
TYPE:
|
keep_initial_numerical_variables
|
If
TYPE:
|
categorical_recoding_method
|
Type of recoding for categorical variables. Types available:
TYPE:
|
numerical_recoding_method
|
Type of recoding recoding for numerical variables. Types available:
TYPE:
|
pairs_recoding_method
|
Type of recoding for bivariate variables. Types available:
TYPE:
|
discretization_method
|
Name of the discretization method in case of unsupervised analysis. Its valid values are: "MODL", "EqualWidth", "EqualFrequency" or "none". Ignored for supervised analysis.
TYPE:
|
grouping_method
|
Name of the grouping method in case of unsupervised analysis. Its valid values are: "MODL", "BasicGrouping" or "none". Ignored for supervised analysis.
TYPE:
|
max_parts
|
Maximum number of variable parts produced by preprocessing methods. If equal to 0 it is automatically calculated. Special default values for unsupervised analysis:
TYPE:
|
See Also
| RETURNS | DESCRIPTION |
|---|---|
tuple
|
A 2-tuple containing: |
Examples:
See the following functions of the samples.py documentation script:
- samples.train_recoder()
- samples.train_recoder_with_multiple_parameters()
- samples.train_recoder_mt_flatten()
deploy_model(dictionary_file_path_or_domain, dictionary_name, data_table_path, output_data_table_path, detect_format=True, header_line=None, field_separator=None, sample_percentage=100.0, sampling_mode='Include sample', selection_variable='', selection_value='', additional_data_tables=None, output_header_line=True, output_field_separator='\t', output_additional_data_tables=None, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Deploys a model on a data table
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object. This file/object defines the model to be deployed. Note that this model is not necessarily a predictor, it can be a generic table transformation.
TYPE:
|
dictionary_name
|
Name of the dictionary to be analyzed.
TYPE:
|
data_table_path
|
Path of the data table file.
TYPE:
|
output_data_table_path
|
Path (absolute path recommended) of the output data file. Note that a relative path will produce a file in the current working directory.
TYPE:
|
detect_format
|
If
TYPE:
|
header_line
|
If
TYPE:
|
field_separator
|
A field separator character. "" has the same effect as "\t". Sets
TYPE:
|
sample_percentage
|
See
TYPE:
|
sampling_mode
|
If equal to "Include sample" it deploys the model on
TYPE:
|
selection_variable
|
It deploys only the records such that the value of
TYPE:
|
selection_value
|
See
DEFAULT:
|
additional_data_tables
|
A dictionary containing the data paths and file paths for a multi-table dictionary file. For more details see Multi-Table Learning Primer. Note Use model dictionary data paths for external tables.
TYPE:
|
output_header_line
|
If
TYPE:
|
output_field_separator
|
The field separator character for the output table ("" counts as "\t").
TYPE:
|
output_additional_data_tables
|
A dictionary containing the output data paths and file paths for a multi-table dictionary file. For more details see Multi-Table Learning Primer.
TYPE:
|
See Also
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
Invalid type of an argument. |
Examples:
See the following functions of the samples.py documentation script:
- samples.deploy_model()
- samples.deploy_model_mt()
- samples.deploy_model_mt_with_interpretation()
- samples.deploy_model_mt_snowflake()
- samples.deploy_model_expert()
build_deployed_dictionary(dictionary_file_path_or_domain, dictionary_name, output_dictionary_file_path, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Builds a dictionary file to read the output table of a deployed model
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
dictionary_name
|
Name of the dictionary to be analyzed.
TYPE:
|
output_dictionary_file_path
|
Path (absolute path recommended) of the output dictionary file. Note that a relative path will produce a file in the current working directory.
TYPE:
|
See Also
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
Invalid type of an argument |
Examples:
See the following functions of the samples.py documentation script:
- samples.build_deployed_dictionary()
sort_data_table(dictionary_file_path_or_domain, dictionary_name, data_table_path, output_data_table_path, sort_variables=None, detect_format=True, header_line=None, field_separator=None, output_header_line=True, output_field_separator='\t', log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Sorts a data table
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
dictionary_name
|
Name of the dictionary to be analyzed.
TYPE:
|
data_table_path
|
Path of the data table file.
TYPE:
|
output_data_table_path
|
Path (absolute path recommended) of the output data file. Note that a relative path will produce a file in the current working directory.
TYPE:
|
sort_variables
|
The names of the variables to sort. If not set sorts the table by its key.
TYPE:
|
detect_format
|
If
TYPE:
|
header_line
|
If
TYPE:
|
field_separator
|
A field separator character. "" has the same effect as "\t". Sets
TYPE:
|
output_header_line
|
If
TYPE:
|
output_field_separator
|
The field separator character for the output table ("" counts as "\t").
TYPE:
|
See Also
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
Invalid type of a argument. |
Examples:
See the following functions of the samples.py documentation script:
- samples.sort_data_table()
- samples.sort_data_table_expert()
extract_keys_from_data_table(dictionary_file_path_or_domain, dictionary_name, data_table_path, output_data_table_path, detect_format=True, header_line=None, field_separator=None, output_header_line=True, output_field_separator='\t', log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Extracts from data table unique occurrences of a key variable
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
dictionary_name
|
Name of the dictionary of the data table.
TYPE:
|
data_table_path
|
Path of the data table file.
TYPE:
|
output_data_table_path
|
Path (absolute path recommended) of the output data file. Note that a relative path will produce a file in the current working directory.
TYPE:
|
detect_format
|
If
TYPE:
|
header_line
|
If
TYPE:
|
field_separator
|
A field separator character. "" has the same effect as "\t". Sets
TYPE:
|
output_header_line
|
If
TYPE:
|
output_field_separator
|
The field separator character for the output table ("" counts as "\t").
TYPE:
|
See Also
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
Invalid type of an argument. |
Examples:
See the following function of the samples.py documentation script:
- samples.extract_keys_from_data_table()
train_coclustering(dictionary_file_path_or_domain, dictionary_name, data_table_path, coclustering_variables, coclustering_report_file_path, detect_format=True, header_line=None, field_separator=None, sample_percentage=100.0, sampling_mode='Include sample', selection_variable='', selection_value='', additional_data_tables=None, frequency_variable='', min_optimization_time=0, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Trains a coclustering model from a data table
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
dictionary_name
|
Name of the dictionary to be analyzed.
TYPE:
|
data_table_path
|
Path of the data table file.
TYPE:
|
coclustering_variables
|
The names of variables to use in coclustering. Min length: 2. Max length: 10.
TYPE:
|
coclustering_report_file_path
|
Path (absolute path recommended) to the coclustering report file, in the JSON format. Note that a relative path will produce a report file in the current working directory.
TYPE:
|
detect_format
|
If
TYPE:
|
header_line
|
If
TYPE:
|
field_separator
|
A field separator character. "" has the same effect as "\t". Sets
TYPE:
|
sample_percentage
|
See
TYPE:
|
sampling_mode
|
If equal to "Include sample" it trains the coclustering estimator on
TYPE:
|
selection_variable
|
It trains with only the records such that the value of
TYPE:
|
selection_value
|
See
DEFAULT:
|
additional_data_tables
|
A dictionary containing the data paths and file paths for a multi-table dictionary file. For more details see Multi-Table Learning Primer.
TYPE:
|
frequency_variable
|
Name of frequency variable.
TYPE:
|
min_optimization_time
|
Minimum optimization time in seconds.
TYPE:
|
See Also
| RETURNS | DESCRIPTION |
|---|---|
str
|
The path of the of the resulting coclustering file. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
Number of coclustering variables out of the range 2-10. |
TypeError
|
Invalid type of an argument. |
Examples:
See the following function of the samples.py documentation script:
- samples.train_coclustering()
train_instance_variable_coclustering(dictionary_file_path_or_domain, dictionary_name, data_table_path, coclustering_report_file_path, detect_format=True, header_line=None, field_separator=None, sample_percentage=100.0, sampling_mode='Include sample', selection_variable='', selection_value='', additional_data_tables=None, min_optimization_time=0, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Trains an instance-variable coclustering model from a data table
Note
If keys are available in the input dictionary, they are used as instance identifiers. Otherwise, line numbers in the instance data table are used as instance idenfitiers.
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
dictionary_name
|
Name of the dictionary to be analyzed.
TYPE:
|
data_table_path
|
Path of the data table file.
TYPE:
|
coclustering_report_file_path
|
Path (absolute path recommended) to the coclustering report file, in the JSON format. Note that a relative path will produce a report file in the current working directory.
TYPE:
|
detect_format
|
If
TYPE:
|
header_line
|
If
TYPE:
|
field_separator
|
A field separator character. "" has the same effect as "\t". Sets
TYPE:
|
sample_percentage
|
See
TYPE:
|
sampling_mode
|
If equal to "Include sample" it trains the coclustering estimator on
TYPE:
|
selection_variable
|
It trains with only the records such that the value of
TYPE:
|
selection_value
|
See
DEFAULT:
|
additional_data_tables
|
A dictionary containing the data paths and file paths for a multi-table dictionary file. For more details see Multi-Table Learning Primer.
TYPE:
|
min_optimization_time
|
Minimum optimization time in seconds.
TYPE:
|
See Also
| RETURNS | DESCRIPTION |
|---|---|
str
|
The path of the of the resulting coclustering file. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
Number of coclustering variables out of the range 2-10. |
TypeError
|
Invalid type of an argument. |
Examples:
See the following function of the samples.py documentation script:
- samples.train_instance_variable_coclustering()
simplify_coclustering(coclustering_file_path, simplified_coclustering_file_path, results_dir=None, max_preserved_information=0, max_cells=0, max_total_parts=0, max_part_numbers=None, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Simplifies a coclustering model
| PARAMETER | DESCRIPTION |
|---|---|
coclustering_file_path
|
Path of the coclustering file (extension
TYPE:
|
simplified_coclustering_file_path
|
Path (absolute path recommended) of the output coclustering file. Note that a relative path will produce a report file in the current working directory.
TYPE:
|
max_preserved_information
|
Maximum information preserve in the simplified coclustering. If equal to 0 there is no limit.
TYPE:
|
max_cells
|
Maximum number of cells in the simplified coclustering. If equal to 0 there is no limit.
TYPE:
|
max_total_parts
|
Maximum number of parts totaled over all variables. If equal to 0 there is no limit.
TYPE:
|
max_part_numbers
|
Dictionary that associate variable names to their maximum number of parts to preserve in the simplified coclustering. If not set there is no limit.
TYPE:
|
See Also
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
Invalid type of an argument. |
Examples:
See the following function of the samples.py documentation script:
- samples.simplify_coclustering()
prepare_coclustering_deployment(dictionary_file_path_or_domain, dictionary_name, coclustering_file_path, table_variable, deployed_variable_name, coclustering_dictionary_file_path, max_preserved_information=0, max_cells=0, max_total_parts=0, max_part_numbers=None, build_cluster_variable=True, build_distance_variables=False, build_frequency_variables=False, variables_prefix='', log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Prepares a individual-variable coclustering deployment
| PARAMETER | DESCRIPTION |
|---|---|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
dictionary_name
|
Name of the dictionary to be analyzed.
TYPE:
|
coclustering_file_path
|
Path of the coclustering model file (extension
TYPE:
|
table_variable
|
Name of the table variable in the dictionary.
TYPE:
|
deployed_variable_name
|
Name of the coclustering variable to deploy.
TYPE:
|
coclustering_dictionary_file_path
|
Path of the coclustering dictionary file for deployment.
TYPE:
|
max_preserved_information
|
Maximum information preserve in the simplified coclustering. If equal to 0 there is no limit.
TYPE:
|
max_cells
|
Maximum number of cells in the simplified coclustering. If equal to 0 there is no limit.
TYPE:
|
max_total_parts
|
Maximum number of parts totaled over all variables. If equal to 0 there is no limit.
TYPE:
|
max_part_numbers
|
Dictionary associating variable names to their maximum number of parts
to preserve in the simplified coclustering. For variables not present
in
TYPE:
|
build_cluster_variable
|
If
TYPE:
|
build_distance_variables
|
If
TYPE:
|
build_frequency_variables
|
If
TYPE:
|
variables_prefix
|
Prefix for the variables in the deployment dictionary.
TYPE:
|
See Also
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
Invalid type of an argument |
Examples:
See the following function of the samples.py documentation script:
- samples.deploy_model_expert()
extract_clusters(coclustering_file_path, cluster_variable, clusters_file_path, max_preserved_information=0, max_cells=0, max_total_parts=0, max_part_numbers=None, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Extracts clusters to a tab separated (TSV) file
| PARAMETER | DESCRIPTION |
|---|---|
coclustering_file_path
|
Path of the coclustering model file (extension
TYPE:
|
cluster_variable
|
Name of the variable for which the clusters are extracted.
TYPE:
|
clusters_file_path
|
Path (absolute path recommended) of the output clusters TSV file. Note that a relative path will produce a file in the current working directory.
TYPE:
|
max_preserved_information
|
Maximum information preserve in the simplified coclustering. If equal to 0 there is no limit.
TYPE:
|
max_cells
|
Maximum number of cells in the simplified coclustering. If equal to 0 there is no limit.
TYPE:
|
max_total_parts
|
Maximum number of parts totaled over all variables. If equal to 0 there is no limit.
TYPE:
|
max_part_numbers
|
Dictionary that associate variable names to their maximum number of parts to preserve in the simplified coclustering. If not set there is no limit.
TYPE:
|
See Also
Examples:
See the following function of the samples.py documentation script:
- samples.extract_clusters()
detect_data_table_format(data_table_path, dictionary_file_path_or_domain=None, dictionary_name=None, log_file_path=None, output_scenario_path=None, task_file_path=None, trace=False, stdout_file_path='', stderr_file_path='', max_cores=None, memory_limit_mb=None, temp_dir='', scenario_prologue='', **kwargs)
Detects the format of a data table
Runs an heuristic to detect the format of a data table. The detection heuristic is more accurate if a dictionary with the table schema is provided.
| PARAMETER | DESCRIPTION |
|---|---|
data_table_path
|
Path of the data table file.
TYPE:
|
dictionary_file_path_or_domain
|
Path of a Khiops dictionary file or a DictionaryDomain object.
TYPE:
|
dictionary_name
|
Name of the dictionary.
TYPE:
|
See Also
| RETURNS | DESCRIPTION |
|---|---|
tuple
|
A 2-tuple containing:
- the These are exactly the parameters expected in many Khiops Python API functions. |
Examples:
See the following function of the samples.py documentation script:
- samples.detect_data_table_format()