Esempio n. 1
0
    def get_params(self, deep: bool = True) -> Dict[str, Any]:
        out = {}
        out["variables"] = self._variables

        if deep:
            deep_stuff: Dict[str, Any] = {}
            for k, v in self._variables.items():
                deep_stuff.update(nest_HPparams(k, v.get_params(deep=deep)))

            out.update(deep_stuff)
        return out
Esempio n. 2
0
    def test_deep_planned_nested_indiv_operator(self):
        from lale.lib.sklearn import BaggingClassifier, DecisionTreeClassifier

        dtc = DecisionTreeClassifier()
        clf = BaggingClassifier(base_estimator=dtc)
        params = clf.get_params(deep=True)
        filtered_params = self.remove_lale_params(params)

        # expected = LogisticRegression.get_defaults()
        base = filtered_params["base_estimator"]
        base_params = self.remove_lale_params(base.get_params(deep=True))
        nested_base_params = nest_HPparams("base_estimator", base_params)
        self.assertDictEqual(
            {
                k: v
                for k, v in filtered_params.items()
                if k.startswith("base_estimator__")
                and not k.startswith("base_estimator___lale")
            },
            nested_base_params,
        )