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

Scarliles/honesty #69

Draft
wants to merge 85 commits into
base: submodulev3
Choose a base branch
from

commented out some flaky tests in tree which now fail. correct covera…

7059bf7
Select commit
Loading
Failed to load commit list.
Draft

Scarliles/honesty #69

commented out some flaky tests in tree which now fail. correct covera…
7059bf7
Select commit
Loading
Failed to load commit list.
Azure Pipelines / neurodata.scikit-learn failed Dec 31, 2024 in 34m 12s

Build #20241231.4 had test failures

Details

Tests

  • Failed: 60 (0.16%)
  • Passed: 35,612 (93.16%)
  • Other: 2,556 (6.69%)
  • Total: 38,228

Annotations

Check failure on line 7699 in Build log

See this annotation in the file changed.

@azure-pipelines azure-pipelines / neurodata.scikit-learn

Build log #L7699

Bash exited with code '1'.

Check failure on line 1506 in Build log

See this annotation in the file changed.

@azure-pipelines azure-pipelines / neurodata.scikit-learn

Build log #L1506

Bash exited with code '1'.

Check failure on line 1 in test_missing_value_is_predictive[ExtraTreesRegressor]

See this annotation in the file changed.

@azure-pipelines azure-pipelines / neurodata.scikit-learn

test_missing_value_is_predictive[ExtraTreesRegressor]

AssertionError
Raw output
Forest = <class 'sklearn.ensemble._forest.ExtraTreesRegressor'>

    @pytest.mark.parametrize(
        "Forest",
        [
            RandomForestClassifier,
            RandomForestRegressor,
            ExtraTreesRegressor,
            ExtraTreesClassifier,
        ],
    )
    def test_missing_value_is_predictive(Forest):
        """Check that the forest learns when missing values are only present for
        a predictive feature."""
        rng = np.random.RandomState(0)
        n_samples = 300
        expected_score = 0.75
    
        X_non_predictive = rng.standard_normal(size=(n_samples, 10))
        y = rng.randint(0, high=2, size=n_samples)
    
        # Create a predictive feature using `y` and with some noise
        X_random_mask = rng.choice([False, True], size=n_samples, p=[0.95, 0.05])
        y_mask = y.astype(bool)
        y_mask[X_random_mask] = ~y_mask[X_random_mask]
    
        predictive_feature = rng.standard_normal(size=n_samples)
        predictive_feature[y_mask] = np.nan
        assert np.isnan(predictive_feature).any()
    
        X_predictive = X_non_predictive.copy()
        X_predictive[:, 5] = predictive_feature
    
        (
            X_predictive_train,
            X_predictive_test,
            X_non_predictive_train,
            X_non_predictive_test,
            y_train,
            y_test,
        ) = train_test_split(X_predictive, X_non_predictive, y, random_state=0)
        forest_predictive = Forest(random_state=0).fit(X_predictive_train, y_train)
        forest_non_predictive = Forest(random_state=0).fit(X_non_predictive_train, y_train)
    
        predictive_test_score = forest_predictive.score(X_predictive_test, y_test)
    
>       assert predictive_test_score >= expected_score
E       AssertionError

Forest     = <class 'sklearn.ensemble._forest.ExtraTreesRegressor'>
X_non_predictive = array([[ 1.76405235,  0.40015721,  0.97873798, ..., -0.15135721,
        -0.10321885,  0.4105985 ],
       [ 0.1440435...144, -1.57760707],
       [-0.34056003, -1.30322008,  0.46675065, ..., -0.19240421,
        -1.21251574, -0.08059852]])
X_non_predictive_test = array([[ 3.25799614e-01,  1.24769521e-01, -1.01267312e+00,
        -1.02729688e+00,  3.23356531e-01, -1.36939112e+00,
... 5.42610783e-01,  7.15938893e-01,
        -2.99461286e+00,  8.80937561e-01,  1.80813181e+00,
         4.36638475e-01]])
X_non_predictive_train = array([[ 0.94231431, -2.00512543,  0.75504968, ...,  0.39756522,
        -1.02285504, -1.150692  ],
       [ 0.2804417...406,  0.49600095],
       [-0.83963245, -1.3682451 ,  1.5612796 , ..., -0.25631689,
         0.46079433, -0.40098616]])
