Skip to content

user warning in test: tests/tests_automl/test_targets.py::AutoMLTargetsTest::test_regression_missing_target #754

@a-szulc

Description

@a-szulc
============================= test session starts ==============================
platform linux -- Python 3.12.3, pytest-8.3.2, pluggy-1.5.0 -- /home/adas/mljar/mljar-supervised/venv/bin/python3
cachedir: .pytest_cache
rootdir: /home/adas/mljar/mljar-supervised
configfile: pytest.ini
plugins: cov-5.0.0
collecting ... collected 1 item

tests/tests_automl/test_targets.py::AutoMLTargetsTest::test_regression_missing_target FAILED

=================================== FAILURES ===================================
_______________ AutoMLTargetsTest.test_regression_missing_target _______________

self = <tests.tests_automl.test_targets.AutoMLTargetsTest testMethod=test_regression_missing_target>

    def test_regression_missing_target(self):
        X = np.random.rand(self.rows, 3)
        X = pd.DataFrame(X, columns=[f"f{i}" for i in range(3)])
        y = pd.Series(np.random.rand(self.rows), name="target")
    
        y.iloc[1] = None
    
        automl = AutoML(
            results_path=self.automl_dir,
            total_time_limit=1,
            algorithms=["Xgboost"],
            train_ensemble=False,
            explain_level=0,
            start_random_models=1,
        )
>       automl.fit(X, y)

tests/tests_automl/test_targets.py:304: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
supervised/automl.py:432: in fit
    return self._fit(X, y, sample_weight, cv, sensitive_features)
supervised/base_automl.py:967: in _fit
    X, y, sample_weight, sensitive_features = self._build_dataframe(
supervised/base_automl.py:789: in _build_dataframe
    X, y, sample_weight, sensitive_features = ExcludeRowsMissingTarget.transform(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

X =           f0        f1        f2
0   0.428266  0.400413  0.520708
1   0.240960  0.342989  0.285674
2   0.041829  0.516...  0.954445  0.989042
47  0.036140  0.744682  0.704169
48  0.647842  0.012628  0.719164
49  0.579543  0.874871  0.058259
y = 0     0.179094
1          NaN
2     0.678937
3     0.052738
4     0.357631
5     0.983330
6     0.233370
7     0.56043...
44    0.117175
45    0.436181
46    0.289724
47    0.862779
48    0.475552
49    0.649819
Name: target, dtype: float64
sample_weight = None, sensitive_features = None, warn = True

    @staticmethod
    def transform(
        X=None, y=None, sample_weight=None, sensitive_features=None, warn=False
    ):
        if y is None:
            return X, y, sample_weight, sensitive_features
        y_missing = pd.isnull(y)
        if np.sum(np.array(y_missing)) == 0:
            return X, y, sample_weight, sensitive_features
        logger.debug("Exclude rows with missing target values")
        if warn:
>           warnings.warn(
                "There are samples with missing target values in the data which will be excluded for further analysis"
            )
E           UserWarning: There are samples with missing target values in the data which will be excluded for further analysis

supervised/preprocessing/exclude_missing_target.py:25: UserWarning
=========================== short test summary info ============================
FAILED tests/tests_automl/test_targets.py::AutoMLTargetsTest::test_regression_missing_target
============================== 1 failed in 1.90s ===============================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions