Patterns¶
-
class
Patterns
¶ Abstract type used to store the input Pattern as (data, labels). To be provided as an argument to
focusingBP
.Inputs and outputs must have the same length. Outputs entries must be ∈ {-1,1}. Intputs entries must be arrays in which each element is ∈ {-1,1}, and all the vectors must have the same length. The input pattern can be loaded from binary/ascii file, random generated or from a given matrix.
Public Functions
-
Patterns
()¶ Default constructor.
-
Patterns
(const std::string &filename, bool bin = false, const std::string &del = "t")¶ Load pattern from file.
The input file can store the values in binary or ascii format. For the binary format the function requires a file formatted following these instructions:
- Number of rows (long int)
- Number of columns (long int)
- labels array (long int) with a length equal to the number of rows
- data matrix (double) with a shape (number of rows x number of columns).
For the ascii format the function requires a file formatted following these instructions:
- labels array (as a series of separated numbers)
- matrix of data (as a series of rows separated by
\n
)
- Note
- Outputs entries must be ∈ {-1,1}. Intputs entries must be arrays in which each element is ∈ {-1,1}.
- Note
- In the ascii format the delimiter of the file can be set using the
del
variable. - Parameters
filename
: Input filenamebin
: switch between binary/ascii files (default = false)del
: delimiter string if the file is in ascii fmt (default = “\t”)
-
Patterns
(const long int &N, const long int &M)¶ Generate random patter.
The pattern is generated using a Bernoulli distribution and thus it creates a data (matrix) + labels (vector) of binary values. The values are converted into the range (-1, 1) for the compatibility with the rFBP algorithm.
- Parameters
N
: number of input vectors (samples)M
: number of columns (probes)
-
Patterns
(double **data, long int *label, const int &Nrow, const int &Ncol)¶ Copy pattern from arrays.
Data and labels are copied, so be careful with this constructor.
- Note
- The copy of the arrays is performed for compatibility with the Python API of the library.
- Parameters
data
: matrix of data in double formatlabel
: array of labelsNrow
: number of rows in data matrixNcol
: number of columns in data matrix
-
Patterns &
operator=
(const Patterns &p)¶ Copy operator.
The operator performs a deep copy of the object and if there are buffers already allocated, the operatore deletes them and then re-allocates an appropriated portion of memory.
- Parameters
p
: Pattern object
-
Patterns
(const Patterns &p)¶ Copy constructor.
The copy constructor provides a deep copy of the object, i.e. all the arrays are copied and not moved.
- Parameters
p
: Pattern object
-
~Patterns
()¶ Destructor.
Completely destroy the object releasing the data/labels memory.
-