def test_get_x(): # if using list, get_x should get ints clf = OGDLR(ndims=100) clf.fit(X[:100], y[:100]) xt = ['sunny', 'cold', X[0, 2]] result = clf._get_x(xt) assert all([isinstance(r, int) for r in result]) # if using dict, get_x should give dictionary keys xt = ['sunny', 'cold', X[0, 2]] result = ogdlr_after._get_x(xt) expected = [ 'BIAS', 'weather__sunny', 'temperature__cold', 'noise__' + X[0, 2] ] assert result == expected
def test_get_x(): # if using list, get_x should get ints clf = OGDLR(ndims=100) clf.fit(X[:100], y[:100]) xt = ['sunny', 'cold', X[0, 2]] result = clf._get_x(xt) assert all([isinstance(r, int) for r in result]) # if using dict, get_x should give dictionary keys xt = ['sunny', 'cold', X[0, 2]] result = ogdlr_after._get_x(xt) expected = ['BIAS', 'weather__sunny', 'temperature__cold', 'noise__' + X[0, 2]] assert result == expected
def test_get_p(): # probabilities are between 0 and 1 Xs = [ogdlr_after._get_x(x) for x in X] prob = [ogdlr_after._get_p(xt) for xt in Xs] assert all([0 < pr < 1 for pr in prob])