Exemplo n.º 1
0
def test_worker():
    random.seed(1)
    inputs, targets = load_circle()
    params = {"kernel": "poly", "degree": 2}
    result = run_experiment(svm.SVC(kernel="poly", degree=2), params, inputs, targets)
    assert result[0] == params
    assert result[1] > 0.95
Exemplo n.º 2
0
def test_experiment_run_polynomial_grid():
    inputs, targets = load_circle()
    random.seed(1)
    results = run(svm.SVC(),
                 "grid_search",
                 {"kernel": ["linear", "poly"], "degree": [1, 2, 3, 4, 5]},
                 inputs,
                 targets)
    best_result = results[0][0]
    assert best_result["kernel"] == "poly"
    assert best_result["degree"] == 2
Exemplo n.º 3
0
def test_experiment_run_polynomial_random():
    inputs, targets = load_circle()
    random.seed(1)
    results = run(svm.SVC(gamma='auto'),
                  "random_search", {
                      "kernel": ["linear", "poly"],
                      "degree": [1, 2, 3, 4, 5]
                  },
                  inputs,
                  targets,
                  n_iter=100)
    best_result = results[0][0]
    assert best_result["kernel"] == "poly"
    assert best_result["degree"] == 2