Code Duplication    Length = 21-25 lines in 6 locations

tests/test_lightgbm.py 1 location

@@ 32-56 (lines=25) @@
29
    opt.score(X, y)
30
31
32
def test_lightgbm_classification():
33
    from hyperactive import RandomSearchOptimizer
34
35
    ml_scores = [
36
        "accuracy_score",
37
        "balanced_accuracy_score",
38
        "average_precision_score",
39
        "brier_score_loss",
40
        "f1_score",
41
        "log_loss",
42
        "precision_score",
43
        "recall_score",
44
        "jaccard_score",
45
        "roc_auc_score",
46
    ]
47
48
    for score in ml_scores:
49
        opt = RandomSearchOptimizer(search_config, 1, metric=score)
50
        assert opt._config_.metric == score
51
        opt.fit(X, y)
52
        assert opt._config_.metric == score
53
        opt.predict(X)
54
        assert opt._config_.metric == score
55
        opt.score(X, y)
56
        assert opt._config_.metric == score
57
58
59
def test_lightgbm_regression():

tests/test_catboost.py 1 location

@@ 30-54 (lines=25) @@
27
    opt.score(X, y)
28
29
30
def test_catboost_classification():
31
    from hyperactive import RandomSearchOptimizer
32
33
    ml_scores = [
34
        "accuracy_score",
35
        "balanced_accuracy_score",
36
        "average_precision_score",
37
        "brier_score_loss",
38
        "f1_score",
39
        "log_loss",
40
        "precision_score",
41
        "recall_score",
42
        "jaccard_score",
43
        "roc_auc_score",
44
    ]
45
46
    for score in ml_scores:
47
        opt = RandomSearchOptimizer(search_config, 1, metric=score)
48
        assert opt._config_.metric == score
49
        opt.fit(X, y)
50
        assert opt._config_.metric == score
51
        opt.predict(X)
52
        assert opt._config_.metric == score
53
        opt.score(X, y)
54
        assert opt._config_.metric == score
55
56
57
def test_catboost_regression():

tests/test_sklearn.py 1 location

@@ 30-54 (lines=25) @@
27
    opt.score(X, y)
28
29
30
def test_sklearn_classification():
31
    from hyperactive import RandomSearchOptimizer
32
33
    ml_scores = [
34
        "accuracy_score",
35
        "balanced_accuracy_score",
36
        "average_precision_score",
37
        "brier_score_loss",
38
        "f1_score",
39
        "log_loss",
40
        "precision_score",
41
        "recall_score",
42
        "jaccard_score",
43
        "roc_auc_score",
44
    ]
45
46
    for score in ml_scores:
47
        opt = RandomSearchOptimizer(search_config, 1, metric=score)
48
        assert opt._config_.metric == score
49
        opt.fit(X, y)
50
        assert opt._config_.metric == score
51
        opt.predict(X)
52
        assert opt._config_.metric == score
53
        opt.score(X, y)
54
        assert opt._config_.metric == score
55
56
57
def test_sklearn_regression():

tests/test_xgboost.py 1 location

@@ 30-54 (lines=25) @@
27
    opt.score(X, y)
28
29
30
def test_xgboost_classification():
31
    from hyperactive import RandomSearchOptimizer
32
33
    ml_scores = [
34
        "accuracy_score",
35
        "balanced_accuracy_score",
36
        "average_precision_score",
37
        "brier_score_loss",
38
        "f1_score",
39
        "log_loss",
40
        "precision_score",
41
        "recall_score",
42
        "jaccard_score",
43
        "roc_auc_score",
44
    ]
45
46
    for score in ml_scores:
47
        opt = RandomSearchOptimizer(search_config, 1, metric=score)
48
        assert opt._config_.metric == score
49
        opt.fit(X, y)
50
        assert opt._config_.metric == score
51
        opt.predict(X)
52
        assert opt._config_.metric == score
53
        opt.score(X, y)
54
        assert opt._config_.metric == score
55
56
57
def test_xgboost_regression():

tests/local/_test_keras_cnn.py 1 location

@@ 35-55 (lines=21) @@
32
    opt.score(X, y)
33
34
35
def test_keras_scores():
36
    from hyperactive import RandomSearchOptimizer
37
38
    ml_scores = [
39
        "accuracy",
40
        "binary_accuracy",
41
        "categorical_accuracy",
42
        # "sparse_categorical_accuracy",
43
        "top_k_categorical_accuracy",
44
        # "sparse_top_k_categorical_accuracy",
45
    ]
46
47
    for score in ml_scores:
48
        opt = RandomSearchOptimizer(search_config, 1, metric=score)
49
        assert opt._config_.metric == score
50
        opt.fit(X, y)
51
        assert opt._config_.metric == score
52
        opt.predict(X)
53
        assert opt._config_.metric == score
54
        opt.score(X, y)
55
        assert opt._config_.metric == score
56
57
58
def test_keras_losses():

tests/test_keras_mlp.py 1 location

@@ 27-47 (lines=21) @@
24
    opt.score(X, y)
25
26
27
def test_keras_scores():
28
    from hyperactive import RandomSearchOptimizer
29
30
    ml_scores = [
31
        "accuracy",
32
        "binary_accuracy",
33
        "categorical_accuracy",
34
        "sparse_categorical_accuracy",
35
        "top_k_categorical_accuracy",
36
        "sparse_top_k_categorical_accuracy",
37
    ]
38
39
    for score in ml_scores:
40
        opt = RandomSearchOptimizer(search_config, 1, metric=score)
41
        assert opt._config_.metric == score
42
        opt.fit(X, y)
43
        assert opt._config_.metric == score
44
        opt.predict(X)
45
        assert opt._config_.metric == score
46
        opt.score(X, y)
47
        assert opt._config_.metric == score
48
49
50
def test_keras_losses():