mirror of
https://github.com/rmontanana/mdlp.git
synced 2025-08-16 16:05:57 +00:00
Fix BinDisc quantile mistakes (#9)
* Fix BinDisc quantile mistakes * Fix FImdlp tests * Fix tests, samples and remove uneeded support files * Add coypright header to sources Fix coverage report Add coverage badge to README * Update sonar github action * Move sources to a folder and change ArffFiles files to library * Add recursive submodules to github action
This commit is contained in:
committed by
GitHub
parent
7b0673fd4b
commit
e36d9af8f9
@@ -1,132 +0,0 @@
|
||||
#include "ArffFiles.h"
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
|
||||
using namespace std;
|
||||
|
||||
ArffFiles::ArffFiles() = default;
|
||||
|
||||
vector<string> ArffFiles::getLines() const
|
||||
{
|
||||
return lines;
|
||||
}
|
||||
|
||||
unsigned long int ArffFiles::getSize() const
|
||||
{
|
||||
return lines.size();
|
||||
}
|
||||
|
||||
vector<pair<string, string>> ArffFiles::getAttributes() const
|
||||
{
|
||||
return attributes;
|
||||
}
|
||||
|
||||
string ArffFiles::getClassName() const
|
||||
{
|
||||
return className;
|
||||
}
|
||||
|
||||
string ArffFiles::getClassType() const
|
||||
{
|
||||
return classType;
|
||||
}
|
||||
|
||||
vector<mdlp::samples_t>& ArffFiles::getX()
|
||||
{
|
||||
return X;
|
||||
}
|
||||
|
||||
vector<int>& ArffFiles::getY()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
void ArffFiles::load(const string& fileName, bool classLast)
|
||||
{
|
||||
ifstream file(fileName);
|
||||
if (!file.is_open()) {
|
||||
throw invalid_argument("Unable to open file");
|
||||
}
|
||||
string line;
|
||||
string keyword;
|
||||
string attribute;
|
||||
string type;
|
||||
string type_w;
|
||||
while (getline(file, line)) {
|
||||
if (line.empty() || line[0] == '%' || line == "\r" || line == " ") {
|
||||
continue;
|
||||
}
|
||||
if (line.find("@attribute") != string::npos || line.find("@ATTRIBUTE") != string::npos) {
|
||||
stringstream ss(line);
|
||||
ss >> keyword >> attribute;
|
||||
type = "";
|
||||
while (ss >> type_w)
|
||||
type += type_w + " ";
|
||||
attributes.emplace_back(trim(attribute), trim(type));
|
||||
continue;
|
||||
}
|
||||
if (line[0] == '@') {
|
||||
continue;
|
||||
}
|
||||
lines.push_back(line);
|
||||
}
|
||||
file.close();
|
||||
if (attributes.empty())
|
||||
throw invalid_argument("No attributes found");
|
||||
if (classLast) {
|
||||
className = get<0>(attributes.back());
|
||||
classType = get<1>(attributes.back());
|
||||
attributes.pop_back();
|
||||
} else {
|
||||
className = get<0>(attributes.front());
|
||||
classType = get<1>(attributes.front());
|
||||
attributes.erase(attributes.begin());
|
||||
}
|
||||
generateDataset(classLast);
|
||||
|
||||
}
|
||||
|
||||
void ArffFiles::generateDataset(bool classLast)
|
||||
{
|
||||
X = vector<mdlp::samples_t>(attributes.size(), mdlp::samples_t(lines.size()));
|
||||
auto yy = vector<string>(lines.size(), "");
|
||||
int labelIndex = classLast ? static_cast<int>(attributes.size()) : 0;
|
||||
for (size_t i = 0; i < lines.size(); i++) {
|
||||
stringstream ss(lines[i]);
|
||||
string value;
|
||||
int pos = 0;
|
||||
int xIndex = 0;
|
||||
while (getline(ss, value, ',')) {
|
||||
if (pos++ == labelIndex) {
|
||||
yy[i] = value;
|
||||
} else {
|
||||
X[xIndex++][i] = stof(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
y = factorize(yy);
|
||||
}
|
||||
|
||||
string ArffFiles::trim(const string& source)
|
||||
{
|
||||
string s(source);
|
||||
s.erase(0, s.find_first_not_of(" '\n\r\t"));
|
||||
s.erase(s.find_last_not_of(" '\n\r\t") + 1);
|
||||
return s;
|
||||
}
|
||||
|
||||
vector<int> ArffFiles::factorize(const vector<string>& labels_t)
|
||||
{
|
||||
vector<int> yy;
|
||||
yy.reserve(labels_t.size());
|
||||
map<string, int> labelMap;
|
||||
int i = 0;
|
||||
for (const string& label : labels_t) {
|
||||
if (labelMap.find(label) == labelMap.end()) {
|
||||
labelMap[label] = i++;
|
||||
}
|
||||
yy.push_back(labelMap[label]);
|
||||
}
|
||||
return yy;
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
#ifndef ARFFFILES_H
|
||||
#define ARFFFILES_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../typesFImdlp.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class ArffFiles {
|
||||
private:
|
||||
vector<string> lines;
|
||||
vector<pair<string, string>> attributes;
|
||||
string className;
|
||||
string classType;
|
||||
vector<mdlp::samples_t> X;
|
||||
vector<int> y;
|
||||
|
||||
void generateDataset(bool);
|
||||
|
||||
public:
|
||||
ArffFiles();
|
||||
void load(const string&, bool = true);
|
||||
vector<string> getLines() const;
|
||||
unsigned long int getSize() const;
|
||||
string getClassName() const;
|
||||
string getClassType() const;
|
||||
static string trim(const string&);
|
||||
vector<mdlp::samples_t>& getX();
|
||||
vector<int>& getY();
|
||||
vector<pair<string, string>> getAttributes() const;
|
||||
static vector<int> factorize(const vector<string>& labels_t);
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,9 +1,16 @@
|
||||
// ****************************************************************
|
||||
// SPDX - FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||
// SPDX - FileType: SOURCE
|
||||
// SPDX - License - Identifier: MIT
|
||||
// ****************************************************************
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "gtest/gtest.h"
|
||||
#include "ArffFiles.h"
|
||||
#include "../BinDisc.h"
|
||||
#include <ArffFiles.hpp>
|
||||
#include "BinDisc.h"
|
||||
#include "Experiments.hpp"
|
||||
|
||||
namespace mdlp {
|
||||
const float margin = 1e-4;
|
||||
@@ -40,10 +47,11 @@ namespace mdlp {
|
||||
auto y = labels_t();
|
||||
fit(X, y);
|
||||
auto cuts = getCutPoints();
|
||||
ASSERT_EQ(3, cuts.size());
|
||||
EXPECT_NEAR(3.66667, cuts.at(0), margin);
|
||||
EXPECT_NEAR(6.33333, cuts.at(1), margin);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts.at(2));
|
||||
ASSERT_EQ(4, cuts.size());
|
||||
EXPECT_NEAR(1, cuts.at(0), margin);
|
||||
EXPECT_NEAR(3.66667, cuts.at(1), margin);
|
||||
EXPECT_NEAR(6.33333, cuts.at(2), margin);
|
||||
EXPECT_NEAR(9.0, cuts.at(3), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 1, 1, 1, 2, 2, 2 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -53,10 +61,11 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
ASSERT_EQ(3, cuts.size());
|
||||
EXPECT_NEAR(3.666667, cuts[0], margin);
|
||||
EXPECT_NEAR(6.333333, cuts[1], margin);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[2]);
|
||||
ASSERT_EQ(4, cuts.size());
|
||||
EXPECT_NEAR(1, cuts[0], margin);
|
||||
EXPECT_NEAR(3.666667, cuts[1], margin);
|
||||
EXPECT_NEAR(6.333333, cuts[2], margin);
|
||||
EXPECT_NEAR(9, cuts[3], margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 1, 1, 1, 2, 2, 2 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -66,10 +75,11 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
ASSERT_EQ(3, cuts.size());
|
||||
EXPECT_EQ(4.0, cuts[0]);
|
||||
EXPECT_EQ(7.0, cuts[1]);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[2]);
|
||||
ASSERT_EQ(4, cuts.size());
|
||||
EXPECT_NEAR(1, cuts.at(0), margin);
|
||||
EXPECT_NEAR(4.0, cuts.at(1), margin);
|
||||
EXPECT_NEAR(7.0, cuts.at(2), margin);
|
||||
EXPECT_NEAR(10.0, cuts.at(3), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 2 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -79,10 +89,11 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
ASSERT_EQ(3, cuts.size());
|
||||
EXPECT_EQ(4, cuts[0]);
|
||||
EXPECT_EQ(7, cuts[1]);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[2]);
|
||||
ASSERT_EQ(4, cuts.size());
|
||||
EXPECT_NEAR(1, cuts.at(0), margin);
|
||||
EXPECT_NEAR(4.0, cuts.at(1), margin);
|
||||
EXPECT_NEAR(7.0, cuts.at(2), margin);
|
||||
EXPECT_NEAR(10.0, cuts.at(3), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 2 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -92,10 +103,11 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
ASSERT_EQ(3, cuts.size());
|
||||
EXPECT_NEAR(4.33333, cuts[0], margin);
|
||||
EXPECT_NEAR(7.66667, cuts[1], margin);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[2]);
|
||||
ASSERT_EQ(4, cuts.size());
|
||||
EXPECT_NEAR(1, cuts.at(0), margin);
|
||||
EXPECT_NEAR(4.33333, cuts.at(1), margin);
|
||||
EXPECT_NEAR(7.66667, cuts.at(2), margin);
|
||||
EXPECT_NEAR(11.0, cuts.at(3), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -105,10 +117,11 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
ASSERT_EQ(3, cuts.size());
|
||||
EXPECT_NEAR(4.33333, cuts[0], margin);
|
||||
EXPECT_NEAR(7.66667, cuts[1], margin);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[2]);
|
||||
ASSERT_EQ(4, cuts.size());
|
||||
EXPECT_NEAR(1, cuts.at(0), margin);
|
||||
EXPECT_NEAR(4.33333, cuts.at(1), margin);
|
||||
EXPECT_NEAR(7.66667, cuts.at(2), margin);
|
||||
EXPECT_NEAR(11.0, cuts.at(3), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -118,8 +131,9 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
ASSERT_EQ(1, cuts.size());
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[0]);
|
||||
ASSERT_EQ(2, cuts.size());
|
||||
EXPECT_NEAR(1, cuts.at(0), margin);
|
||||
EXPECT_NEAR(1, cuts.at(1), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 0, 0, 0 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -129,8 +143,9 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(1, cuts.size());
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[0]);
|
||||
ASSERT_EQ(2, cuts.size());
|
||||
EXPECT_NEAR(1, cuts.at(0), margin);
|
||||
EXPECT_NEAR(1, cuts.at(1), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 0, 0, 0 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -140,16 +155,18 @@ namespace mdlp {
|
||||
samples_t X = {};
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(1, cuts.size());
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[0]);
|
||||
ASSERT_EQ(2, cuts.size());
|
||||
EXPECT_NEAR(0, cuts.at(0), margin);
|
||||
EXPECT_NEAR(0, cuts.at(1), margin);
|
||||
}
|
||||
TEST_F(TestBinDisc3Q, EmptyQuantile)
|
||||
{
|
||||
samples_t X = {};
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(1, cuts.size());
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[0]);
|
||||
ASSERT_EQ(2, cuts.size());
|
||||
EXPECT_NEAR(0, cuts.at(0), margin);
|
||||
EXPECT_NEAR(0, cuts.at(1), margin);
|
||||
}
|
||||
TEST(TestBinDisc3, ExceptionNumberBins)
|
||||
{
|
||||
@@ -160,10 +177,11 @@ namespace mdlp {
|
||||
samples_t X = { 3.0, 1.0, 1.0, 3.0, 1.0, 1.0, 3.0, 1.0, 1.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
ASSERT_EQ(3, cuts.size());
|
||||
EXPECT_NEAR(1.66667, cuts[0], margin);
|
||||
EXPECT_NEAR(2.33333, cuts[1], margin);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[2]);
|
||||
ASSERT_EQ(4, cuts.size());
|
||||
EXPECT_NEAR(1, cuts.at(0), margin);
|
||||
EXPECT_NEAR(1.66667, cuts.at(1), margin);
|
||||
EXPECT_NEAR(2.33333, cuts.at(2), margin);
|
||||
EXPECT_NEAR(3.0, cuts.at(3), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 2, 0, 0, 2, 0, 0, 2, 0, 0 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -174,9 +192,10 @@ namespace mdlp {
|
||||
samples_t X = { 3.0, 1.0, 1.0, 3.0, 1.0, 1.0, 3.0, 1.0, 1.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(2, cuts.size());
|
||||
EXPECT_NEAR(1.66667, cuts[0], margin);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[1]);
|
||||
ASSERT_EQ(3, cuts.size());
|
||||
EXPECT_NEAR(1, cuts.at(0), margin);
|
||||
EXPECT_NEAR(1.66667, cuts.at(1), margin);
|
||||
EXPECT_NEAR(3.0, cuts.at(2), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 1, 0, 0, 1, 0, 0, 1, 0, 0 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -187,11 +206,12 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(4, cuts.size());
|
||||
ASSERT_EQ(3.75, cuts[0]);
|
||||
EXPECT_EQ(6.5, cuts[1]);
|
||||
EXPECT_EQ(9.25, cuts[2]);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[3]);
|
||||
ASSERT_EQ(5, cuts.size());
|
||||
EXPECT_NEAR(1.0, cuts.at(0), margin);
|
||||
EXPECT_NEAR(3.75, cuts.at(1), margin);
|
||||
EXPECT_NEAR(6.5, cuts.at(2), margin);
|
||||
EXPECT_NEAR(9.25, cuts.at(3), margin);
|
||||
EXPECT_NEAR(12.0, cuts.at(4), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -201,11 +221,12 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(4, cuts.size());
|
||||
ASSERT_EQ(3.75, cuts[0]);
|
||||
EXPECT_EQ(6.5, cuts[1]);
|
||||
EXPECT_EQ(9.25, cuts[2]);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[3]);
|
||||
ASSERT_EQ(5, cuts.size());
|
||||
EXPECT_NEAR(1.0, cuts.at(0), margin);
|
||||
EXPECT_NEAR(3.75, cuts.at(1), margin);
|
||||
EXPECT_NEAR(6.5, cuts.at(2), margin);
|
||||
EXPECT_NEAR(9.25, cuts.at(3), margin);
|
||||
EXPECT_NEAR(12.0, cuts.at(4), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -215,11 +236,12 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(4, cuts.size());
|
||||
EXPECT_EQ(4.0, cuts[0]);
|
||||
EXPECT_EQ(7.0, cuts[1]);
|
||||
EXPECT_EQ(10.0, cuts[2]);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[3]);
|
||||
ASSERT_EQ(5, cuts.size());
|
||||
EXPECT_NEAR(1.0, cuts.at(0), margin);
|
||||
EXPECT_NEAR(4.0, cuts.at(1), margin);
|
||||
EXPECT_NEAR(7.0, cuts.at(2), margin);
|
||||
EXPECT_NEAR(10.0, cuts.at(3), margin);
|
||||
EXPECT_NEAR(13.0, cuts.at(4), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -229,11 +251,12 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(4, cuts.size());
|
||||
EXPECT_EQ(4.0, cuts[0]);
|
||||
EXPECT_EQ(7.0, cuts[1]);
|
||||
EXPECT_EQ(10.0, cuts[2]);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[3]);
|
||||
ASSERT_EQ(5, cuts.size());
|
||||
EXPECT_NEAR(1.0, cuts.at(0), margin);
|
||||
EXPECT_NEAR(4.0, cuts.at(1), margin);
|
||||
EXPECT_NEAR(7.0, cuts.at(2), margin);
|
||||
EXPECT_NEAR(10.0, cuts.at(3), margin);
|
||||
EXPECT_NEAR(13.0, cuts.at(4), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -243,11 +266,12 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(4, cuts.size());
|
||||
EXPECT_EQ(4.25, cuts[0]);
|
||||
EXPECT_EQ(7.5, cuts[1]);
|
||||
EXPECT_EQ(10.75, cuts[2]);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[3]);
|
||||
ASSERT_EQ(5, cuts.size());
|
||||
EXPECT_NEAR(1.0, cuts.at(0), margin);
|
||||
EXPECT_NEAR(4.25, cuts.at(1), margin);
|
||||
EXPECT_NEAR(7.5, cuts.at(2), margin);
|
||||
EXPECT_NEAR(10.75, cuts.at(3), margin);
|
||||
EXPECT_NEAR(14.0, cuts.at(4), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -257,11 +281,12 @@ namespace mdlp {
|
||||
samples_t X = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(4, cuts.size());
|
||||
EXPECT_EQ(4.25, cuts[0]);
|
||||
EXPECT_EQ(7.5, cuts[1]);
|
||||
EXPECT_EQ(10.75, cuts[2]);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[3]);
|
||||
ASSERT_EQ(5, cuts.size());
|
||||
EXPECT_NEAR(1.0, cuts.at(0), margin);
|
||||
EXPECT_NEAR(4.25, cuts.at(1), margin);
|
||||
EXPECT_NEAR(7.5, cuts.at(2), margin);
|
||||
EXPECT_NEAR(10.75, cuts.at(3), margin);
|
||||
EXPECT_NEAR(14.0, cuts.at(4), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -271,11 +296,12 @@ namespace mdlp {
|
||||
samples_t X = { 15.0, 8.0, 12.0, 14.0, 6.0, 1.0, 13.0, 11.0, 10.0, 9.0, 7.0, 4.0, 3.0, 5.0, 2.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(4, cuts.size());
|
||||
EXPECT_EQ(4.5, cuts[0]);
|
||||
EXPECT_EQ(8, cuts[1]);
|
||||
EXPECT_EQ(11.5, cuts[2]);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[3]);
|
||||
ASSERT_EQ(5, cuts.size());
|
||||
EXPECT_NEAR(1.0, cuts.at(0), margin);
|
||||
EXPECT_NEAR(4.5, cuts.at(1), margin);
|
||||
EXPECT_NEAR(8, cuts.at(2), margin);
|
||||
EXPECT_NEAR(11.5, cuts.at(3), margin);
|
||||
EXPECT_NEAR(15.0, cuts.at(4), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 3, 2, 3, 3, 1, 0, 3, 2, 2, 2, 1, 0, 0, 1, 0 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -285,11 +311,12 @@ namespace mdlp {
|
||||
samples_t X = { 15.0, 13.0, 12.0, 14.0, 6.0, 1.0, 8.0, 11.0, 10.0, 9.0, 7.0, 4.0, 3.0, 5.0, 2.0 };
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(4, cuts.size());
|
||||
EXPECT_EQ(4.5, cuts[0]);
|
||||
EXPECT_EQ(8, cuts[1]);
|
||||
EXPECT_EQ(11.5, cuts[2]);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[3]);
|
||||
ASSERT_EQ(5, cuts.size());
|
||||
EXPECT_NEAR(1.0, cuts.at(0), margin);
|
||||
EXPECT_NEAR(4.5, cuts.at(1), margin);
|
||||
EXPECT_NEAR(8, cuts.at(2), margin);
|
||||
EXPECT_NEAR(11.5, cuts.at(3), margin);
|
||||
EXPECT_NEAR(15.0, cuts.at(4), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 3, 3, 3, 3, 1, 0, 2, 2, 2, 2, 1, 0, 0, 1, 0 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -300,11 +327,12 @@ namespace mdlp {
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
EXPECT_EQ(4, cuts.size());
|
||||
EXPECT_EQ(1.0, cuts[0]);
|
||||
EXPECT_EQ(2.0, cuts[1]);
|
||||
ASSERT_EQ(3.0, cuts[2]);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[3]);
|
||||
ASSERT_EQ(5, cuts.size());
|
||||
EXPECT_NEAR(0.0, cuts.at(0), margin);
|
||||
EXPECT_NEAR(1.0, cuts.at(1), margin);
|
||||
EXPECT_NEAR(2.0, cuts.at(2), margin);
|
||||
EXPECT_NEAR(3.0, cuts.at(3), margin);
|
||||
EXPECT_NEAR(4.0, cuts.at(4), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 1, 1, 1, 2, 2, 3, 3, 3, 3 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
@@ -315,50 +343,69 @@ namespace mdlp {
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
fit(X);
|
||||
auto cuts = getCutPoints();
|
||||
ASSERT_EQ(3, cuts.size());
|
||||
EXPECT_EQ(2.0, cuts[0]);
|
||||
ASSERT_EQ(3.0, cuts[1]);
|
||||
EXPECT_EQ(numeric_limits<float>::max(), cuts[2]);
|
||||
ASSERT_EQ(5, cuts.size());
|
||||
EXPECT_NEAR(0.0, cuts.at(0), margin);
|
||||
EXPECT_NEAR(1.0, cuts.at(1), margin);
|
||||
EXPECT_NEAR(2.0, cuts.at(2), margin);
|
||||
EXPECT_NEAR(3.0, cuts.at(3), margin);
|
||||
EXPECT_NEAR(4.0, cuts.at(4), margin);
|
||||
auto labels = transform(X);
|
||||
labels_t expected = { 0, 0, 0, 0, 1, 1, 2, 2, 2, 2 };
|
||||
labels_t expected = { 0, 1, 1, 1, 2, 2, 3, 3, 3, 3 };
|
||||
EXPECT_EQ(expected, labels);
|
||||
}
|
||||
TEST_F(TestBinDisc4U, irisUniform)
|
||||
TEST(TestBinDiscGeneric, Fileset)
|
||||
{
|
||||
ArffFiles file;
|
||||
file.load(data_path + "iris.arff", true);
|
||||
vector<samples_t>& X = file.getX();
|
||||
fit(X[0]);
|
||||
auto Xt = transform(X[0]);
|
||||
labels_t expected = { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 2, 2, 1, 2, 1, 2, 0, 2, 0, 0, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 0, 1, 1, 1, 2, 0, 1, 2, 1, 3, 2, 2, 3, 0, 3, 2, 3, 2, 2, 2, 1, 1, 2, 2, 3, 3, 1, 2, 1, 3, 2, 2, 3, 2, 1, 2, 3, 3, 3, 2, 2, 1, 3, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 };
|
||||
EXPECT_EQ(expected, Xt);
|
||||
auto Xtt = fit_transform(X[0], file.getY());
|
||||
EXPECT_EQ(expected, Xtt);
|
||||
auto Xt_t = torch::tensor(X[0], torch::kFloat32);
|
||||
auto y_t = torch::tensor(file.getY(), torch::kInt32);
|
||||
auto Xtt_t = fit_transform_t(Xt_t, y_t);
|
||||
for (int i = 0; i < expected.size(); i++)
|
||||
EXPECT_EQ(expected[i], Xtt_t[i].item<int>());
|
||||
}
|
||||
TEST_F(TestBinDisc4Q, irisQuantile)
|
||||
{
|
||||
ArffFiles file;
|
||||
file.load(data_path + "iris.arff", true);
|
||||
vector<samples_t>& X = file.getX();
|
||||
fit(X[0]);
|
||||
auto Xt = transform(X[0]);
|
||||
labels_t expected = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 3, 3, 3, 1, 3, 1, 2, 0, 3, 1, 0, 2, 2, 2, 1, 3, 1, 2, 2, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2, 1, 2, 3, 2, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 1, 1, 2, 2, 3, 2, 3, 3, 0, 3, 3, 3, 3, 3, 3, 1, 2, 3, 3, 3, 3, 2, 3, 1, 3, 2, 3, 3, 2, 2, 3, 3, 3, 3, 3, 2, 2, 3, 2, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 2, 2 };
|
||||
EXPECT_EQ(expected, Xt);
|
||||
auto Xtt = fit_transform(X[0], file.getY());
|
||||
EXPECT_EQ(expected, Xtt);
|
||||
auto Xt_t = torch::tensor(X[0], torch::kFloat32);
|
||||
auto y_t = torch::tensor(file.getY(), torch::kInt32);
|
||||
auto Xtt_t = fit_transform_t(Xt_t, y_t);
|
||||
for (int i = 0; i < expected.size(); i++)
|
||||
EXPECT_EQ(expected[i], Xtt_t[i].item<int>());
|
||||
fit_t(Xt_t, y_t);
|
||||
auto Xt_t2 = transform_t(Xt_t);
|
||||
for (int i = 0; i < expected.size(); i++)
|
||||
EXPECT_EQ(expected[i], Xt_t2[i].item<int>());
|
||||
Experiments exps(data_path + "tests.txt");
|
||||
int num = 0;
|
||||
while (exps.is_next()) {
|
||||
++num;
|
||||
Experiment exp = exps.next();
|
||||
BinDisc disc(exp.n_bins_, exp.strategy_[0] == 'Q' ? strategy_t::QUANTILE : strategy_t::UNIFORM);
|
||||
std::vector<precision_t> test;
|
||||
if (exp.type_ == experiment_t::RANGE) {
|
||||
for (float i = exp.from_; i < exp.to_; i += exp.step_) {
|
||||
test.push_back(i);
|
||||
}
|
||||
} else {
|
||||
test = exp.dataset_;
|
||||
}
|
||||
// show_vector(test, "Test");
|
||||
auto empty = std::vector<int>();
|
||||
auto Xt = disc.fit_transform(test, empty);
|
||||
auto cuts = disc.getCutPoints();
|
||||
EXPECT_EQ(exp.discretized_data_.size(), Xt.size());
|
||||
auto flag = false;
|
||||
size_t n_errors = 0;
|
||||
if (num < 40) {
|
||||
//
|
||||
// Check discretization of only the first 40 tests as after we cannot ensure the same codification due to precision problems
|
||||
//
|
||||
for (int i = 0; i < exp.discretized_data_.size(); ++i) {
|
||||
if (exp.discretized_data_.at(i) != Xt.at(i)) {
|
||||
if (!flag) {
|
||||
if (exp.type_ == experiment_t::RANGE)
|
||||
std::cout << "+Exp #: " << num << " From: " << exp.from_ << " To: " << exp.to_ << " Step: " << exp.step_ << " Bins: " << exp.n_bins_ << " Strategy: " << exp.strategy_ << std::endl;
|
||||
else {
|
||||
std::cout << "+Exp #: " << num << " strategy: " << exp.strategy_ << " " << " n_bins: " << exp.n_bins_ << " ";
|
||||
show_vector(exp.dataset_, "Dataset");
|
||||
}
|
||||
show_vector(cuts, "Cuts");
|
||||
std::cout << "Error at " << i << " test[i]=" << test.at(i) << " Expected: " << exp.discretized_data_.at(i) << " Got: " << Xt.at(i) << std::endl;
|
||||
flag = true;
|
||||
EXPECT_EQ(exp.discretized_data_.at(i), Xt.at(i));
|
||||
}
|
||||
n_errors++;
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
std::cout << "*** Found " << n_errors << " mistakes in this experiment dataset" << std::endl;
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(exp.cutpoints_.size(), cuts.size());
|
||||
for (int i = 0; i < exp.cutpoints_.size(); ++i) {
|
||||
EXPECT_NEAR(exp.cutpoints_.at(i), cuts.at(i), margin);
|
||||
}
|
||||
}
|
||||
std::cout << "* Number of experiments tested: " << num << std::endl;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
cmake_policy(SET CMP0135 NEW)
|
||||
include(FetchContent)
|
||||
include_directories(${GTEST_INCLUDE_DIRS})
|
||||
FetchContent_Declare(
|
||||
@@ -11,28 +8,30 @@ FetchContent_Declare(
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
|
||||
find_package(Torch REQUIRED)
|
||||
include_directories(
|
||||
${TORCH_INCLUDE_DIRS}
|
||||
${mdlp_SOURCE_DIR}/src
|
||||
${mdlp_SOURCE_DIR}/tests/lib/Files
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
include_directories(${TORCH_INCLUDE_DIRS})
|
||||
|
||||
add_executable(Metrics_unittest ../Metrics.cpp Metrics_unittest.cpp)
|
||||
add_executable(Metrics_unittest ${mdlp_SOURCE_DIR}/src/Metrics.cpp Metrics_unittest.cpp)
|
||||
target_link_libraries(Metrics_unittest GTest::gtest_main)
|
||||
target_compile_options(Metrics_unittest PRIVATE --coverage)
|
||||
target_link_options(Metrics_unittest PRIVATE --coverage)
|
||||
|
||||
add_executable(FImdlp_unittest ../CPPFImdlp.cpp ArffFiles.cpp ../Metrics.cpp FImdlp_unittest.cpp ../Discretizer.cpp)
|
||||
add_executable(FImdlp_unittest FImdlp_unittest.cpp
|
||||
${mdlp_SOURCE_DIR}/src/CPPFImdlp.cpp ${mdlp_SOURCE_DIR}/src/Metrics.cpp ${mdlp_SOURCE_DIR}/src/Discretizer.cpp)
|
||||
target_link_libraries(FImdlp_unittest GTest::gtest_main "${TORCH_LIBRARIES}")
|
||||
target_compile_options(FImdlp_unittest PRIVATE --coverage)
|
||||
target_link_options(FImdlp_unittest PRIVATE --coverage)
|
||||
|
||||
add_executable(BinDisc_unittest ../BinDisc.cpp ArffFiles.cpp BinDisc_unittest.cpp ../Discretizer.cpp)
|
||||
add_executable(BinDisc_unittest BinDisc_unittest.cpp ${mdlp_SOURCE_DIR}/src/BinDisc.cpp ${mdlp_SOURCE_DIR}/src/Discretizer.cpp)
|
||||
target_link_libraries(BinDisc_unittest GTest::gtest_main "${TORCH_LIBRARIES}")
|
||||
target_compile_options(BinDisc_unittest PRIVATE --coverage)
|
||||
target_link_options(BinDisc_unittest PRIVATE --coverage)
|
||||
|
||||
add_executable(Discretizer_unittest ../BinDisc.cpp ../CPPFImdlp.cpp ArffFiles.cpp ../Metrics.cpp ../Discretizer.cpp Discretizer_unittest.cpp)
|
||||
add_executable(Discretizer_unittest Discretizer_unittest.cpp
|
||||
${mdlp_SOURCE_DIR}/src/BinDisc.cpp ${mdlp_SOURCE_DIR}/src/CPPFImdlp.cpp ${mdlp_SOURCE_DIR}/src/Metrics.cpp ${mdlp_SOURCE_DIR}/src/Discretizer.cpp )
|
||||
target_link_libraries(Discretizer_unittest GTest::gtest_main "${TORCH_LIBRARIES}")
|
||||
target_compile_options(Discretizer_unittest PRIVATE --coverage)
|
||||
target_link_options(Discretizer_unittest PRIVATE --coverage)
|
||||
|
@@ -1,11 +1,17 @@
|
||||
// ****************************************************************
|
||||
// SPDX - FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||
// SPDX - FileType: SOURCE
|
||||
// SPDX - License - Identifier: MIT
|
||||
// ****************************************************************
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <ArffFiles.hpp>
|
||||
#include "gtest/gtest.h"
|
||||
#include "ArffFiles.h"
|
||||
#include "../Discretizer.h"
|
||||
#include "../BinDisc.h"
|
||||
#include "../CPPFImdlp.h"
|
||||
#include "Discretizer.h"
|
||||
#include "BinDisc.h"
|
||||
#include "CPPFImdlp.h"
|
||||
|
||||
namespace mdlp {
|
||||
const float margin = 1e-4;
|
||||
@@ -20,7 +26,15 @@ namespace mdlp {
|
||||
return "../../tests/datasets/";
|
||||
}
|
||||
const std::string data_path = set_data_path();
|
||||
|
||||
const labels_t iris_quantile = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 3, 3, 3, 1, 3, 1, 2, 0, 3, 1, 0, 2, 2, 2, 1, 3, 1, 2, 2, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2, 1, 2, 3, 2, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 1, 1, 2, 2, 3, 2, 3, 3, 0, 3, 3, 3, 3, 3, 3, 1, 2, 3, 3, 3, 3, 2, 3, 1, 3, 2, 3, 3, 2, 2, 3, 3, 3, 3, 3, 2, 2, 3, 2, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 2, 2 };
|
||||
TEST(Discretizer, Version)
|
||||
{
|
||||
Discretizer* disc = new BinDisc(4, strategy_t::UNIFORM);
|
||||
auto version = disc->version();
|
||||
delete disc;
|
||||
std::cout << "Version computed: " << version;
|
||||
EXPECT_EQ("1.2.3", version);
|
||||
}
|
||||
TEST(Discretizer, BinIrisUniform)
|
||||
{
|
||||
ArffFiles file;
|
||||
@@ -43,12 +57,198 @@ namespace mdlp {
|
||||
auto y = labels_t();
|
||||
disc->fit(X[0], y);
|
||||
auto Xt = disc->transform(X[0]);
|
||||
labels_t expected = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 3, 3, 3, 1, 3, 1, 2, 0, 3, 1, 0, 2, 2, 2, 1, 3, 1, 2, 2, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2, 1, 2, 3, 2, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 1, 1, 2, 2, 3, 2, 3, 3, 0, 3, 3, 3, 3, 3, 3, 1, 2, 3, 3, 3, 3, 2, 3, 1, 3, 2, 3, 3, 2, 2, 3, 3, 3, 3, 3, 2, 2, 3, 2, 3, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 2, 2 };
|
||||
delete disc;
|
||||
EXPECT_EQ(expected, Xt);
|
||||
EXPECT_EQ(iris_quantile, Xt);
|
||||
}
|
||||
|
||||
TEST(Discretizer, BinIrisQuantileTorch)
|
||||
{
|
||||
ArffFiles file;
|
||||
Discretizer* disc = new BinDisc(4, strategy_t::QUANTILE);
|
||||
file.load(data_path + "iris.arff", true);
|
||||
auto X = file.getX();
|
||||
auto y = file.getY();
|
||||
auto X_torch = torch::tensor(X[0], torch::kFloat32);
|
||||
auto yt = torch::tensor(y, torch::kInt32);
|
||||
disc->fit_t(X_torch, yt);
|
||||
torch::Tensor Xt = disc->transform_t(X_torch);
|
||||
delete disc;
|
||||
EXPECT_EQ(iris_quantile.size(), Xt.size(0));
|
||||
for (int i = 0; i < iris_quantile.size(); ++i) {
|
||||
EXPECT_EQ(iris_quantile.at(i), Xt[i].item<int>());
|
||||
}
|
||||
}
|
||||
TEST(Discretizer, BinIrisQuantileTorchFit_transform)
|
||||
{
|
||||
ArffFiles file;
|
||||
Discretizer* disc = new BinDisc(4, strategy_t::QUANTILE);
|
||||
file.load(data_path + "iris.arff", true);
|
||||
auto X = file.getX();
|
||||
auto y = file.getY();
|
||||
auto X_torch = torch::tensor(X[0], torch::kFloat32);
|
||||
auto yt = torch::tensor(y, torch::kInt32);
|
||||
torch::Tensor Xt = disc->fit_transform_t(X_torch, yt);
|
||||
delete disc;
|
||||
EXPECT_EQ(iris_quantile.size(), Xt.size(0));
|
||||
for (int i = 0; i < iris_quantile.size(); ++i) {
|
||||
EXPECT_EQ(iris_quantile.at(i), Xt[i].item<int>());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Discretizer, FImdlpIris)
|
||||
{
|
||||
auto labelsq = {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
1,
|
||||
3,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
3,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
0,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
1,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
};
|
||||
labels_t expected = {
|
||||
5, 3, 4, 4, 5, 5, 5, 5, 2, 4, 5, 5, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 4, 5, 3, 5, 5, 5, 4, 4, 5, 5, 5, 4, 4, 5, 4, 3, 5, 5, 0, 4, 5,
|
||||
|
139
tests/Experiments.hpp
Normal file
139
tests/Experiments.hpp
Normal file
@@ -0,0 +1,139 @@
|
||||
// ****************************************************************
|
||||
// SPDX - FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||
// SPDX - FileType: SOURCE
|
||||
// SPDX - License - Identifier: MIT
|
||||
// ****************************************************************
|
||||
|
||||
#ifndef EXPERIMENTS_HPP
|
||||
#define EXPERIMENTS_HPP
|
||||
#include<sstream>
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include<fstream>
|
||||
#include<vector>
|
||||
#include<tuple>
|
||||
#include "typesFImdlp.h"
|
||||
|
||||
template <typename T>
|
||||
void show_vector(const std::vector<T>& data, std::string title)
|
||||
{
|
||||
std::cout << title << ": ";
|
||||
std::string sep = "";
|
||||
for (const auto& d : data) {
|
||||
std::cout << sep << d;
|
||||
sep = ", ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
enum class experiment_t {
|
||||
RANGE,
|
||||
VECTOR
|
||||
};
|
||||
class Experiment {
|
||||
public:
|
||||
Experiment(float from_, float to_, float step_, int n_bins, std::string strategy, std::vector<int> data_discretized, std::vector<mdlp::precision_t> cutpoints) :
|
||||
from_{ from_ }, to_{ to_ }, step_{ step_ }, n_bins_{ n_bins }, strategy_{ strategy }, discretized_data_{ data_discretized }, cutpoints_{ cutpoints }, type_{ experiment_t::RANGE }
|
||||
{
|
||||
validate_strategy();
|
||||
|
||||
}
|
||||
Experiment(std::vector<mdlp::precision_t> dataset, int n_bins, std::string strategy, std::vector<int> data_discretized, std::vector<mdlp::precision_t> cutpoints) :
|
||||
n_bins_{ n_bins }, strategy_{ strategy }, dataset_{ dataset }, discretized_data_{ data_discretized }, cutpoints_{ cutpoints }, type_{ experiment_t::VECTOR }
|
||||
{
|
||||
validate_strategy();
|
||||
}
|
||||
void validate_strategy()
|
||||
{
|
||||
if (strategy_ != "Q" && strategy_ != "U") {
|
||||
throw std::invalid_argument("Invalid strategy " + strategy_);
|
||||
}
|
||||
}
|
||||
float from_;
|
||||
float to_;
|
||||
float step_;
|
||||
int n_bins_;
|
||||
std::string strategy_;
|
||||
std::vector<mdlp::precision_t> dataset_;
|
||||
std::vector<int> discretized_data_;
|
||||
std::vector<mdlp::precision_t> cutpoints_;
|
||||
experiment_t type_;
|
||||
};
|
||||
class Experiments {
|
||||
public:
|
||||
Experiments(const std::string filename) : filename{ filename }
|
||||
{
|
||||
test_file.open(filename);
|
||||
if (!test_file.is_open()) {
|
||||
throw std::runtime_error("File " + filename + " not found");
|
||||
}
|
||||
exp_end = false;
|
||||
}
|
||||
~Experiments()
|
||||
{
|
||||
test_file.close();
|
||||
}
|
||||
bool end() const
|
||||
{
|
||||
return exp_end;
|
||||
}
|
||||
bool is_next()
|
||||
{
|
||||
while (std::getline(test_file, line) && line[0] == '#');
|
||||
if (test_file.eof()) {
|
||||
exp_end = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Experiment next()
|
||||
{
|
||||
return parse_experiment(line);
|
||||
}
|
||||
private:
|
||||
std::tuple<float, float, float, int, std::string> parse_header(const std::string& line)
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
std::string from_, to_, step_, n_bins, strategy;
|
||||
iss >> from_ >> to_ >> step_ >> n_bins >> strategy;
|
||||
return { std::stof(from_), std::stof(to_), std::stof(step_), std::stoi(n_bins), strategy };
|
||||
}
|
||||
template <typename T>
|
||||
std::vector<T> parse_vector(const std::string& line)
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
std::vector<T> data;
|
||||
std::string d;
|
||||
while (iss >> d) {
|
||||
data.push_back(std::is_same<T, float>::value ? std::stof(d) : std::stoi(d));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
Experiment parse_experiment(std::string& line)
|
||||
{
|
||||
// Read experiment lines
|
||||
std::string experiment, data, cuts, strategy;
|
||||
std::getline(test_file, experiment);
|
||||
std::getline(test_file, data);
|
||||
std::getline(test_file, cuts);
|
||||
// split data into variables
|
||||
float from_, to_, step_;
|
||||
int n_bins;
|
||||
std::vector<mdlp::precision_t> dataset;
|
||||
auto data_discretized = parse_vector<int>(data);
|
||||
auto cutpoints = parse_vector<mdlp::precision_t>(cuts);
|
||||
if (line == "RANGE") {
|
||||
tie(from_, to_, step_, n_bins, strategy) = parse_header(experiment);
|
||||
return Experiment{ from_, to_, step_, n_bins, strategy, data_discretized, cutpoints };
|
||||
}
|
||||
strategy = experiment.substr(0, 1);
|
||||
n_bins = std::stoi(experiment.substr(1, 1));
|
||||
data = experiment.substr(3, experiment.size() - 4);
|
||||
dataset = parse_vector<mdlp::precision_t>(data);
|
||||
return Experiment(dataset, n_bins, strategy, data_discretized, cutpoints);
|
||||
}
|
||||
std::ifstream test_file;
|
||||
std::string filename;
|
||||
std::string line;
|
||||
bool exp_end;
|
||||
};
|
||||
#endif
|
@@ -1,9 +1,15 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "../Metrics.h"
|
||||
#include "../CPPFImdlp.h"
|
||||
// ****************************************************************
|
||||
// SPDX - FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||
// SPDX - FileType: SOURCE
|
||||
// SPDX - License - Identifier: MIT
|
||||
// ****************************************************************
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "ArffFiles.h"
|
||||
#include <ArffFiles.hpp>
|
||||
#include "gtest/gtest.h"
|
||||
#include "Metrics.h"
|
||||
#include "CPPFImdlp.h"
|
||||
|
||||
#define EXPECT_THROW_WITH_MESSAGE(stmt, etype, whatstring) EXPECT_THROW( \
|
||||
try { \
|
||||
@@ -124,7 +130,7 @@ namespace mdlp {
|
||||
{
|
||||
samples_t X_ = { 1, 2, 2, 3, 4, 2, 3 };
|
||||
labels_t y_ = { 0, 0, 1, 2, 3, 4, 5 };
|
||||
cutPoints_t expected = { 1.5f, 2.5f };
|
||||
cutPoints_t expected = { 1.0, 1.5f, 2.5f, 4.0 };
|
||||
fit(X_, y_);
|
||||
auto computed = getCutPoints();
|
||||
EXPECT_EQ(computed.size(), expected.size());
|
||||
@@ -167,29 +173,31 @@ namespace mdlp {
|
||||
y = { 1 };
|
||||
fit(X, y);
|
||||
computed = getCutPoints();
|
||||
EXPECT_EQ(computed.size(), 0);
|
||||
EXPECT_EQ(computed.size(), 2);
|
||||
X = { 1, 3 };
|
||||
y = { 1, 2 };
|
||||
fit(X, y);
|
||||
computed = getCutPoints();
|
||||
EXPECT_EQ(computed.size(), 0);
|
||||
EXPECT_EQ(computed.size(), 2);
|
||||
X = { 2, 4 };
|
||||
y = { 1, 2 };
|
||||
fit(X, y);
|
||||
computed = getCutPoints();
|
||||
EXPECT_EQ(computed.size(), 0);
|
||||
EXPECT_EQ(computed.size(), 2);
|
||||
X = { 1, 2, 3 };
|
||||
y = { 1, 2, 2 };
|
||||
fit(X, y);
|
||||
computed = getCutPoints();
|
||||
EXPECT_EQ(computed.size(), 1);
|
||||
EXPECT_NEAR(computed[0], 1.5, precision);
|
||||
EXPECT_EQ(computed.size(), 3);
|
||||
EXPECT_NEAR(computed[0], 1, precision);
|
||||
EXPECT_NEAR(computed[1], 1.5, precision);
|
||||
EXPECT_NEAR(computed[2], 3, precision);
|
||||
}
|
||||
|
||||
TEST_F(TestFImdlp, TestArtificialDataset)
|
||||
{
|
||||
fit(X, y);
|
||||
cutPoints_t expected = { 5.05f };
|
||||
cutPoints_t expected = { 4.7, 5.05, 6.0 };
|
||||
vector<precision_t> computed = getCutPoints();
|
||||
EXPECT_EQ(computed.size(), expected.size());
|
||||
for (unsigned long i = 0; i < computed.size(); i++) {
|
||||
@@ -200,10 +208,10 @@ namespace mdlp {
|
||||
TEST_F(TestFImdlp, TestIris)
|
||||
{
|
||||
vector<cutPoints_t> expected = {
|
||||
{5.45f, 5.75f},
|
||||
{2.75f, 2.85f, 2.95f, 3.05f, 3.35f},
|
||||
{2.45f, 4.75f, 5.05f},
|
||||
{0.8f, 1.75f}
|
||||
{4.3, 5.45f, 5.75f, 7.9},
|
||||
{2, 2.75f, 2.85f, 2.95f, 3.05f, 3.35f, 4.4},
|
||||
{1, 2.45f, 4.75f, 5.05f, 6.9},
|
||||
{0.1, 0.8f, 1.75f, 2.5}
|
||||
};
|
||||
vector<int> depths = { 3, 5, 4, 3 };
|
||||
auto test = CPPFImdlp();
|
||||
@@ -213,7 +221,7 @@ namespace mdlp {
|
||||
TEST_F(TestFImdlp, ComputeCutPointsGCase)
|
||||
{
|
||||
cutPoints_t expected;
|
||||
expected = { 1.5 };
|
||||
expected = { 0, 1.5, 2 };
|
||||
samples_t X_ = { 0, 1, 2, 2, 2 };
|
||||
labels_t y_ = { 1, 1, 1, 2, 2 };
|
||||
fit(X_, y_);
|
||||
@@ -247,10 +255,10 @@ namespace mdlp {
|
||||
// Set max_depth to 1
|
||||
auto test = CPPFImdlp(3, 1, 0);
|
||||
vector<cutPoints_t> expected = {
|
||||
{5.45f},
|
||||
{3.35f},
|
||||
{2.45f},
|
||||
{0.8f}
|
||||
{4.3, 5.45f, 7.9},
|
||||
{2, 3.35f, 4.4},
|
||||
{1, 2.45f, 6.9},
|
||||
{0.1, 0.8f, 2.5}
|
||||
};
|
||||
vector<int> depths = { 1, 1, 1, 1 };
|
||||
test_dataset(test, "iris", expected, depths);
|
||||
@@ -261,10 +269,10 @@ namespace mdlp {
|
||||
auto test = CPPFImdlp(75, 100, 0);
|
||||
// Set min_length to 75
|
||||
vector<cutPoints_t> expected = {
|
||||
{5.45f, 5.75f},
|
||||
{2.85f, 3.35f},
|
||||
{2.45f, 4.75f},
|
||||
{0.8f, 1.75f}
|
||||
{4.3, 5.45f, 5.75f, 7.9},
|
||||
{2, 2.85f, 3.35f, 4.4},
|
||||
{1, 2.45f, 4.75f, 6.9},
|
||||
{0.1, 0.8f, 1.75f, 2.5}
|
||||
};
|
||||
vector<int> depths = { 3, 2, 2, 2 };
|
||||
test_dataset(test, "iris", expected, depths);
|
||||
@@ -275,10 +283,10 @@ namespace mdlp {
|
||||
// Set min_length to 75
|
||||
auto test = CPPFImdlp(75, 2, 0);
|
||||
vector<cutPoints_t> expected = {
|
||||
{5.45f, 5.75f},
|
||||
{2.85f, 3.35f},
|
||||
{2.45f, 4.75f},
|
||||
{0.8f, 1.75f}
|
||||
{4.3, 5.45f, 5.75f, 7.9},
|
||||
{2, 2.85f, 3.35f, 4.4},
|
||||
{1, 2.45f, 4.75f, 6.9},
|
||||
{0.1, 0.8f, 1.75f, 2.5}
|
||||
};
|
||||
vector<int> depths = { 2, 2, 2, 2 };
|
||||
test_dataset(test, "iris", expected, depths);
|
||||
@@ -289,10 +297,10 @@ namespace mdlp {
|
||||
// Set min_length to 75
|
||||
auto test = CPPFImdlp(75, 2, 1);
|
||||
vector<cutPoints_t> expected = {
|
||||
{5.45f},
|
||||
{2.85f},
|
||||
{2.45f},
|
||||
{0.8f}
|
||||
{4.3, 5.45f, 7.9},
|
||||
{2, 2.85f, 4.4},
|
||||
{1, 2.45f, 6.9},
|
||||
{0.1, 0.8f, 2.5}
|
||||
};
|
||||
vector<int> depths = { 2, 2, 2, 2 };
|
||||
test_dataset(test, "iris", expected, depths);
|
||||
@@ -304,10 +312,10 @@ namespace mdlp {
|
||||
// Set min_length to 75
|
||||
auto test = CPPFImdlp(75, 2, 0.2f);
|
||||
vector<cutPoints_t> expected = {
|
||||
{5.45f, 5.75f},
|
||||
{2.85f, 3.35f},
|
||||
{2.45f, 4.75f},
|
||||
{0.8f, 1.75f}
|
||||
{4.3, 5.45f, 5.75f, 7.9},
|
||||
{2, 2.85f, 3.35f, 4.4},
|
||||
{1, 2.45f, 4.75f, 6.9},
|
||||
{0.1, 0.8f, 1.75f, 2.5}
|
||||
};
|
||||
vector<int> depths = { 2, 2, 2, 2 };
|
||||
test_dataset(test, "iris", expected, depths);
|
||||
@@ -327,7 +335,6 @@ namespace mdlp {
|
||||
computed = compute_max_num_cut_points();
|
||||
ASSERT_EQ(expected, computed);
|
||||
}
|
||||
|
||||
}
|
||||
TEST_F(TestFImdlp, TransformTest)
|
||||
{
|
||||
@@ -345,15 +352,15 @@ namespace mdlp {
|
||||
vector<samples_t>& X = file.getX();
|
||||
labels_t& y = file.getY();
|
||||
fit(X[1], y);
|
||||
// auto computed = transform(X[1]);
|
||||
// EXPECT_EQ(computed.size(), expected.size());
|
||||
// for (unsigned long i = 0; i < computed.size(); i++) {
|
||||
// EXPECT_EQ(computed[i], expected[i]);
|
||||
// }
|
||||
// auto computed_ft = fit_transform(X[1], y);
|
||||
// EXPECT_EQ(computed_ft.size(), expected.size());
|
||||
// for (unsigned long i = 0; i < computed_ft.size(); i++) {
|
||||
// EXPECT_EQ(computed_ft[i], expected[i]);
|
||||
// }
|
||||
auto computed = transform(X[1]);
|
||||
EXPECT_EQ(computed.size(), expected.size());
|
||||
for (unsigned long i = 0; i < computed.size(); i++) {
|
||||
EXPECT_EQ(computed[i], expected[i]);
|
||||
}
|
||||
auto computed_ft = fit_transform(X[1], y);
|
||||
EXPECT_EQ(computed_ft.size(), expected.size());
|
||||
for (unsigned long i = 0; i < computed_ft.size(); i++) {
|
||||
EXPECT_EQ(computed_ft[i], expected[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,11 @@
|
||||
// ****************************************************************
|
||||
// SPDX - FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||
// SPDX - FileType: SOURCE
|
||||
// SPDX - License - Identifier: MIT
|
||||
// ****************************************************************
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "../Metrics.h"
|
||||
#include "Metrics.h"
|
||||
|
||||
namespace mdlp {
|
||||
class TestMetrics : public Metrics, public testing::Test {
|
||||
|
222
tests/datasets/tests.txt
Normal file
222
tests/datasets/tests.txt
Normal file
@@ -0,0 +1,222 @@
|
||||
#
|
||||
# from, to, step, #bins, Q/U
|
||||
# discretized data
|
||||
# cut points
|
||||
#
|
||||
#
|
||||
# Range experiments
|
||||
#
|
||||
RANGE
|
||||
0, 100, 1, 4, Q
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
|
||||
0.0, 24.75, 49.5, 74.25, 99.0
|
||||
RANGE
|
||||
0, 50, 1, 4, Q
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
|
||||
0.0, 12.25, 24.5, 36.75, 49.0
|
||||
RANGE
|
||||
0, 100, 1, 3, Q
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
|
||||
0.0, 33.0, 66.0, 99.0
|
||||
RANGE
|
||||
0, 50, 1, 3, U
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
|
||||
0.0, 16.33333, 32.66667, 49.0
|
||||
RANGE
|
||||
0, 10, 1, 3, U
|
||||
0, 0, 0, 1, 1, 1, 2, 2, 2, 2
|
||||
0.0, 3.0, 6.0, 9.0
|
||||
RANGE
|
||||
1, 10, 1, 3, Q
|
||||
0, 0, 0, 1, 1, 1, 2, 2, 2
|
||||
1.0, 3.66667, 6.33333, 9.0
|
||||
RANGE
|
||||
1, 10, 1, 3, U
|
||||
0, 0, 0, 1, 1, 1, 2, 2, 2
|
||||
1.0, 3.66667, 6.33333, 9.0
|
||||
RANGE
|
||||
1, 11, 1, 3, Q
|
||||
0, 0, 0, 1, 1, 1, 2, 2, 2, 2
|
||||
1.0, 4.0, 7.0, 10.0
|
||||
RANGE
|
||||
1, 11, 1, 3, U
|
||||
0, 0, 0, 1, 1, 1, 2, 2, 2, 2
|
||||
1.0, 4.0, 7.0, 10.0
|
||||
RANGE
|
||||
1, 12, 1, 3, Q
|
||||
0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2
|
||||
1.0, 4.33333, 7.66667, 11.0
|
||||
RANGE
|
||||
1, 12, 1, 3, U
|
||||
0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2
|
||||
1.0, 4.33333, 7.66667, 11.0
|
||||
RANGE
|
||||
1, 13, 1, 3, Q
|
||||
0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2
|
||||
1.0, 4.66667, 8.33333, 12.0
|
||||
RANGE
|
||||
1, 13, 1, 3, U
|
||||
0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2
|
||||
1.0, 4.66667, 8.33333, 12.0
|
||||
RANGE
|
||||
1, 14, 1, 3, Q
|
||||
0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2
|
||||
1.0, 5.0, 9.0, 13.0
|
||||
RANGE
|
||||
1, 14, 1, 3, U
|
||||
0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2
|
||||
1.0, 5.0, 9.0, 13.0
|
||||
RANGE
|
||||
1, 15, 1, 3, Q
|
||||
0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2
|
||||
1.0, 5.33333, 9.66667, 14.0
|
||||
RANGE
|
||||
1, 15, 1, 3, U
|
||||
0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2
|
||||
1.0, 5.33333, 9.66667, 14.0
|
||||
#
|
||||
# Vector experiments
|
||||
#
|
||||
VECTOR
|
||||
Q3[3.0, 1.0, 1.0, 3.0, 1.0, 1.0, 3.0, 1.0, 1.0]
|
||||
1, 0, 0, 1, 0, 0, 1, 0, 0
|
||||
1.0, 1.66667, 3.0
|
||||
VECTOR
|
||||
U3[3.0, 1.0, 1.0, 3.0, 1.0, 1.0, 3.0, 1.0, 1.0]
|
||||
2, 0, 0, 2, 0, 0, 2, 0, 0
|
||||
1.0, 1.66667, 2.33333, 3.0
|
||||
VECTOR
|
||||
Q3[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]
|
||||
0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2
|
||||
1.0, 4.66667, 8.33333, 12.0
|
||||
VECTOR
|
||||
U3[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]
|
||||
0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2
|
||||
1.0, 4.66667, 8.33333, 12.0
|
||||
VECTOR
|
||||
Q3[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0]
|
||||
0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2
|
||||
1.0, 5.0, 9.0, 13.0
|
||||
VECTOR
|
||||
U3[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0]
|
||||
0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2
|
||||
1.0, 5.0, 9.0, 13.0
|
||||
VECTOR
|
||||
Q3[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0]
|
||||
0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2
|
||||
1.0, 5.33333, 9.66667, 14.0
|
||||
VECTOR
|
||||
U3[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0]
|
||||
0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2
|
||||
1.0, 5.33333, 9.66667, 14.0
|
||||
VECTOR
|
||||
Q3[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0]
|
||||
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2
|
||||
1.0, 5.66667, 10.33333, 15.0
|
||||
VECTOR
|
||||
U3[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0]
|
||||
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2
|
||||
1.0, 5.66667, 10.33333, 15.0
|
||||
VECTOR
|
||||
Q3[15.0, 8.0, 12.0, 14.0, 6.0, 1.0, 13.0, 11.0, 10.0, 9.0, 7.0, 4.0, 3.0, 5.0, 2.0]
|
||||
2, 1, 2, 2, 1, 0, 2, 2, 1, 1, 1, 0, 0, 0, 0
|
||||
1.0, 5.66667, 10.33333, 15.0
|
||||
VECTOR
|
||||
U3[15.0, 8.0, 12.0, 14.0, 6.0, 1.0, 13.0, 11.0, 10.0, 9.0, 7.0, 4.0, 3.0, 5.0, 2.0]
|
||||
2, 1, 2, 2, 1, 0, 2, 2, 1, 1, 1, 0, 0, 0, 0
|
||||
1.0, 5.66667, 10.33333, 15.0
|
||||
VECTOR
|
||||
Q3[0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0, 4.0]
|
||||
0, 1, 1, 1, 1, 1, 2, 2, 2, 2
|
||||
0.0, 1.0, 3.0, 4.0
|
||||
VECTOR
|
||||
U3[0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0, 4.0]
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 2, 2
|
||||
0.0, 1.33333, 2.66667, 4.0
|
||||
#
|
||||
# Vector experiments with iris
|
||||
#
|
||||
VECTOR
|
||||
Q3[5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.9, 5.4, 4.8, 4.8, 4.3, 5.8, 5.7, 5.4, 5.1, 5.7, 5.1, 5.4, 5.1, 4.6, 5.1, 4.8, 5.0, 5.0, 5.2, 5.2, 4.7, 4.8, 5.4, 5.2, 5.5, 4.9, 5.0, 5.5, 4.9, 4.4, 5.1, 5.0, 4.5, 4.4, 5.0, 5.1, 4.8, 5.1, 4.6, 5.3, 5.0, 7.0, 6.4, 6.9, 5.5, 6.5, 5.7, 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 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 3, 3, 3, 2, 3, 3, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 2, 3, 3, 3, 2, 3, 2, 2, 2, 3, 2, 3, 3, 3, 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2
|
||||
0.1, 0.7, 1.3, 1.9, 2.5
|
1
tests/lib/Files
Submodule
1
tests/lib/Files
Submodule
Submodule tests/lib/Files added at a5316928d4
15
tests/test
15
tests/test
@@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
if [ -d build ] && [ "$1" != "run" ]; then
|
||||
rm -fr build
|
||||
fi
|
||||
if [ -d gcovr-report ] ; then
|
||||
rm -fr gcovr-report
|
||||
fi
|
||||
cmake -S . -B build -Wno-dev -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="--coverage" -DCMAKE_C_FLAGS="--coverage"
|
||||
cmake --build build
|
||||
cd build
|
||||
ctest --output-on-failure
|
||||
cd ..
|
||||
mkdir gcovr-report
|
||||
cd ..
|
||||
gcovr --gcov-filter "CPPFImdlp.cpp" --gcov-filter "Metrics.cpp" --gcov-filter "BinDisc.cpp" --gcov-filter "Discretizer.cpp" --txt --sonarqube=tests/gcovr-report/coverage.xml --exclude-noncode-lines
|
@@ -1,412 +0,0 @@
|
||||
from scipy.io.arff import loadarff
|
||||
from sklearn.preprocessing import KBinsDiscretizer
|
||||
|
||||
|
||||
def test(clf, X, expected, title):
|
||||
X = [[x] for x in X]
|
||||
clf.fit(X)
|
||||
computed = [int(x[0]) for x in clf.transform(X)]
|
||||
print(f"{title}")
|
||||
print(f"{computed=}")
|
||||
print(f"{expected=}")
|
||||
assert computed == expected
|
||||
print("-" * 80)
|
||||
|
||||
|
||||
# Test Uniform Strategy
|
||||
clf3u = KBinsDiscretizer(
|
||||
n_bins=3, encode="ordinal", strategy="uniform", subsample=200_000
|
||||
)
|
||||
clf3q = KBinsDiscretizer(
|
||||
n_bins=3, encode="ordinal", strategy="quantile", subsample=200_000
|
||||
)
|
||||
clf4u = KBinsDiscretizer(
|
||||
n_bins=4, encode="ordinal", strategy="uniform", subsample=200_000
|
||||
)
|
||||
clf4q = KBinsDiscretizer(
|
||||
n_bins=4, encode="ordinal", strategy="quantile", subsample=200_000
|
||||
)
|
||||
#
|
||||
X = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
|
||||
labels = [0, 0, 0, 1, 1, 1, 2, 2, 2]
|
||||
test(clf3u, X, labels, title="Easy3BinsUniform")
|
||||
test(clf3q, X, labels, title="Easy3BinsQuantile")
|
||||
#
|
||||
X = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
|
||||
labels = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2]
|
||||
# En C++ se obtiene el mismo resultado en ambos, no como aquí
|
||||
labels2 = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]
|
||||
test(clf3u, X, labels, title="X10BinsUniform")
|
||||
test(clf3q, X, labels2, title="X10BinsQuantile")
|
||||
#
|
||||
X = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0]
|
||||
labels = [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]
|
||||
# En C++ se obtiene el mismo resultado en ambos, no como aquí
|
||||
# labels2 = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]
|
||||
test(clf3u, X, labels, title="X11BinsUniform")
|
||||
test(clf3q, X, labels, title="X11BinsQuantile")
|
||||
#
|
||||
X = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
|
||||
labels = [0, 0, 0, 0, 0, 0]
|
||||
test(clf3u, X, labels, title="ConstantUniform")
|
||||
test(clf3q, X, labels, title="ConstantQuantile")
|
||||
#
|
||||
X = [3.0, 1.0, 1.0, 3.0, 1.0, 1.0, 3.0, 1.0, 1.0]
|
||||
labels = [2, 0, 0, 2, 0, 0, 2, 0, 0]
|
||||
labels2 = [1, 0, 0, 1, 0, 0, 1, 0, 0] # igual que en C++
|
||||
test(clf3u, X, labels, title="EasyRepeatedUniform")
|
||||
test(clf3q, X, labels2, title="EasyRepeatedQuantile")
|
||||
#
|
||||
X = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]
|
||||
labels = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3]
|
||||
test(clf4u, X, labels, title="Easy4BinsUniform")
|
||||
test(clf4q, X, labels, title="Easy4BinsQuantile")
|
||||
#
|
||||
X = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0]
|
||||
labels = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3]
|
||||
test(clf4u, X, labels, title="X13BinsUniform")
|
||||
test(clf4q, X, labels, title="X13BinsQuantile")
|
||||
#
|
||||
X = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0]
|
||||
labels = [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3]
|
||||
test(clf4u, X, labels, title="X14BinsUniform")
|
||||
test(clf4q, X, labels, title="X14BinsQuantile")
|
||||
#
|
||||
X1 = [15.0, 8.0, 12.0, 14.0, 6.0, 1.0, 13.0, 11.0, 10.0, 9.0, 7.0, 4.0, 3.0, 5.0, 2.0]
|
||||
X2 = [15.0, 13.0, 12.0, 14.0, 6.0, 1.0, 8.0, 11.0, 10.0, 9.0, 7.0, 4.0, 3.0, 5.0, 2.0]
|
||||
labels1 = [3, 2, 3, 3, 1, 0, 3, 2, 2, 2, 1, 0, 0, 1, 0]
|
||||
labels2 = [3, 3, 3, 3, 1, 0, 2, 2, 2, 2, 1, 0, 0, 1, 0]
|
||||
test(clf4u, X1, labels1, title="X15BinsUniform")
|
||||
test(clf4q, X2, labels2, title="X15BinsQuantile")
|
||||
#
|
||||
X = [0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0, 4.0]
|
||||
labels = [0, 1, 1, 1, 2, 2, 3, 3, 3, 3]
|
||||
test(clf4u, X, labels, title="RepeatedValuesUniform")
|
||||
test(clf4q, X, labels, title="RepeatedValuesQuantile")
|
||||
|
||||
print(f"Uniform {clf4u.bin_edges_=}")
|
||||
print(f"Quaintile {clf4q.bin_edges_=}")
|
||||
print("-" * 80)
|
||||
#
|
||||
data, meta = loadarff("tests/datasets/iris.arff")
|
||||
|
||||
labelsu = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
0,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
]
|
||||
labelsq = [
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
1,
|
||||
3,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
3,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
0,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
1,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
]
|
||||
# test(clf4u, data["sepallength"], labelsu, title="IrisUniform")
|
||||
# test(clf4q, data["sepallength"], labelsq, title="IrisQuantile")
|
||||
sepallength = [[x] for x in data["sepallength"]]
|
||||
clf4u.fit(sepallength)
|
||||
clf4q.fit(sepallength)
|
||||
computedu = clf4u.transform(sepallength)
|
||||
computedq = clf4q.transform(sepallength)
|
||||
wrongu = 0
|
||||
wrongq = 0
|
||||
for i in range(len(labelsu)):
|
||||
if labelsu[i] != computedu[i]:
|
||||
wrongu += 1
|
||||
if labelsq[i] != computedq[i]:
|
||||
wrongq += 1
|
||||
print(f"Iris sepallength diff. between BinDisc & sklearn::KBins Uniform ={wrongu:3d}")
|
||||
print(f"Iris sepallength diff. between BinDisc & sklearn::KBins Quantile ={wrongq:3d}")
|
71
tests/tests_do.py
Normal file
71
tests/tests_do.py
Normal file
@@ -0,0 +1,71 @@
|
||||
# ***************************************************************
|
||||
# SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||
# SPDX-FileType: SOURCE
|
||||
# SPDX-License-Identifier: MIT
|
||||
# ***************************************************************
|
||||
|
||||
import json
|
||||
from sklearn.preprocessing import KBinsDiscretizer
|
||||
|
||||
with open("datasets/tests.txt") as f:
|
||||
data = f.readlines()
|
||||
|
||||
data = [x.strip() for x in data if x[0] != "#"]
|
||||
|
||||
errors = False
|
||||
for i in range(0, len(data), 4):
|
||||
experiment_type = data[i]
|
||||
print("Experiment:", data[i + 1])
|
||||
if experiment_type == "RANGE":
|
||||
range_data = data[i + 1]
|
||||
from_, to_, step_, n_bins_, strategy_ = range_data.split(",")
|
||||
X = [[float(x)] for x in range(int(from_), int(to_), int(step_))]
|
||||
else:
|
||||
strategy_ = data[i + 1][0]
|
||||
n_bins_ = data[i + 1][1]
|
||||
vector = data[i + 1][2:]
|
||||
X = [[float(x)] for x in json.loads(vector)]
|
||||
|
||||
strategy = "quantile" if strategy_.strip() == "Q" else "uniform"
|
||||
disc = KBinsDiscretizer(
|
||||
n_bins=int(n_bins_),
|
||||
encode="ordinal",
|
||||
strategy=strategy,
|
||||
)
|
||||
expected_data = data[i + 2]
|
||||
cuts_data = data[i + 3]
|
||||
disc.fit(X)
|
||||
#
|
||||
# Normalize the cutpoints to remove numerical errors such as 33.0000000001
|
||||
# instead of 33
|
||||
#
|
||||
for j in range(len(disc.bin_edges_[0])):
|
||||
disc.bin_edges_[0][j] = round(disc.bin_edges_[0][j], 5)
|
||||
result = disc.transform(X)
|
||||
result = [int(x) for x in result.flatten()]
|
||||
expected = [int(x) for x in expected_data.split(",")]
|
||||
#
|
||||
# Check the Results
|
||||
#
|
||||
assert len(result) == len(expected)
|
||||
for j in range(len(result)):
|
||||
if result[j] != expected[j]:
|
||||
print("* Error at", j, "Expected=", expected[j], "Result=", result[j])
|
||||
errors = True
|
||||
expected_cuts = disc.bin_edges_[0]
|
||||
computed_cuts = [float(x) for x in cuts_data.split(",")]
|
||||
assert len(expected_cuts) == len(computed_cuts)
|
||||
for j in range(len(expected_cuts)):
|
||||
if round(expected_cuts[j], 5) != computed_cuts[j]:
|
||||
print(
|
||||
"* Error at",
|
||||
j,
|
||||
"Expected=",
|
||||
expected_cuts[j],
|
||||
"Result=",
|
||||
computed_cuts[j],
|
||||
)
|
||||
errors = True
|
||||
if errors:
|
||||
raise Exception("There were errors!")
|
||||
print("*** All tests run succesfully! ***")
|
209
tests/tests_generate.ipynb
Normal file
209
tests/tests_generate.ipynb
Normal file
@@ -0,0 +1,209 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from sklearn.preprocessing import KBinsDiscretizer\n",
|
||||
"from sklearn.datasets import load_iris"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"experiments_range = [\n",
|
||||
" [0, 100, 1, 4, \"Q\"],\n",
|
||||
" [0, 50, 1, 4, \"Q\"],\n",
|
||||
" [0, 100, 1, 3, \"Q\"],\n",
|
||||
" [0, 50, 1, 3, \"Q\"],\n",
|
||||
" [0, 10, 1, 3, \"Q\"],\n",
|
||||
" [0, 100, 1, 4, \"U\"],\n",
|
||||
" [0, 50, 1, 4, \"U\"],\n",
|
||||
" [0, 100, 1, 3, \"U\"],\n",
|
||||
" [0, 50, 1, 3, \"U\"],\n",
|
||||
"# \n",
|
||||
" [0, 10, 1, 3, \"U\"],\n",
|
||||
" [1, 10, 1, 3, \"Q\"],\n",
|
||||
" [1, 10, 1, 3, \"U\"],\n",
|
||||
" [1, 11, 1, 3, \"Q\"],\n",
|
||||
" [1, 11, 1, 3, \"U\"],\n",
|
||||
" [1, 12, 1, 3, \"Q\"],\n",
|
||||
" [1, 12, 1, 3, \"U\"],\n",
|
||||
" [1, 13, 1, 3, \"Q\"],\n",
|
||||
" [1, 13, 1, 3, \"U\"],\n",
|
||||
" [1, 14, 1, 3, \"Q\"],\n",
|
||||
" [1, 14, 1, 3, \"U\"],\n",
|
||||
" [1, 15, 1, 3, \"Q\"],\n",
|
||||
" [1, 15, 1, 3, \"U\"]\n",
|
||||
"]\n",
|
||||
"experiments_vectors = [\n",
|
||||
" (3, [3.0, 1.0, 1.0, 3.0, 1.0, 1.0, 3.0, 1.0, 1.0]),\n",
|
||||
" (3, [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]),\n",
|
||||
" (3, [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0]),\n",
|
||||
" (3, [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0]),\n",
|
||||
" (3, [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0]),\n",
|
||||
" (3, [15.0, 8.0, 12.0, 14.0, 6.0, 1.0, 13.0, 11.0, 10.0, 9.0, 7.0, 4.0, 3.0, 5.0, 2.0]),\n",
|
||||
" (3, [0.0, 1.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0, 4.0])\n",
|
||||
"]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/home/rmontanana/miniconda3/lib/python3.11/site-packages/sklearn/preprocessing/_discretization.py:307: UserWarning: Bins whose width are too small (i.e., <= 1e-8) in feature 0 are removed. Consider decreasing the number of bins.\n",
|
||||
" warnings.warn(\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def write_lists(file, data, cuts):\n",
|
||||
" sep = \"\"\n",
|
||||
" for res in data:\n",
|
||||
" file.write(f\"{sep}{int(res):d}\")\n",
|
||||
" sep= \", \"\n",
|
||||
" file.write(\"\\n\")\n",
|
||||
" sep = \"\"\n",
|
||||
" for res in cuts:\n",
|
||||
" file.write(sep + str(round(res,5)))\n",
|
||||
" sep = \", \"\n",
|
||||
" file.write(\"\\n\")\n",
|
||||
"\n",
|
||||
"def normalize_cuts(cuts):\n",
|
||||
" #\n",
|
||||
" # Normalize the cutpoints to remove numerical errors such as 33.0000000001\n",
|
||||
" # instead of 33\n",
|
||||
" #\n",
|
||||
" for k in range(cuts.shape[0]):\n",
|
||||
" for i in range(len(cuts[k])):\n",
|
||||
" cuts[k][i] = round(cuts[k][i], 5)\n",
|
||||
"\n",
|
||||
"with open(\"datasets/tests.txt\", \"w\") as file:\n",
|
||||
" file.write(\"#\\n\")\n",
|
||||
" file.write(\"# from, to, step, #bins, Q/U\\n\")\n",
|
||||
" file.write(\"# discretized data\\n\")\n",
|
||||
" file.write(\"# cut points\\n\")\n",
|
||||
" file.write(\"#\\n\")\n",
|
||||
" #\n",
|
||||
" # Range experiments\n",
|
||||
" #\n",
|
||||
" file.write(\"#\\n\")\n",
|
||||
" file.write(\"# Range experiments\\n\")\n",
|
||||
" file.write(\"#\\n\")\n",
|
||||
" for experiment in experiments_range:\n",
|
||||
" file.write(\"RANGE\\n\")\n",
|
||||
" (from_, to_, step_, bins_, strategy) = experiment\n",
|
||||
" disc = KBinsDiscretizer(n_bins=bins_, encode='ordinal', strategy='quantile' if strategy.strip() == \"Q\" else 'uniform')\n",
|
||||
" data = [[x] for x in range(from_, to_, step_)]\n",
|
||||
" disc.fit(data)\n",
|
||||
" normalize_cuts(disc.bin_edges_)\n",
|
||||
" result = disc.transform(data)\n",
|
||||
" file.write(f\"{from_}, {to_}, {step_}, {bins_}, {strategy}\\n\")\n",
|
||||
" write_lists(file, result, disc.bin_edges_[0])\n",
|
||||
" #\n",
|
||||
" # Vector experiments\n",
|
||||
" #\n",
|
||||
" file.write(\"#\\n\")\n",
|
||||
" file.write(\"# Vector experiments\\n\")\n",
|
||||
" file.write(\"#\\n\")\n",
|
||||
" for n_bins, experiment in experiments_vectors:\n",
|
||||
" for strategy in [\"Q\", \"U\"]:\n",
|
||||
" file.write(\"VECTOR\\n\")\n",
|
||||
" file.write(f\"{strategy}{n_bins}{experiment}\\n\")\n",
|
||||
" disc = KBinsDiscretizer(\n",
|
||||
" n_bins=n_bins,\n",
|
||||
" encode=\"ordinal\",\n",
|
||||
" \n",
|
||||
" strategy=\"quantile\" if strategy.strip() == \"Q\" else \"uniform\",\n",
|
||||
" )\n",
|
||||
" data = [[x] for x in experiment]\n",
|
||||
" disc.fit(data)\n",
|
||||
" normalize_cuts(disc.bin_edges_)\n",
|
||||
" result = disc.transform(data)\n",
|
||||
" write_lists(file, result, disc.bin_edges_[0])\n",
|
||||
" #\n",
|
||||
" # Vector experiments iris\n",
|
||||
" #\n",
|
||||
" file.write(\"#\\n\");\n",
|
||||
" file.write(\"# Vector experiments with iris\\n\");\n",
|
||||
" file.write(\"#\\n\");\n",
|
||||
" X, y = load_iris(return_X_y=True)\n",
|
||||
" for i in range(X.shape[1]):\n",
|
||||
" for n_bins in [3, 4]:\n",
|
||||
" for strategy in [\"Q\", \"U\"]:\n",
|
||||
" file.write(\"VECTOR\\n\")\n",
|
||||
" experiment = X[:, i]\n",
|
||||
" file.write(f\"{strategy}{n_bins}{experiment.tolist()}\\n\")\n",
|
||||
" disc = KBinsDiscretizer(\n",
|
||||
" n_bins=n_bins,\n",
|
||||
" encode=\"ordinal\",\n",
|
||||
" strategy=\"quantile\" if strategy.strip() == \"Q\" else \"uniform\")\n",
|
||||
" data = [[x] for x in experiment]\n",
|
||||
" disc.fit(data)\n",
|
||||
" normalize_cuts(disc.bin_edges_)\n",
|
||||
" result = disc.transform(data)\n",
|
||||
" write_lists(file, result, disc.bin_edges_[0])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Cut points: [array([ 0., 33., 66., 99.])]\n",
|
||||
"Mistaken transformed data disc.transform([[33]]) = [[0.]]\n",
|
||||
"Reason of the mistake the cutpoint has decimals (double): 33.00000000000001\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#\n",
|
||||
"# Proving the mistakes due to floating point precision\n",
|
||||
"#\n",
|
||||
"from sklearn.preprocessing import KBinsDiscretizer\n",
|
||||
"\n",
|
||||
"data = [[x] for x in range(100)]\n",
|
||||
"disc = KBinsDiscretizer(n_bins=3, encode=\"ordinal\", strategy=\"quantile\")\n",
|
||||
"disc.fit(data)\n",
|
||||
"print(\"Cut points: \", disc.bin_edges_)\n",
|
||||
"print(\"Mistaken transformed data disc.transform([[33]]) =\", disc.transform([[33]]))\n",
|
||||
"print(\"Reason of the mistake the cutpoint has decimals (double): \", disc.bin_edges_[0][1])"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.1.undefined"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
Reference in New Issue
Block a user