X_predictive = array([[ 1.76405235,  0.40015721,  0.97873798, ..., -0.15135721,
        -0.10321885,  0.4105985 ],
       [ 0.1440435...144, -1.57760707],
       [-0.34056003, -1.30322008,  0.46675065, ..., -0.19240421,
        -1.21251574, -0.08059852]])
X_predictive_test = array([[ 3.25799614e-01,  1.24769521e-01, -1.01267312e+00,
        -1.02729688e+00,  3.23356531e-01, -1.71864988e+00,
... 5.42610783e-01,  2.08233171e-01,
        -2.99461286e+00,  8.80937561e-01,  1.80813181e+00,
         4.36638475e-01]])
X_predictive_train = array([[ 0.94231431, -2.00512543,  0.75504968, ...,  0.39756522,
        -1.02285504, -1.150692  ],
       [ 0.2804417...406,  0.49600095],
       [-0.83963245, -1.3682451 ,  1.5612796 , ..., -0.25631689,
         0.46079433, -0.40098616]])
X_random_mask = array([False, False, False, False, False, False, False, False, False,
       False, False, False, False, False, False,...False, False, False,
       False, False, False, False, False, False, False, False, False,
       False, False, False])
expected_score = 0.75
forest_non_predictive = ExtraTreesRegressor(random_state=0)
forest_predictive = ExtraTreesRegressor(random_state=0)
n_samples  = 300
predictive_feature = array([        nan,         nan,         nan,         nan, -0.33406295,
               nan, -0.83677104,         nan, ...   nan,         nan, -0.

Check failure on line 1 in test_estimators[ExtraTreeClassifier()-check_no_attributes_set_in_init]

See this annotation in the file changed.

@azure-pipelines azure-pipelines / neurodata.scikit-learn

test_estimators[ExtraTreeClassifier()-check_no_attributes_set_in_init]

AssertionError: Estimator ExtraTreeClassifier should not set any attribute apart from parameters during init. Found attributes ['postsplit_conditions', 'presplit_conditions', 'splitter_listeners', 'tree_build_listeners'].
Raw output
estimator = ExtraTreeClassifier()
check = functools.partial(<function check_no_attributes_set_in_init at 0x7f6583504720>, 'ExtraTreeClassifier')
request = <FixtureRequest for <Function test_estimators[ExtraTreeClassifier()-check_no_attributes_set_in_init]>>

    @parametrize_with_checks(list(_tested_estimators()))
    def test_estimators(estimator, check, request):
        # Common tests for estimator instances
        with ignore_warnings(
            category=(FutureWarning, ConvergenceWarning, UserWarning, LinAlgWarning)
        ):
>           check(estimator)

check      = functools.partial(<function check_no_attributes_set_in_init at 0x7f6583504720>, 'ExtraTreeClassifier')
estimator  = ExtraTreeClassifier()
request    = <FixtureRequest for <Function test_estimators[ExtraTreeClassifier()-check_no_attributes_set_in_init]>>

../1/s/sklearn/tests/test_common.py:127: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../1/s/sklearn/utils/_testing.py:147: in wrapper
    return fn(*args, **kwargs)
        args       = ('ExtraTreeClassifier', ExtraTreeClassifier())
        fn         = <function check_no_attributes_set_in_init at 0x7f6583504680>
        kwargs     = {}
        self       = _IgnoreWarnings(record=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'ExtraTreeClassifier', estimator_orig = ExtraTreeClassifier()

    @ignore_warnings(category=FutureWarning)
    def check_no_attributes_set_in_init(name, estimator_orig):
        """Check setting during init."""
        try:
            # Clone fails if the estimator does not store
            # all parameters as an attribute during init
            estimator = clone(estimator_orig)
        except AttributeError:
            raise AttributeError(
                f"Estimator {name} should store all parameters as an attribute during init."
            )
    
        if hasattr(type(estimator).__init__, "deprecated_original"):
            return
    
        init_params = _get_args(type(estimator).__init__)
        parents_init_params = [
            param
            for params_parent in (_get_args(parent) for parent in type(estimator).__mro__)
            for param in params_parent
        ]
    
        # Test for no setting apart from parameters during init
        invalid_attr = set(vars(estimator)) - set(init_params) - set(parents_init_params)
        # Ignore private attributes
        invalid_attr = set([attr for attr in invalid_attr if not attr.startswith("_")])
>       assert not invalid_attr, (
            "Estimator %s should not set any attribute apart"
            " from parameters during init. Found attributes %s."
            % (name, sorted(invalid_attr))
        )
E       AssertionError: Estimator ExtraTreeClassifier should not set any attribute apart from parameters during init. Found attributes ['postsplit_conditions', 'presplit_conditions', 'splitter_listeners', 'tree_build_listeners'].

estimator  = ExtraTreeClassifier()
estimator_orig = ExtraTreeClassifier()
init_params = ['self', 'criterion', 'splitter', 'max_depth', 'min_samples_split', 'min_samples_leaf', ...]
invalid_attr = {'postsplit_conditions', 'presplit_conditions', 'splitter_listeners', 'tree_build_listeners'}
name       = 'ExtraTreeClassifier'
parents_init_params = ['criterion', 'splitter', 'max_depth', 'min_samples_split', 'min_samples_leaf', 'min_weight_fraction_leaf', ...]

../1/s/sklearn/utils/estimator_checks.py:3183: AssertionError

Check failure on line 1 in test_estimators[DecisionTreeClassifier()-check_no_attributes_set_in_init]

See this annotation in the file changed.

@azure-pipelines azure-pipelines / neurodata.scikit-learn

test_estimators[DecisionTreeClassifier()-check_no_attributes_set_in_init]

AssertionError: Estimator DecisionTreeClassifier should not set any attribute apart from parameters during init. Found attributes ['postsplit_conditions', 'presplit_conditions', 'splitter_listeners', 'tree_build_listeners'].
Raw output
estimator = DecisionTreeClassifier()
check = functools.partial(<function check_no_attributes_set_in_init at 0x7f4c96ee85e0>, 'DecisionTreeClassifier')
request = <FixtureRequest for <Function test_estimators[DecisionTreeClassifier()-check_no_attributes_set_in_init]>>

    @parametrize_with_checks(list(_tested_estimators()))
    def test_estimators(estimator, check, request):
        # Common tests for estimator instances
        with ignore_warnings(
            category=(FutureWarning, ConvergenceWarning, UserWarning, LinAlgWarning)
        ):
>           check(estimator)

check      = functools.partial(<function check_no_attributes_set_in_init at 0x7f4c96ee85e0>, 'DecisionTreeClassifier')
estimator  = DecisionTreeClassifier()
request    = <FixtureRequest for <Function test_estimators[DecisionTreeClassifier()-check_no_attributes_set_in_init]>>

../1/s/sklearn/tests/test_common.py:127: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../1/s/sklearn/utils/_testing.py:147: in wrapper
    return fn(*args, **kwargs)
        args       = ('DecisionTreeClassifier', DecisionTreeClassifier())
        fn         = <function check_no_attributes_set_in_init at 0x7f4c96ee8540>
        kwargs     = {}
        self       = _IgnoreWarnings(record=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'DecisionTreeClassifier', estimator_orig = DecisionTreeClassifier()

    @ignore_warnings(category=FutureWarning)
    def check_no_attributes_set_in_init(name, estimator_orig):
        """Check setting during init."""
        try:
            # Clone fails if the estimator does not store
            # all parameters as an attribute during init
            estimator = clone(estimator_orig)
        except AttributeError:
            raise AttributeError(
                f"Estimator {name} should store all parameters as an attribute during init."
            )
    
        if hasattr(type(estimator).__init__, "deprecated_original"):
            return
    
        init_params = _get_args(type(estimator).__init__)
        parents_init_params = [
            param
            for params_parent in (_get_args(parent) for parent in type(estimator).__mro__)
            for param in params_parent
        ]
    
        # Test for no setting apart from parameters during init
        invalid_attr = set(vars(estimator)) - set(init_params) - set(parents_init_params)
        # Ignore private attributes
        invalid_attr = set([attr for attr in invalid_attr if not attr.startswith("_")])
>       assert not invalid_attr, (
            "Estimator %s should not set any attribute apart"
            " from parameters during init. Found attributes %s."
            % (name, sorted(invalid_attr))
        )
E       AssertionError: Estimator DecisionTreeClassifier should not set any attribute apart from parameters during init. Found attributes ['postsplit_conditions', 'presplit_conditions', 'splitter_listeners', 'tree_build_listeners'].

estimator  = DecisionTreeClassifier()
estimator_orig = DecisionTreeClassifier()
init_params = ['self', 'criterion', 'splitter', 'max_depth', 'min_samples_split', 'min_samples_leaf', ...]
invalid_attr = {'postsplit_conditions', 'presplit_conditions', 'splitter_listeners', 'tree_build_listeners'}
name       = 'DecisionTreeClassifier'
parents_init_params = ['criterion', 'splitter', 'max_depth', 'min_samples_split', 'min_samples_leaf', 'min_weight_fraction_leaf', ...]

../1/s/sklearn/utils/estimator_checks.py:3183: AssertionError

Check failure on line 1 in test_estimators[ExtraTreeRegressor()-check_no_attributes_set_in_init]

See this annotation in the file changed.

@azure-pipelines azure-pipelines / neurodata.scikit-learn

test_estimators[ExtraTreeRegressor()-check_no_attributes_set_in_init]

AssertionError: Estimator ExtraTreeRegressor should not set any attribute apart from parameters during init. Found attributes ['postsplit_conditions', 'presplit_conditions', 'splitter_listeners', 'tree_build_listeners'].
Raw output
estimator = ExtraTreeRegressor()
check = functools.partial(<function check_no_attributes_set_in_init at 0x7f6583504720>, 'ExtraTreeRegressor')
request = <FixtureRequest for <Function test_estimators[ExtraTreeRegressor()-check_no_attributes_set_in_init]>>

    @parametrize_with_checks(list(_tested_estimators()))
    def test_estimators(estimator, check, request):
        # Common tests for estimator instances
        with ignore_warnings(
            category=(FutureWarning, ConvergenceWarning, UserWarning, LinAlgWarning)
        ):
>           check(estimator)

check      = functools.partial(<function check_no_attributes_set_in_init at 0x7f6583504720>, 'ExtraTreeRegressor')
estimator  = ExtraTreeRegressor()
request    = <FixtureRequest for <Function test_estimators[ExtraTreeRegressor()-check_no_attributes_set_in_init]>>

../1/s/sklearn/tests/test_common.py:127: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../1/s/sklearn/utils/_testing.py:147: in wrapper
    return fn(*args, **kwargs)
        args       = ('ExtraTreeRegressor', ExtraTreeRegressor())
        fn         = <function check_no_attributes_set_in_init at 0x7f6583504680>
        kwargs     = {}
        self       = _IgnoreWarnings(record=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'ExtraTreeRegressor', estimator_orig = ExtraTreeRegressor()

    @ignore_warnings(category=FutureWarning)
    def check_no_attributes_set_in_init(name, estimator_orig):
        """Check setting during init."""
        try:
            # Clone fails if the estimator does not store
            # all parameters as an attribute during init
            estimator = clone(estimator_orig)
        except AttributeError:
            raise AttributeError(
                f"Estimator {name} should store all parameters as an attribute during init."
            )
    
        if hasattr(type(estimator).__init__, "deprecated_original"):
            return
    
        init_params = _get_args(type(estimator).__init__)
        parents_init_params = [
            param
            for params_parent in (_get_args(parent) for parent in type(estimator).__mro__)
            for param in params_parent
        ]
    
        # Test for no setting apart from parameters during init
        invalid_attr = set(vars(estimator)) - set(init_params) - set(parents_init_params)
        # Ignore private attributes
        invalid_attr = set([attr for attr in invalid_attr if not attr.startswith("_")])
>       assert not invalid_attr, (
            "Estimator %s should not set any attribute apart"
            " from parameters during init. Found attributes %s."
            % (name, sorted(invalid_attr))
        )
E       AssertionError: Estimator ExtraTreeRegressor should not set any attribute apart from parameters during init. Found attributes ['postsplit_conditions', 'presplit_conditions', 'splitter_listeners', 'tree_build_listeners'].

estimator  = ExtraTreeRegressor()
estimator_orig = ExtraTreeRegressor()
init_params = ['self', 'criterion', 'splitter', 'max_depth', 'min_samples_split', 'min_samples_leaf', ...]
invalid_attr = {'postsplit_conditions', 'presplit_conditions', 'splitter_listeners', 'tree_build_listeners'}
name       = 'ExtraTreeRegressor'
parents_init_params = ['criterion', 'splitter', 'max_depth', 'min_samples_split', 'min_samples_leaf', 'min_weight_fraction_leaf', ...]

../1/s/sklearn/utils/estimator_checks.py:3183: AssertionError