def test_gradient(self): ol = OrderedLogit() X = np.array([[1.0], [1.0], [1.0]]) y = np.array([1, 1, 2]) coefficients = np.array([1.0, 1.0]) ol.n_attributes = 1 ol.n_classes = 2 ol._prepare_y(y) expected = np.array([0.5, -0.5]) assert_array_equal(ol._gradient(coefficients, X, y), expected)
def sample_lor(): lor = OrderedLogit(significance=0.9) lor.alpha_ = np.array([1, 1]) lor.beta_ = np.array([1, 1, 1]) lor._y_dict = {1: 1, 2: 2, 3: 7} lor.n_attributes = 3 lor.n_classes = 3 lor.N = 10 lor.score_ = 0.9 lor.se_ = np.array([1, 1, 1, 1, 1]) lor.p_values_ = np.array([0, 0, 0, 0, 0]) lor.attribute_names = pd.DataFrame( ['attribute_1', 'attribute_2', 'attribute_3'], columns=['attribute names']) return lor