Y-oHr-N / OptGBM

Optuna + LightGBM = OptGBM
MIT License
34 stars 7 forks source link

test_fit_twice_without_study raises AssertionError #92

Open Y-oHr-N opened 4 years ago

Y-oHr-N commented 4 years ago
tmp_path = PosixPath('/tmp/pytest-of-root/pytest-6/test_fit_twice_without_study__0'), n_jobs = -1

    @pytest.mark.parametrize("n_jobs", [-1, 1])
    def test_fit_twice_without_study(tmp_path: pathlib.Path, n_jobs: int) -> None:
        X, y = load_breast_cancer(return_X_y=True)

        clf = OGBMClassifier(
            n_estimators=n_estimators,
            n_jobs=n_jobs,
            n_trials=n_trials,
            random_state=random_state,
            train_dir=tmp_path,
        )

        clf.fit(X, y)

        df = clf.study_.trials_dataframe()
        values = df["value"]

        clf = OGBMClassifier(
            bagging_fraction=1.0,
            bagging_freq=0,
            feature_fraction=1.0,
            lambda_l1=0.0,
            lambda_l2=0.0,
            min_data_in_leaf=20,
            n_estimators=n_estimators,
            n_jobs=n_jobs,
            n_trials=n_trials,
            random_state=random_state,
            train_dir=tmp_path,
        )

        clf.fit(X, y)

        df = clf.study_.trials_dataframe()

>       np.testing.assert_array_equal(values, df["value"])
E       AssertionError: 
E       Arrays are not equal
E       
E       Mismatched elements: 1 / 5 (20%)
E       Max absolute difference: 5.55111512e-17
E       Max relative difference: 1.84773566e-16
E        x: array([0.690443, 0.315822, 0.300428, 0.690443, 0.308651])
E        y: array([0.690443, 0.315822, 0.300428, 0.690443, 0.308651])

tests/test_sklearn.py:289: AssertionError