flexcv.utilities
flexcv.utilities.add_model_to_keys(param_grid)
This function adds the string "model__" to avery key of the param_grid dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param_grid |
dict
|
A dictionary of parameters for a model. |
required |
Returns:
Type | Description |
---|---|
dict
|
A dictionary of parameters for a model with the string "model__" added to each key. |
Source code in flexcv/utilities.py
flexcv.utilities.add_module_handlers(logger)
Adds handlers to the logger for the module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logger |
Logger
|
logging.Logger: The logger for the module. |
required |
Returns:
Type | Description |
---|---|
None
|
(None) |
Source code in flexcv/utilities.py
flexcv.utilities.get_fixed_effects_formula(target_name, X_data)
Returns the fixed effects formula for the dataset.
Scheme: "target ~ column1 + column2 + ...
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_name |
str: The name of the target variable in the dataset. |
required | |
X_data |
pd.DataFrame: The feature matrix. |
required |
Returns:
Type | Description |
---|---|
str
|
The fixed effects formula. |
Source code in flexcv/utilities.py
flexcv.utilities.get_re_formula(random_slopes_data)
Returns a random effects formula for use in statsmodels. Scheme: ~ random_slope1 + random_slope2 + ... Returns an empty string if no random slopes are provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
random_slopes_data |
pd.Series | pd.DataFrame: The random slopes data. |
required |
Returns:
Type | Description |
---|---|
str
|
The random effects formula. |
Source code in flexcv/utilities.py
flexcv.utilities.get_repeated_cv_metadata(str_children='Instance of repeated run ', api_dict=None)
This function can be used to fetch metadata from repeated cross-validation runs. We use it to get the ids of the children runs and their descriptions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
str_children |
str
|
The string that is prepended to the description of each child run. |
'Instance of repeated run '
|
api_dict |
dict
|
A dictionary containing the Neptune.ai project name and the api token. |
None
|
Source code in flexcv/utilities.py
flexcv.utilities.handle_duplicate_kwargs(*args)
This function removes duplicate kwargs from mutiple dicts. If a key is present in multiple dicts, we check if the values are the same. If they are, we keep the key-value pair. If they are not, we raise a ValueError.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs |
dict
|
A dict of kwargs. |
required |
Returns:
Type | Description |
---|---|
dict
|
The dict without duplicate kwargs. |
Source code in flexcv/utilities.py
flexcv.utilities.pformat_dict(d, indent='')
Pretty-format a dictionary, only printing values that are themselves dictionaries.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d |
dict
|
dictionary to print |
required |
indent |
str
|
Level of indentation for use with recursion (Default value = "") |
''
|
Returns:
Source code in flexcv/utilities.py
flexcv.utilities.rm_model_from_keys(param_grid)
This function removes the string "model__" from avery key of the param_grid dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param_grid |
dict
|
A dictionary of parameters for a model. |
required |
Returns:
Type | Description |
---|---|
dict
|
A dictionary of parameters for a model with the string "model__" removed from each key. |
Source code in flexcv/utilities.py
flexcv.utilities.run_padding(func)
Decorator to add padding to the output of a function. Helps to visually separate the output of different functions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Any callable. |
required |
Returns:
Type | Description |
---|---|
Any
|
Return value of the passed callable. |