The Python module PyYAML can be used to process ".yml" or ".yaml" file. You can use the safe_load() function of this module to read data from the file. The safe_load() function returns a dictionary.
Here is an example:
import yaml
with open('data/inp.yml', 'r') as fyml:
config = yaml.safe_load(fyml)
print(config)
In the "inp.yml" file, I have the following data:
XGB_params:
n_jobs: 2
max_depth: 3
random_state: 101
The output of the above code is:
{'XGB_params': {'n_jobs': 2, 'max_depth': 3, 'random_state': 101}}