ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
IO.hpp
Go to the documentation of this file.
1
5#pragma once
6
8#include "utils/Types.hpp"
9
10#include <nlohmann/json.hpp>
11#include <string>
12
13namespace ppforest2::io {
18 void check_file_not_exists(std::string const& path);
19
24 void check_dir_not_exists(std::string const& path);
25}
26
33 std::string ensure_extension(std::string const& path);
34
40 nlohmann::json read_file(std::string const& path);
41
47 void write_file(nlohmann::json const& data, std::string const& path);
48}
49
63 stats::DataPacket read(std::string const& filename);
64
74 stats::DataPacket read_sorted(std::string const& filename);
75
81 void write(stats::DataPacket const& data, std::string const& filename);
82}
Definition IO.hpp:50
void write(stats::DataPacket const &data, std::string const &filename)
Write a DataPacket to a CSV file (features followed by label, no header).
stats::DataPacket read_sorted(std::string const &filename)
Read a CSV file and sort rows so that response groups are contiguous.
stats::DataPacket read(std::string const &filename)
Read a CSV file into a DataPacket.
Definition IO.hpp:27
nlohmann::json read_file(std::string const &path)
Read a JSON file and parse its contents.
std::string ensure_extension(std::string const &path)
Ensure a file path ends with the ".json" extension.
void write_file(nlohmann::json const &data, std::string const &path)
Write a JSON object to a file (pretty-printed with indent 2).
Definition Color.hpp:31
void check_dir_not_exists(std::string const &path)
Exit with an error if a directory already exists at the given path.
void check_file_not_exists(std::string const &path)
Exit with an error if a file already exists at the given path.
Bundled dataset: features, responses, and group labels.
Definition DataPacket.hpp:18