Exemplo n.º 1
0
def test_scalar_prediction_type():
    model = Workspace(quiet=True)
    model.learn("1 | a b c")
    assert model.get_prediction_type() == model.pSCALAR
    prediction = model.predict(" | a b c")
    assert isinstance(prediction, float)
    del model
Exemplo n.º 2
0
def test_multilabel_prediction_type():
    model = Workspace(multilabel_oaa=4, quiet=True)
    model.learn("1 | a b c")
    assert model.get_prediction_type() == model.pMULTILABELS
    prediction = model.predict(" | a b c")
    assert isinstance(prediction, list)
    del model
Exemplo n.º 3
0
def test_action_probs_prediction_type():
    model = Workspace(cb_explore=2, ngram=2, quiet=True)
    model.learn("1 | a b c")
    assert model.get_prediction_type() == model.pACTION_PROBS
    prediction = model.predict(" | a b c")
    assert isinstance(prediction, list)
    del model
Exemplo n.º 4
0
def test_multiclass_prediction_type():
    n = 3
    model = Workspace(loss_function="logistic", oaa=n, quiet=True)
    model.learn("1 | a b c")
    assert model.get_prediction_type(
    ) == vowpalwabbit.PredictionType.MULTICLASS
    prediction = model.predict(" | a b c")
    assert isinstance(prediction, int)
    del model
Exemplo n.º 5
0
def test_action_scores_prediction_type():
    model = Workspace(loss_function="logistic", csoaa_ldf="m", quiet=True)
    multi_ex = [model.example("1:1 | a b c"), model.example("2:-1  | a b c")]
    model.learn(multi_ex)
    assert model.get_prediction_type() == model.pMULTICLASS
    multi_ex = [model.example("1 | a b c"), model.example("2 | a b c")]
    prediction = model.predict(multi_ex)
    assert isinstance(prediction, int)
    del model
Exemplo n.º 6
0
def test_scalars_prediction_type():
    n = 3
    model = Workspace(loss_function="logistic",
                      oaa=n,
                      probabilities=True,
                      quiet=True)
    model.learn("1 | a b c")
    assert model.get_prediction_type() == vowpalwabbit.PredictionType.SCALARS
    prediction = model.predict(" | a b c")
    assert isinstance(prediction, list)
    assert len(prediction) == n
    del model
Exemplo n.º 7
0
def test_prob_prediction_type():
    model = Workspace(
        loss_function="logistic",
        csoaa_ldf="mc",
        probabilities=True,
        quiet=True,
    )
    multi_ex = [
        model.example("1:0.2 | a b c"),
        model.example("2:0.8  | a b c"),
    ]
    model.learn(multi_ex)
    assert model.get_prediction_type() == vowpalwabbit.PredictionType.PROB
    multi_ex = [model.example("1 | a b c"), model.example("2 | a b c")]
    prediction = model.predict(multi_ex)
    assert isinstance(prediction, float)
    del model