20 #ifndef SUPERNN_DATA_HPP
21 #define SUPERNN_DATA_HPP
30 static const double FSMALL = 1e-9;
38 SInfo(
double _min,
double _max);
40 double scale(
const SInfo &to,
double value)
const;
47 struct Bounds :
public std::vector<SInfo>
90 typedef std::vector<double>
Row;
95 struct Data :
public std::vector<Row>
106 Data(
unsigned rows,
unsigned cols);
130 Data(
unsigned rows,
unsigned cols,
const double st[]);
139 Data(
unsigned rows,
unsigned cols,
const Row &row);
153 Data sample(
unsigned first,
unsigned last)
const;
162 unsigned load_file(
const std::string &path);
170 void save_file(
const std::string &path)
const;
213 void scale(
double min,
double max);
242 inline double get(
unsigned row,
unsigned col)
const
255 inline void set(
unsigned row,
unsigned col,
double val)
void k_fold(unsigned n, unsigned k, Data &p, Data &l) const
Fills two Data objects with complementary information, useful for cross-validation.
void scale_column(unsigned n, const SInfo &curv, const SInfo &newv)
Scales a single data column.
Bounds from
Original data bounds.
Bounds & calc_bounds()
Calculates and sets the data bounds using the minimum and maximum values of each neuron.
Data sample(unsigned first, unsigned last) const
Samples the data.
void merge_with(const Bounds &other)
Merges the values from another Bounds with the current, retaining the limits.
void load_file(std::ifstream &inp)
Reads the scaling information from a file stream.
Minimum / maximum scaling information.
void save_file(const std::string &path) const
Erases the contents of a file and saves the Data values into it.
void scale()
Scales the data, neuron per neuron, using the current from and to bounds.
size_t n_total
Number of inputs + outputs per row.
Bounds to
Scaled data bounds.
Data scaling information, for all input and output neurons.
void set(unsigned row, unsigned col, double val)
Sets the value in the (row,col) cell to value.
double scale(const SInfo &to, double value) const
void save_file(std::ofstream &out) const
Appends the data bounds values into a file stream.
void save_info_file(const std::string &path) const
Erases the contents of a file and saves the Data bounds info into it.
std::vector< double > Row
Data row.
Data used in training, validation and testing.
void descale()
Descales the data.
unsigned load_file(const std::string &path)
Reads values from a file and appends then into the data.
void shuffle()
Randomizes the positions of the rows.
Data drop_column(unsigned col) const
Returns a copy of the current object, without a column.
Row & add()
Adds a row to the data, returning a reference to it.