diff --git a/CPPFImdlp.cpp b/CPPFImdlp.cpp index 007a789..e0d2f95 100644 --- a/CPPFImdlp.cpp +++ b/CPPFImdlp.cpp @@ -12,7 +12,7 @@ namespace mdlp { metrics(Metrics(y, indices)) { } - CPPFImdlp::CPPFImdlp(int min_length_, int max_depth_): depth(0), max_depth(max_depth_), min_length(min_length_), indices(indices_t()), X(samples_t()), y(labels_t()), + CPPFImdlp::CPPFImdlp(size_t min_length_, int max_depth_): depth(0), max_depth(max_depth_), min_length(min_length_), indices(indices_t()), X(samples_t()), y(labels_t()), metrics(Metrics(y, indices)) { } diff --git a/CPPFImdlp.h b/CPPFImdlp.h index 406779a..ac57eb2 100644 --- a/CPPFImdlp.h +++ b/CPPFImdlp.h @@ -7,10 +7,11 @@ namespace mdlp { class CPPFImdlp { protected: - indices_t indices; + size_t min_length; + int depth, max_depth; samples_t X; labels_t y; - int depth, max_depth; + indices_t indices; Metrics metrics; cutPoints_t cutPoints; @@ -20,9 +21,8 @@ namespace mdlp { size_t getCandidate(size_t, size_t); pair valueCutPoint(size_t, size_t, size_t); public: - int min_length; CPPFImdlp(); - CPPFImdlp(int, int); + CPPFImdlp(size_t, int); ~CPPFImdlp(); CPPFImdlp& fit(samples_t&, labels_t&); cutPoints_t getCutPoints(); diff --git a/tests/FImdlp_unittest.cpp b/tests/FImdlp_unittest.cpp index f8650f7..51197db 100644 --- a/tests/FImdlp_unittest.cpp +++ b/tests/FImdlp_unittest.cpp @@ -57,7 +57,7 @@ namespace mdlp { void test_dataset(CPPFImdlp& test, string filename, vector& expected, int depths[]) { ArffFiles file; - file.load("../datasets/" + filename, true); + file.load("../datasets/" + filename + ".arff", true); vector& X = file.getX(); labels_t& y = file.getY(); auto attributes = file.getAttributes(); @@ -203,10 +203,11 @@ namespace mdlp { {0.8 } }; int depths[] = { 1, 1, 1, 1 }; - test_dataset(test, "iris.arff", expected, depths); + test_dataset(test, "iris", expected, depths); } TEST_F(TestFImdlp, MinLength) { + auto test = CPPFImdlp(75, 100); // Set min_length to 75 vector expected = { { 5.45, 5.75 }, @@ -214,26 +215,8 @@ namespace mdlp { { 2.45, 4.75 }, { 0.8, 1.75 } }; - int depths[] = { 2, 2, 2, 2 }; - //test_dataset(test, "iris", expected, depths); - ArffFiles file; - file.load("../datasets/iris.arff", true); - vector& X = file.getX(); - labels_t& y = file.getY(); - auto attributes = file.getAttributes(); - for (auto feature = 0; feature < attributes.size(); feature++) { - auto test = CPPFImdlp(75, 100); - test.fit(X[feature], y); - cout << "Feature: " << feature << " Depth: " << test.get_depth() << endl; - //EXPECT_EQ(test.get_depth(), depths[feature]); - auto computed = test.getCutPoints(); - for (auto item : test.getCutPoints()) { - cout << item << " "; - } - cout << endl; - //checkCutPoints(computed, expected[feature]); - } - FAIL(); + int depths[] = { 3, 2, 2, 2 }; + test_dataset(test, "iris", expected, depths); } TEST_F(TestFImdlp, MinLengthMaxDepth) { @@ -246,6 +229,6 @@ namespace mdlp { { 0.8, 1.75 } }; int depths[] = { 2, 2, 2, 2 }; - test_dataset(test, "iris.arff", expected, depths); + test_dataset(test, "iris", expected, depths); } }