SuperNN  1.0.0
Public Member Functions | Public Attributes | List of all members
SuperNN::Data Struct Reference

Data used in training, validation and testing. More...

Inheritance diagram for SuperNN::Data:
Inheritance graph
[legend]

Public Member Functions

 Data ()
 
 Data (unsigned rows, unsigned cols)
 Constructor. More...
 
 Data (unsigned rows, unsigned cols, const double st[])
 Constructor. More...
 
 Data (unsigned rows, unsigned cols, const Row &row)
 Constructor. More...
 
virtual ~Data ()
 
Rowadd ()
 Adds a row to the data, returning a reference to it. More...
 
Boundscalc_bounds ()
 Calculates and sets the data bounds using the minimum and maximum values of each neuron. More...
 
void descale ()
 Descales the data. More...
 
Data drop_column (unsigned col) const
 Returns a copy of the current object, without a column. More...
 
double get (unsigned row, unsigned col) const
 Returns the value in the (row,col) cell. More...
 
void k_fold (unsigned n, unsigned k, Data &p, Data &l) const
 Fills two Data objects with complementary information, useful for cross-validation. More...
 
unsigned load_file (const std::string &path)
 Reads values from a file and appends then into the data. More...
 
Data sample (unsigned first, unsigned last) const
 Samples the data. More...
 
void save_file (const std::string &path) const
 Erases the contents of a file and saves the Data values into it. More...
 
void save_info_file (const std::string &path) const
 Erases the contents of a file and saves the Data bounds info into it. More...
 
void scale ()
 Scales the data, neuron per neuron, using the current from and to bounds. More...
 
void scale (double min, double max)
 Scales the data, neuron per neuron, using the current "from" bounds. More...
 
void scale_column (unsigned n, const SInfo &curv, const SInfo &newv)
 Scales a single data column. More...
 
void set (unsigned row, unsigned col, double val)
 Sets the value in the (row,col) cell to value. More...
 
void shuffle ()
 Randomizes the positions of the rows. More...
 

Public Attributes

Bounds from
 Original data bounds. More...
 
size_t n_total
 Number of inputs + outputs per row. More...
 
Bounds to
 Scaled data bounds. More...
 

Detailed Description

Data used in training, validation and testing.

Definition at line 95 of file data.hpp.

Constructor & Destructor Documentation

SuperNN::Data::Data ( )

Definition at line 110 of file data.cpp.

SuperNN::Data::~Data ( )
virtual

Definition at line 120 of file data.cpp.

SuperNN::Data::Data ( unsigned  rows,
unsigned  cols 
)

Constructor.

Parameters
rowsNumber of rows
colsNumber of columns (inputs + outputs)

Definition at line 114 of file data.cpp.

SuperNN::Data::Data ( unsigned  rows,
unsigned  cols,
const double  st[] 
)

Constructor.

Reads the values from a static array.

Parameters
rowsNumber of rows
nNumber of columns (inputs + outputs)
stStatic array with the data values

Definition at line 124 of file data.cpp.

SuperNN::Data::Data ( unsigned  rows,
unsigned  cols,
const Row row 
)

Constructor.

Reads the values from a vector.

Parameters
rowsNumber of rows
nNumber of columns (inputs + outputs)
stVector (one dimension) with the data values

Definition at line 139 of file data.cpp.

Member Function Documentation

Row & SuperNN::Data::add ( )

Adds a row to the data, returning a reference to it.

Returns
Reference to the added row

Definition at line 212 of file data.cpp.

Bounds & SuperNN::Data::calc_bounds ( )

Calculates and sets the data bounds using the minimum and maximum values of each neuron.

Returns
Calculated bounds

Definition at line 297 of file data.cpp.

void SuperNN::Data::descale ( )

Descales the data.

Definition at line 342 of file data.cpp.

Data SuperNN::Data::drop_column ( unsigned  col) const

Returns a copy of the current object, without a column.

Parameters
colColumn that will be missing
Returns
Copy of the current object, without a column

Definition at line 154 of file data.cpp.

double SuperNN::Data::get ( unsigned  row,
unsigned  col 
) const
inline

Returns the value in the (row,col) cell.

Main a helper for bindings to other programming languages.

Parameters
rowRow
colColumn
Returns
Value at (row,col)

Definition at line 242 of file data.hpp.

void SuperNN::Data::k_fold ( unsigned  n,
unsigned  k,
Data p,
Data l 
) const

Fills two Data objects with complementary information, useful for cross-validation.

The first Data object is filled with the N-th partition (0 based) of the original data, while the another one is filled with the remaining rows. Each one of the K partitions have roughly the same size, and the original data is left unmodified.

Parameters
nPartition to get
kTotal number of partitions
pData that will be filled with the rows from the selected partition
lData that will be filled with the remaining rows

Definition at line 348 of file data.cpp.

unsigned SuperNN::Data::load_file ( const std::string &  path)

Reads values from a file and appends then into the data.

Parameters
pathInput file path
Returns
Number of added rows
Exceptions
Exceptionif it couldn't open the file or it has invalid contents

Definition at line 218 of file data.cpp.

Data SuperNN::Data::sample ( unsigned  first,
unsigned  last 
) const

Samples the data.

Parameters
firstFirst row (zero-based, including)
lastLast row (zero-based, excluding)
Returns
A new data object containing the rows from first to last

Definition at line 194 of file data.cpp.

void SuperNN::Data::save_file ( const std::string &  path) const

Erases the contents of a file and saves the Data values into it.

Parameters
pathOutput file path
Exceptions
Exceptionif the output file couldn't be written

Definition at line 256 of file data.cpp.

void SuperNN::Data::save_info_file ( const std::string &  path) const

Erases the contents of a file and saves the Data bounds info into it.

Parameters
pathOutput file path
Exceptions
Exceptionif the output file couldn't be written

Definition at line 280 of file data.cpp.

void SuperNN::Data::scale ( )

Scales the data, neuron per neuron, using the current from and to bounds.

You need to set the bounds prior to calling this function.

Definition at line 327 of file data.cpp.

void SuperNN::Data::scale ( double  min,
double  max 
)

Scales the data, neuron per neuron, using the current "from" bounds.

Sets the "to" bounds of every neuron to min and max. You need to call calc_bounds() or manually set the from bounds prior to calling this function.

Parameters
minNew minimum value
maxNew maximum value

Definition at line 333 of file data.cpp.

void SuperNN::Data::scale_column ( unsigned  n,
const SInfo curv,
const SInfo newv 
)

Scales a single data column.

Parameters
nColumn to scale
curvCurrent bounds
newvNew bounds

Definition at line 321 of file data.cpp.

void SuperNN::Data::set ( unsigned  row,
unsigned  col,
double  val 
)
inline

Sets the value in the (row,col) cell to value.

Main a helper for bindings to other programming languages.

Parameters
rowRow
colColumn
valueValue to write at (row,col)

Definition at line 255 of file data.hpp.

void SuperNN::Data::shuffle ( )

Randomizes the positions of the rows.

Definition at line 189 of file data.cpp.

Member Data Documentation

Bounds SuperNN::Data::from

Original data bounds.

Definition at line 261 of file data.hpp.

size_t SuperNN::Data::n_total

Number of inputs + outputs per row.

Definition at line 267 of file data.hpp.

Bounds SuperNN::Data::to

Scaled data bounds.

Definition at line 264 of file data.hpp.