Ejemplo n.º 1
0
 def test_transform_schema_higher_order(self):
     from lale.datasets.data_schemas import to_schema
     inner = LogisticRegression
     outer = IdentityWrapper(op=LogisticRegression)
     input_schema = to_schema(self._digits['X'])
     transformed_inner = inner.transform_schema(input_schema)
     transformed_outer = outer.transform_schema(input_schema)
     self.maxDiff = None
     self.assertEqual(transformed_inner, transformed_outer)
Ejemplo n.º 2
0
    def test_transform_schema_higher_order(self):
        with EnableSchemaValidation():
            from lale.datasets.data_schemas import to_schema

            inner = LogisticRegression
            outer = IdentityWrapper(op=LogisticRegression)
            digits = self._digits
            assert digits is not None
            input_schema = to_schema(digits["X"])
            transformed_inner = inner.transform_schema(input_schema)
            transformed_outer = outer.transform_schema(input_schema)
            self.maxDiff = None
            self.assertEqual(transformed_inner, transformed_outer)
Ejemplo n.º 3
0
    def test_transform_schema_higher_order(self):
        from lale.datasets.data_schemas import to_schema

        existing_flag = disable_data_schema_validation
        set_disable_data_schema_validation(False)

        inner = LogisticRegression
        outer = IdentityWrapper(op=LogisticRegression)
        input_schema = to_schema(self._digits["X"])
        transformed_inner = inner.transform_schema(input_schema)
        transformed_outer = outer.transform_schema(input_schema)
        self.maxDiff = None
        self.assertEqual(transformed_inner, transformed_outer)
        set_disable_data_schema_validation(existing_flag)
Ejemplo n.º 4
0
 def test_input_schema_fit(self):
     self.maxDiff = None
     self.assertEqual(
         LogisticRegression.input_schema_fit(),
         LogisticRegression.get_schema("input_fit"),
     )
     self.assertEqual(
         (NMF >> LogisticRegression).input_schema_fit(), NMF.get_schema("input_fit")
     )
     self.assertEqual(
         IdentityWrapper(op=LogisticRegression).input_schema_fit(),
         LogisticRegression.get_schema("input_fit"),
     )
     actual = (TfidfVectorizer | NMF).input_schema_fit()
     expected = {
         "anyOf": [
             {
                 "type": "object",
                 "required": ["X"],
                 "additionalProperties": False,
                 "properties": {
                     "X": {
                         "anyOf": [
                             {"type": "array", "items": {"type": "string"}},
                             {
                                 "type": "array",
                                 "items": {
                                     "type": "array",
                                     "minItems": 1,
                                     "maxItems": 1,
                                     "items": {"type": "string"},
                                 },
                             },
                         ]
                     },
                     "y": {},
                 },
             },
             {
                 "type": "object",
                 "required": ["X"],
                 "additionalProperties": False,
                 "properties": {
                     "X": {
                         "type": "array",
                         "items": {
                             "type": "array",
                             "items": {"type": "number", "minimum": 0.0},
                         },
                     },
                     "y": {},
                 },
             },
         ]
     }
     self.assertEqual(actual, expected)
Ejemplo n.º 5
0
 def test_input_schema_fit(self):
     self.maxDiff = None
     self.assertEqual(LogisticRegression.input_schema_fit(),
                      LogisticRegression.get_schema('input_fit'))
     self.assertEqual((NMF >> LogisticRegression).input_schema_fit(),
                      NMF.get_schema('input_fit'))
     self.assertEqual(
         IdentityWrapper(op=LogisticRegression).input_schema_fit(),
         LogisticRegression.get_schema('input_fit'))
     actual = (TfidfVectorizer | NMF).input_schema_fit()
     expected = {
         'anyOf': [{
             'type': 'object',
             'required': ['X'],
             'additionalProperties': False,
             'properties': {
                 'X': {
                     'anyOf': [{
                         'type': 'array',
                         'items': {
                             'type': 'string'
                         }
                     }, {
                         'type': 'array',
                         'items': {
                             'type': 'array',
                             'minItems': 1,
                             'maxItems': 1,
                             'items': {
                                 'type': 'string'
                             }
                         }
                     }]
                 },
                 'y': {}
             }
         }, {
             'type': 'object',
             'required': ['X'],
             'additionalProperties': False,
             'properties': {
                 'X': {
                     'type': 'array',
                     'items': {
                         'type': 'array',
                         'items': {
                             'type': 'number',
                             'minimum': 0.0
                         }
                     }
                 },
                 'y': {}
             }
         }]
     }
     self.assertEqual(actual, expected)