コード例 #1
0
def test_pipeline_parameter_False():
    """Assert that no transformers used."""
    atom = ATOMClassifier(X10_nan, y10, random_state=1)
    atom.impute(strat_num="median")
    atom.prune(max_sigma=2)
    X = atom.transform(X10_nan, pipeline=False)  # Use None
    assert isinstance(X, list)  # X is unchanged
コード例 #2
0
def test_pipeline_parameter_True():
    """Assert that all transformers are used."""
    atom = ATOMClassifier(X10_nan, y10, random_state=1)
    atom.impute(strat_num="median")
    atom.prune(max_sigma=2)
    X = atom.transform(X10_nan, pipeline=True)  # Use both transformers
    assert len(X) < 10
コード例 #3
0
def test_pipeline_parameter_None():
    """Assert that only some transformers are used."""
    atom = ATOMClassifier(X10_nan, y10, random_state=1)
    atom.impute(strat_num="median")
    atom.prune(max_sigma=2)
    X = atom.transform(X10_nan, pipeline=None)  # Only use imputer
    assert len(X) == 10
コード例 #4
0
def test_getitem():
    """Assert that atom is subscriptable."""
    atom = ATOMClassifier(X_bin, y_bin, random_state=1)
    atom.clean()
    atom.impute()
    assert atom[1].__class__.__name__ == "Imputer"
    assert atom["mean radius"].equals(atom.dataset["mean radius"])
コード例 #5
0
def test_branch_setter_from_valid():
    """Assert that we can create a new branch, not from the current one."""
    atom = ATOMClassifier(X10_nan, y10, random_state=1)
    atom.branch = "branch_2"
    atom.impute()
    atom.branch = "branch_3_from_master"
    assert atom.branch.name == "branch_3"
    assert atom.n_nans > 0
コード例 #6
0
ファイル: test_ensembles.py プロジェクト: hado2020/ATOM
def test_vote_branch_transformation(pipeline):
    """Assert that the branches transform every estimator only once."""
    atom = ATOMClassifier(X_bin, y_bin, random_state=1)
    atom.clean()
    atom.impute()
    atom.branch = "branch_2"
    atom.encode()
    atom.run(models=["Tree", "LGB"])
    atom.voting()
    assert isinstance(atom.vote.predict(X_bin, pipeline=pipeline), np.ndarray)
コード例 #7
0
def test_plot_pipeline(show_params):
    """Assert that the plot_pipeline method work as intended."""
    atom = ATOMClassifier(X_bin, y_bin, random_state=1)
    atom.impute()
    atom.prune()
    atom.feature_selection("univariate", n_features=10)
    atom.successive_halving(["Tree", "AdaB"])
    pytest.raises(ValueError, atom.plot_pipeline, branch="invalid")
    atom.plot_pipeline(show_params=show_params,
                       title="Pipeline plot",
                       display=False)
コード例 #8
0
ファイル: test_ensembles.py プロジェクト: hado2020/ATOM
def test_vote_prediction_methods():
    """Assert that the prediction methods work as intended."""
    atom = ATOMClassifier(X_bin, y_bin, random_state=1)
    atom.clean()
    atom.run(models=["Tree"])
    atom.branch = "branch_2"
    atom.impute(strat_num="mean", strat_cat="most_frequent")
    atom.run(["LGB"])
    atom.voting(models=["Tree", "LGB"])
    pytest.raises(AttributeError, atom.vote.decision_function, X_bin)
    assert isinstance(atom.vote.predict(X_bin), np.ndarray)
    assert isinstance(atom.vote.predict_proba(X_bin), np.ndarray)
    assert isinstance(atom.vote.score(X_bin, y_bin), np.float64)
コード例 #9
0
def test_status_method():
    """Assert that the status method prints the estimators without errors."""
    atom = ATOMClassifier(X_bin, y_bin, random_state=1)
    atom.impute()
    atom.branch.status()
    assert str(atom.branch).endswith("min_frac_cols: None\n --> Models: None")
コード例 #10
0
def test_iter():
    """Assert that we can iterate over atom's pipeline."""
    atom = ATOMClassifier(X_bin, y_bin, random_state=1)
    atom.clean()
    atom.impute()
    assert [item for item in atom][1] == atom.pipeline[1]
コード例 #11
0
def test_impute():
    """Assert that the impute method imputes all missing values."""
    atom = ATOMClassifier(X10_nan, y10, random_state=1)
    atom.impute()
    assert atom.dataset.isna().sum().sum() == 0