eland icon indicating copy to clipboard operation
eland copied to clipboard

added from_dict() method to LTRModelConfig

Open aarondelgiudice opened this issue 3 months ago • 1 comments

from_dict() method adds support for instantiating a LTRModelConfig object from a dictionary. Allows users to easily export/import LTRModelConfig objects as json objects.

Examples
--------
>>> from eland.ml.ltr import LTRModelConfig, QueryFeatureExtractor

>>> ltr_model_config = LTRModelConfig(
...     feature_extractors=[
...        QueryFeatureExtractor(
...            feature_name='title_bm25',
...            query={ "match": { "title": "{{query}}" } }
...        ),
...        QueryFeatureExtractor(
...            feature_name='descritption_bm25',
...            query={ "match": { "description": "{{query}}" } }
...        )
...     ]
... )
... # Optional, export 'ltr_model_config.to_dict()' to JSON for version control
...
... config_dict = < load config_dict from JSON>
... 
... # instantiate a new LTRModelConfig object
... ltr_model_config2 = LTRModelConfig.from_dict(config_dict)

Closes issues 807

aarondelgiudice avatar Sep 24 '25 17:09 aarondelgiudice

:tada: Snyk checks have passed. No issues have been found so far.

:white_check_mark: security/snyk check is complete. No issues have been found. (View Details)

:white_check_mark: license/snyk check is complete. No issues have been found. (View Details)

prodsecmachine avatar Sep 24 '25 17:09 prodsecmachine