def test_np_rnn_classifier(X_sequence):
    """Just makes sure that this code will run; it doesn't check that
    it is creating good models.
    """
    train, test, vocab = X_sequence
    embedding = np.array([utils.randvec(10) for _ in vocab])
    mod = np_rnn_classifier.RNNClassifier(vocab=vocab,
                                          embedding=embedding,
                                          hidden_dim=20,
                                          max_iter=100)
    X, y = zip(*train)
    X_test, _ = zip(*test)
    mod.fit(X, y)
    mod.predict(X_test)
    mod.predict_proba(X_test)
    mod.predict_one(X_test[0])
    mod.predict_one_proba(X_test[0])
Exemplo n.º 2
0
    assert epochs == list(range(20, 101, 20))
    assert all(len(v)==len(X) for v in model.dev_predictions.values())


def test_sgd_classifier():
    acc = np_sgd_classifier.simple_example()
    assert acc >= 0.89


@pytest.mark.parametrize("model, params", [
    [
        np_sgd_classifier.BasicSGDClassifier(max_iter=10, eta=0.1),
        {'max_iter': 100, 'eta': 1.0}
    ],
    [
        np_rnn_classifier.RNNClassifier(
            vocab=[], max_iter=10, hidden_dim=5, eta=0.1),
        {'hidden_dim': 10, 'eta': 1.0, 'max_iter': 100}
    ],
    [
        torch_rnn_classifier.TorchRNNClassifier(
            vocab=[], max_iter=10, hidden_dim=5, eta=0.1),
        {
            'hidden_dim': 10,
            'eta': 1.0,
            'max_iter': 100,
            'l2_strength': 0.01,
            'embed_dim': 100,
            'bidirectional': False
        }
    ],
    [