Any example on how to use DSSFilterBuilder ?

gnaldi62
gnaldi62 Partner, L2 Designer, Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Frontrunner 2022 Participant, Neuron 2023 Posts: 79 Neuron

Hi all,
we'd need to automatically change the dates related to the split between train and test of a visual ML model.
So far we've been able to get the raw details of the split via code similar to the following:

...
client = dataiku.api_client()
current_project = client.get_default_project()
my_model = current_project.get_ml_task('myAnalysisID', 'myTaskId')
split_params = my_model.get_settings().get_split_params().get_raw()

We then would need to change the values of a couple of dates in order to reflect a new split, but we are stuck here.
It seems we would need to use the class dataikuapi.dss.utils.DSSFilterBuilder, but we cannot find anywhere a reference on how to initialize nor to use it. Any ideas/suggestions ?
Thanks for your help. Best Regards.

Giuseppe

P.S.: we would like to keep the visual analysis rather than translating everything into a Python recipe.

Best Answer

  • Clément_Stenac
    Clément_Stenac Dataiker, Dataiku DSS Core Designer, Registered Posts: 753 Dataiker
    edited July 17 Answer ✓

    Hi,

    For updating an existing filter, it's easier, you can access the current definition of the filter in:

    split_params.get_raw()["efsdTrain"]["filter"]["uiData"]

    Ditto for "efsdTest".

    "efsdTrain/efsdTest" are used for "Explicit Filter Single Dataset". If you are using "Explicit Filter Two Datasets", you need to use "eftdTrain" and "eftdTest"

    For example, a "Pclass contains 1" filter translates to this value for uiData:

    {
      "mode": "&&",
      "conditions": [
        {
          "input": "Pclass",
          "operator": "contains",
          "string": "1"
        }
      ]
    }

    So switching that to "2" would be:

    settings = mltask.get_settings()
    split_params = settings.get_split_params()
    
    split_params.get_raw()["efsdTrain"]["filter"]["uiData"]["conditions"][0]["string"] = "2"
    
    settings.save()

    Hope this helps

Answers

  • gnaldi62
    gnaldi62 Partner, L2 Designer, Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Frontrunner 2022 Participant, Neuron 2023 Posts: 79 Neuron

    Hi Clémemt,
    thanks for the quick reply. Best Regards.

    Giuseppe

Setup Info
    Tags
      Help me…