|
17 | 17 | #include <maths/CBasicStatistics.h>
|
18 | 18 | #include <maths/CBoostedTree.h>
|
19 | 19 | #include <maths/CBoostedTreeFactory.h>
|
| 20 | +#include <maths/CDataFrameUtils.h> |
20 | 21 | #include <maths/COutliers.h>
|
21 | 22 |
|
22 | 23 | #include <api/CDataFrameAnalysisSpecification.h>
|
@@ -1021,13 +1022,17 @@ void CDataFrameAnalyzerTest::testCategoricalFields() {
|
1021 | 1022 | }
|
1022 | 1023 | }
|
1023 | 1024 |
|
1024 |
| -void CDataFrameAnalyzerTest::testCategoricalFields_EmptyAsMissing() { |
| 1025 | +void CDataFrameAnalyzerTest::testCategoricalFieldsEmptyAsMissing() { |
1025 | 1026 |
|
1026 | 1027 | auto eq = [](double expected) {
|
1027 | 1028 | return [expected](double actual) { return expected == actual; };
|
1028 | 1029 | };
|
1029 | 1030 |
|
1030 |
| - auto nan = []() { return [](double actual) { return isnan(actual); }; }; |
| 1031 | + auto missing = []() { |
| 1032 | + return [](double actual) { |
| 1033 | + return maths::CDataFrameUtils::isMissing(actual); |
| 1034 | + }; |
| 1035 | + }; |
1031 | 1036 |
|
1032 | 1037 | auto assertRow = [&](const std::size_t row_i,
|
1033 | 1038 | const std::vector<std::function<bool(double)>>& matchers,
|
@@ -1068,16 +1073,16 @@ void CDataFrameAnalyzerTest::testCategoricalFields_EmptyAsMissing() {
|
1068 | 1073 | std::vector<TRowRef> rows;
|
1069 | 1074 | std::copy(beginRows, endRows, std::back_inserter(rows));
|
1070 | 1075 | CPPUNIT_ASSERT_EQUAL(10UL, rows.size());
|
1071 |
| - assertRow(0, {eq(0.0), eq(0.0), eq(0.0), eq(0.0), eq(0.0)}, rows[0]); |
1072 |
| - assertRow(1, {eq(1.0), eq(1.0), eq(1.0), eq(1.0), eq(1.0)}, rows[1]); |
1073 |
| - assertRow(2, {eq(2.0), eq(2.0), eq(2.0), eq(2.0), eq(0.0)}, rows[2]); |
1074 |
| - assertRow(3, {eq(3.0), eq(3.0), eq(3.0), eq(3.0), nan() }, rows[3]); |
1075 |
| - assertRow(4, {eq(4.0), eq(4.0), eq(4.0), eq(4.0), eq(0.0)}, rows[4]); |
1076 |
| - assertRow(5, {eq(0.0), eq(5.0), eq(5.0), eq(5.0), eq(1.0)}, rows[5]); |
1077 |
| - assertRow(6, {eq(1.0), eq(6.0), eq(6.0), eq(6.0), nan() }, rows[6]); |
1078 |
| - assertRow(7, {eq(5.0), eq(0.0), eq(7.0), eq(7.0), nan() }, rows[7]); |
1079 |
| - assertRow(8, {eq(3.0), eq(1.0), eq(8.0), eq(8.0), eq(0.0)}, rows[8]); |
1080 |
| - assertRow(9, {eq(2.0), eq(2.0), eq(9.0), eq(9.0), eq(1.0)}, rows[9]); |
| 1076 | + assertRow(0, {eq(0.0), eq(0.0), eq(0.0), eq(0.0), eq(0.0)}, rows[0]); |
| 1077 | + assertRow(1, {eq(1.0), eq(1.0), eq(1.0), eq(1.0), eq(1.0)}, rows[1]); |
| 1078 | + assertRow(2, {eq(2.0), eq(2.0), eq(2.0), eq(2.0), eq(0.0)}, rows[2]); |
| 1079 | + assertRow(3, {eq(3.0), eq(3.0), eq(3.0), eq(3.0), missing()}, rows[3]); |
| 1080 | + assertRow(4, {eq(4.0), eq(4.0), eq(4.0), eq(4.0), eq(0.0)}, rows[4]); |
| 1081 | + assertRow(5, {eq(0.0), eq(5.0), eq(5.0), eq(5.0), eq(1.0)}, rows[5]); |
| 1082 | + assertRow(6, {eq(1.0), eq(6.0), eq(6.0), eq(6.0), missing()}, rows[6]); |
| 1083 | + assertRow(7, {eq(5.0), eq(0.0), eq(7.0), eq(7.0), missing()}, rows[7]); |
| 1084 | + assertRow(8, {eq(3.0), eq(1.0), eq(8.0), eq(8.0), eq(0.0)}, rows[8]); |
| 1085 | + assertRow(9, {eq(2.0), eq(2.0), eq(9.0), eq(9.0), eq(1.0)}, rows[9]); |
1081 | 1086 | });
|
1082 | 1087 | }
|
1083 | 1088 |
|
@@ -1122,8 +1127,8 @@ CppUnit::Test* CDataFrameAnalyzerTest::suite() {
|
1122 | 1127 | "CDataFrameAnalyzerTest::testCategoricalFields",
|
1123 | 1128 | &CDataFrameAnalyzerTest::testCategoricalFields));
|
1124 | 1129 | suiteOfTests->addTest(new CppUnit::TestCaller<CDataFrameAnalyzerTest>(
|
1125 |
| - "CDataFrameAnalyzerTest::testCategoricalFields_EmptyAsMissing", |
1126 |
| - &CDataFrameAnalyzerTest::testCategoricalFields_EmptyAsMissing)); |
| 1130 | + "CDataFrameAnalyzerTest::testCategoricalFieldsEmptyAsMissing", |
| 1131 | + &CDataFrameAnalyzerTest::testCategoricalFieldsEmptyAsMissing)); |
1127 | 1132 |
|
1128 | 1133 | return suiteOfTests;
|
1129 | 1134 | }
|
|
0 commit comments