def test_actual_results_strategy_quantile():
    """Test that the actual results are the expected ones."""
    # Data
    X = [[0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
         [0.0, 0.3, 0.2, 0.4, 0.1, 0.5, 0.6, 0.7, 0.8, 0.9],
         [0.0, 0.9, 0.1, 0.8, 0.2, 0.7, 0.3, 0.6, 0.4, 0.5]]
    y = [0, 0, 1]

    clf = SAXVSM(window_size=4, word_size=4, n_bins=2, strategy='quantile',
                 numerosity_reduction=False, sublinear_tf=False)
    decision_function_actual = clf.fit(X, y).decision_function(X)

    # X_bow = ["aabb aabb aabb aabb aabb aabb aabb",
    #          "abab baba abab aabb aabb aabb aabb",
    #          "abab baba abab baba abab baba abab"]

    assert clf.vocabulary_ == {0: 'aabb', 1: 'abab', 2: 'baba'}

    freq = np.asarray([[7, 0, 0],
                       [4, 2, 1],
                       [0, 4, 3]])
    tf = np.asarray([[11, 2, 1],
                     [0, 4, 3]])
    idf = np.asarray([log(2) + 1, 1, 1])
    decision_function_desired = cosine_similarity(freq, tf * idf[None, :])
    np.testing.assert_allclose(decision_function_actual,
                               decision_function_desired, atol=1e-5, rtol=0.)

    pred_actual = clf.fit(X, y).predict(X)
    pred_desired = cosine_similarity(freq, tf * idf[None, :]).argmax(axis=1)
    np.testing.assert_array_equal(pred_actual, pred_desired)

    # Without IDF weighting
    clf = SAXVSM(window_size=4, word_size=4, n_bins=2, strategy='quantile',
                 numerosity_reduction=False, sublinear_tf=False, use_idf=False)
    decision_function_actual = clf.fit(X, y).decision_function(X)

    decision_function_desired = cosine_similarity(freq, tf)
    np.testing.assert_allclose(decision_function_actual,
                               decision_function_desired, atol=1e-5, rtol=0.)

    pred_actual = clf.fit(X, y).predict(X)
    pred_desired = cosine_similarity(freq, tf).argmax(axis=1)
    np.testing.assert_array_equal(pred_actual, pred_desired)
Test that the actual results are the expected ones.
pyts/classification/tests/test_saxvsm.py