Remove unneeded loop in sortIndices

Add some static casts
This commit is contained in:
2023-03-19 19:13:37 +01:00
parent f0845c5bd1
commit cfade7a556
9 changed files with 210 additions and 146 deletions

View File

@@ -38,17 +38,17 @@ tuple<string, string, int, int, float> parse_arguments(int argc, char **argv) {
int max_depth = numeric_limits<int>::max();
int min_length = 3;
float max_cutpoints = 0;
static struct option long_options[] = {
const option long_options[] = {
{"help", no_argument, nullptr, 'h'},
{"file", required_argument, nullptr, 'f'},
{"path", required_argument, nullptr, 'p'},
{"max_depth", required_argument, nullptr, 'm'},
{"max_cutpoints", required_argument, nullptr, 'c'},
{"min_length", required_argument, nullptr, 'n'},
{nullptr, 0, nullptr, 0}
{nullptr, no_argument, nullptr, 0}
};
while (true) {
auto c = getopt_long(argc, argv, "hf:p:m:c:n:", long_options, nullptr);
const auto c = getopt_long(argc, argv, "hf:p:m:c:n:", long_options, nullptr);
if (c == -1)
break;
switch (c) {
@@ -56,16 +56,16 @@ tuple<string, string, int, int, float> parse_arguments(int argc, char **argv) {
usage(argv[0]);
exit(0);
case 'f':
file_name = optarg;
file_name = string(optarg);
break;
case 'm':
max_depth = (int) strtol(optarg, nullptr, 10);
max_depth = stoi(optarg);
break;
case 'n':
min_length = (int) strtol(optarg, nullptr, 10);
min_length = stoi(optarg);
break;
case 'c':
max_cutpoints = strtof(optarg, nullptr);
max_cutpoints = stof(optarg);
break;
case 'p':
path = optarg;
@@ -92,7 +92,7 @@ void process_file(const string &path, const string &file_name, bool class_last,
file.load(path + file_name + ".arff", class_last);
auto attributes = file.getAttributes();
int items = file.getSize();
auto items = file.getSize();
cout << "Number of lines: " << items << endl;
cout << "Attributes: " << endl;
for (auto attribute: attributes) {
@@ -109,7 +109,7 @@ void process_file(const string &path, const string &file_name, bool class_last,
}
cout << y[i] << endl;
}
mdlp::CPPFImdlp test = mdlp::CPPFImdlp(min_length, max_depth, max_cutpoints);
auto test = mdlp::CPPFImdlp(min_length, max_depth, max_cutpoints);
auto total = 0;
for (auto i = 0; i < attributes.size(); i++) {
auto min_max = minmax_element(X[i].begin(), X[i].end());
@@ -141,7 +141,7 @@ void process_all_files(const map<string, bool> &datasets, const string &path, in
size_t timing = 0;
int cut_points = 0;
for (auto i = 0; i < attributes.size(); i++) {
mdlp::CPPFImdlp test = mdlp::CPPFImdlp(min_length, max_depth, max_cutpoints);
auto test = mdlp::CPPFImdlp(min_length, max_depth, max_cutpoints);
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
test.fit(X[i], y);
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
@@ -163,8 +163,10 @@ int main(int argc, char **argv) {
{"mfeat-factors", true},
{"test", true}
};
string file_name, path;
int max_depth, min_length;
string file_name;
string path;
int max_depth;
int min_length;
float max_cutpoints;
tie(file_name, path, max_depth, min_length, max_cutpoints) = parse_arguments(argc, argv);
if (datasets.find(file_name) == datasets.end() && file_name != "all") {