<jupyter_start><jupyter_text>I want to extract possible parameters straight from a method. In this way, the default configuration for MERCS can always be deduced automatically and I do not need to share parameter names across methods anymore. For plotting, this will be a bit of a nuissance, but so be it. A parameters is what it is, and should be called with its proper name.<jupyter_code>from inspect import signature
def foobar(X, parameter_one=None, parameter_two=8, iterations=100, **kwargs):
    
    result=0
    for i in range(iterations):
        result+=parameter_one
        result*=parameter_two
    return result+X
foobar(1,2,1, 10)
sgn = signature(foobar)
config = {}
for key, parameter in sgn.parameters.items():
    print(parameter.kind)
    if parameter.default is not parameter.empty:
        config[key] = parameter.default
config
var.KEYWORD_ONLY
config
d = dict(sgn.parameters)
d['iterations'].default
dir(sgn)
kwargs = dict(random_state=997, prediction_algorithm='rw', clf_criterion='gini')
prefixes = ['clf', 'classification']
delimiter='_'

parameter_map = {x.split(prefix+delimiter)[1]: x for x in d for prefix in prefixes if x.startswith(prefix)}
parameter_map<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09375, 'fraction_numerical': 0.011513157894736841, 'mean_word_length': 5.054726368159204, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '117412', 'license': 'MIT', 'n_tokens_mistral': 376, 'n_tokens_neox': 360, 'n_words': 128, 'path': 'note/dev/190517 - extract-config-from-method.ipynb', 'repo_name': 'eliavw/morpheus', 'size': '1216'}