Exemple #1
0
def test_get_classifier_config_func():
    """Tests that the app config provider is called."""
    actual = get_classifier_config(
        "entity", APP_PATH, domain="domain", intent="intent"
    )["params"]

    expected = {"penalty": "l2", "C": 100}

    assert actual == expected
Exemple #2
0
def test_get_classifier_config_func_error():
    """Tests robustness to exceptions raised by a config provider."""
    actual = get_classifier_config("entity", APP_PATH, domain="domain", intent="error")[
        "params"
    ]

    expected = {"error": "intent", "penalty": "l2", "C": 100}

    assert actual == expected
Exemple #3
0
def test_get_classifier_config():
    """Tests that the default config is returned when an app specified config doesn't exist."""
    actual = get_classifier_config("domain", APP_PATH)["param_selection"]

    expected = {
        "type": "k-fold",
        "k": 10,
        "grid": {"fit_intercept": [True, False], "C": [10, 100, 1000, 10000, 100000]},
    }

    assert actual == expected
Exemple #4
0
def test_get_classifier_config_func():
    """Tests that the app config provider is called."""
    actual = get_classifier_config('entity', APP_PATH,
                                   domain='domain', intent='intent')['params']

    expected = {
        'penalty': 'l2',
        'C': 100
    }

    assert actual == expected
Exemple #5
0
def test_get_classifier_config_func_error():
    """Tests robustness to exceptions raised by a config provider."""
    actual = get_classifier_config('entity', APP_PATH,
                                   domain='domain', intent='error')['params']

    expected = {
        'error': 'intent',
        'penalty': 'l2',
        'C': 100
    }

    assert actual == expected
Exemple #6
0
def test_get_classifier_config():
    """Tests that the default config is returned when an app specified config doesn't exist."""
    actual = get_classifier_config('domain', APP_PATH)['param_selection']

    expected = {
        'type': 'k-fold',
        'k': 10,
        'grid': {
            'fit_intercept': [True, False],
            'C': [10, 100, 1000, 10000, 100000]
        }
    }

    assert actual == expected
Exemple #7
0
def test_get_classifier_config2():
    """Tests that the app specified config is returned over the default config."""
    actual = get_classifier_config('intent', APP_PATH, domain='domain')['param_selection']

    expected = {
        'type': 'k-fold',
        'k': 5,
        'grid': {
            'fit_intercept': [True, False],
            'C': [1, 20, 300],
            'class_bias': [1, 0]
        }
    }

    assert actual == expected
Exemple #8
0
def test_get_classifier_config2():
    """Tests that the app specified config is returned over the default config."""
    actual = get_classifier_config("intent", APP_PATH,
                                   domain="domain")["param_selection"]

    expected = {
        "type": "k-fold",
        "k": 5,
        "grid": {
            "fit_intercept": [True, False],
            "C": [1, 20, 300],
            "class_bias": [1, 0],
        },
    }

    assert actual == expected