@@ -44,10 +44,17 @@ TEST(test_evaluate, test_negative_log_likelihood) {
4444 cov << 1 ., 0.9 , 0.8 , 0.9 , 1 ., 0.9 , 0.8 , 0.9 , 1 .;
4545
4646 const auto nll = albatross::negative_log_likelihood (x, cov);
47- EXPECT_NEAR (nll, - 6.0946974293510134 , 1e-6 );
47+ EXPECT_NEAR (nll, 6.0946974293510134 , 1e-6 );
4848
4949 const auto ldlt_nll = albatross::negative_log_likelihood (x, cov.ldlt ());
5050 EXPECT_NEAR (nll, ldlt_nll, 1e-6 );
51+
52+ const DiagonalMatrixXd diagonal_matrix = cov.diagonal ().asDiagonal ();
53+ const Eigen::MatrixXd dense_diagonal = diagonal_matrix.toDenseMatrix ();
54+ const auto diag_nll = albatross::negative_log_likelihood (x, diagonal_matrix);
55+ const auto dense_diag_nll =
56+ albatross::negative_log_likelihood (x, dense_diagonal);
57+ EXPECT_NEAR (diag_nll, dense_diag_nll, 1e-6 );
5158}
5259
5360TEST_F (LinearRegressionTest, test_leave_one_out) {
@@ -67,27 +74,6 @@ TEST_F(LinearRegressionTest, test_leave_one_out) {
6774 EXPECT_LT (in_sample_rmse, out_of_sample_rmse);
6875}
6976
70- // Group values by interval, but return keys that once sorted won't be
71- // in order
72- std::string group_by_interval (const double &x) {
73- if (x <= 3 ) {
74- return " 2" ;
75- } else if (x <= 6 ) {
76- return " 3" ;
77- } else {
78- return " 1" ;
79- }
80- }
81-
82- bool is_monotonic_increasing (const Eigen::VectorXd &x) {
83- for (Eigen::Index i = 0 ; i < x.size () - 1 ; i++) {
84- if (x[i + 1 ] - x[i] <= 0 .) {
85- return false ;
86- }
87- }
88- return true ;
89- }
90-
9177TEST_F (LinearRegressionTest, test_cross_validated_predict) {
9278 const auto folds = leave_one_group_out<double >(dataset_, group_by_interval);
9379
0 commit comments