Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema validation for bare sparseness constraint #838

Open
hirzel opened this issue Oct 4, 2021 · 0 comments
Open

schema validation for bare sparseness constraint #838

hirzel opened this issue Oct 4, 2021 · 0 comments

Comments

@hirzel
Copy link
Member

hirzel commented Oct 4, 2021

Currently, schema-checking raises an internal assertion for constraints of the form X/isSparse that are "bare", i.e., not inside of an anyOf.

Test to reproduce:

import jsonschema
import scipy.sparse
import sklearn.datasets
import sklearn.decomposition
import unittest
import lale.lib.sklearn

class TestBareSparsenessConstraint(unittest.TestCase):
    def setUp(self):
        X, y = sklearn.datasets.load_iris(return_X_y=True)
        self.sparse_X = scipy.sparse.csr_matrix(X)
        self.y = y

    def test_bare_sparseness_constraint(self):
        #without Lale
        trainable = sklearn.decomposition.PCA()
        with self.assertRaisesRegex(TypeError, "PCA does not support sparse"):
            trained = trainable.fit(self.sparse_X, self.y)
        #with Lale and schema validation
        with EnableSchemaValidation():
            trainable = lale.lib.sklearn.PCA()
            with self.assertRaises(jsonschema.ValidationError):
                trained = trainable.fit(self.sparse_X, self.y)

Output:

  File "lale/lale/operators.py", line 1984, in _validate_hyperparams
    assert e.schema_path[2] == "anyOf"
AssertionError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant