This class represents the layer of principal component analysis. More...
#include <principal_components_layer.h>
Public Types | |
enum | PrincipalComponentsMethod { NoPrincipalComponents, PrincipalComponents } |
Enumeration of available methods for apply the principal components layer. | |
Public Types inherited from Layer | |
enum | LayerType { Scaling, Convolutional, Perceptron, Pooling, Probabilistic, LongShortTermMemory, Recurrent, Unscaling, Bounding, PrincipalComponents } |
This enumeration represents the possible types of layers. | |
Public Member Functions | |
PrincipalComponentsLayer () | |
PrincipalComponentsLayer (const size_t &, const size_t &) | |
PrincipalComponentsLayer (const PrincipalComponentsLayer &) | |
Copy constructor. | |
virtual | ~PrincipalComponentsLayer () |
Destructor. | |
const PrincipalComponentsMethod & | get_principal_components_method () const |
Returns the method used for principal components layer. | |
string | write_principal_components_method () const |
Returns a string with the name of the method used for principal components layer. | |
string | write_principal_components_method_text () const |
Matrix< double > | get_principal_components () const |
Returns a matrix containing the principal components. | |
Vector< double > | get_means () const |
Returns a vector containing the means of every input variable in the data set. | |
Vector< double > | get_explained_variance () const |
Returns a vector containing the explained variance of every of the principal components. | |
size_t | get_inputs_number () const |
Returns the number of inputs to the layer. | |
size_t | get_principal_components_number () const |
Returns the number of principal components. | |
size_t | get_neurons_number () const |
const bool & | get_display () const |
void | set () |
Sets the principal components layer to be empty. | |
void | set (const size_t &, const size_t &) |
void | set (const PrincipalComponentsLayer &) |
void | set_inputs_number (const size_t &) |
void | set_principal_components_number (const size_t &) |
void | set_principal_component (const size_t &, const Vector< double > &) |
void | set_principal_components (const Matrix< double > &) |
void | set_means (const Vector< double > &) |
void | set_means (const size_t &, const double &) |
void | set_explained_variance (const Vector< double > &) |
virtual void | set_default () |
void | set_principal_components_method (const PrincipalComponentsMethod &) |
void | set_principal_components_method (const string &) |
void | set_display (const bool &) |
Tensor< double > | calculate_outputs (const Tensor< double > &) |
string | write_expression (const Vector< string > &, const Vector< string > &) const |
Returns a string with the expression of the principal components process. | |
string | write_no_principal_components_expression (const Vector< string > &, const Vector< string > &) const |
Returns a string with the expression of the principal components process when none method is used. | |
string | write_principal_components_expression (const Vector< string > &, const Vector< string > &) const |
tinyxml2::XMLDocument * | to_XML () const |
virtual void | from_XML (const tinyxml2::XMLDocument &) |
void | write_XML (tinyxml2::XMLPrinter &) const |
Public Member Functions inherited from Layer | |
virtual void | initialize_parameters (const double &) |
virtual void | randomize_parameters_uniform (const double &=-1.0, const double &=1.0) |
virtual void | randomize_parameters_normal (const double &=0.0, const double &=1.0) |
virtual Vector< double > | get_parameters () const |
virtual size_t | get_parameters_number () const |
virtual void | set_parameters (const Vector< double > &) |
virtual Tensor< double > | calculate_outputs (const Tensor< double > &, const Vector< double > &) |
virtual Vector< double > | calculate_error_gradient (const Tensor< double > &, const Layer::FirstOrderActivations &, const Tensor< double > &) |
virtual FirstOrderActivations | calculate_first_order_activations (const Tensor< double > &) |
virtual Tensor< double > | calculate_output_delta (const Tensor< double > &, const Tensor< double > &) const |
virtual Tensor< double > | calculate_hidden_delta (Layer *, const Tensor< double > &, const Tensor< double > &, const Tensor< double > &) const |
virtual Vector< size_t > | get_input_variables_dimensions () const |
virtual void | set_neurons_number (const size_t &) |
virtual string | object_to_string () const |
LayerType | get_type () const |
string | get_type_string () const |
Takes the type of layer used by the model. | |
Protected Attributes | |
size_t | inputs_number |
Inputs number. | |
size_t | principal_components_number |
Principal components number. | |
Vector< double > | means |
Means of the input variables. | |
Matrix< double > | principal_components |
Vector< double > | explained_variance |
Explained variances for every of the principal components. | |
PrincipalComponentsMethod | principal_components_method |
Principal components layer method. | |
bool | display |
Display warning messages to screen. | |
Protected Attributes inherited from Layer | |
LayerType | layer_type = Perceptron |
Layer type object. | |
This class represents the layer of principal component analysis.
This layer is used to reduce the dimension of a dataset.
Definition at line 43 of file principal_components_layer.h.
|
explicit |
Default constructor. It creates a scaling layer object with no scaling neurons.
Definition at line 17 of file principal_components_layer.cpp.
|
explicit |
Principal components neurons number constructor. This constructor creates a principal components layer layer with a given size. The members of this object are initialized with the default values.
new_inputs_number | Number of original inputs. |
new_principal_components_number | Number of principal components neurons in the layer. |
Definition at line 29 of file principal_components_layer.cpp.
Performs the principal component analysis to produce a reduced data set.
inputs | Set of inputs to the principal components layer. |
Reimplemented from Layer.
Definition at line 166 of file principal_components_layer.cpp.
|
virtual |
Deserializes a TinyXML document into this principal components layer object.
document | XML document containing the member data. |
Definition at line 706 of file principal_components_layer.cpp.
const bool & get_display | ( | ) | const |
Returns true if messages from this class are to be displayed on the screen, or false if messages from this class are not to be displayed on the screen.
Definition at line 323 of file principal_components_layer.cpp.
void set | ( | const PrincipalComponentsLayer & | new_principal_components_layer | ) |
Sets the members of this object to be the members of another object of the same class.
new_principal_components_layer | Object to be copied. |
Definition at line 373 of file principal_components_layer.cpp.
void set | ( | const size_t & | new_inputs_number, |
const size_t & | new_principal_components_number | ||
) |
Sets a new size to the principal components layer. It also sets means and eigenvector matrix to zero.
new_inputs_number | New inputs number. |
new_principal_components_number | New principal components number. |
Definition at line 353 of file principal_components_layer.cpp.
|
virtual |
Sets the members to their default value.
Definition at line 475 of file principal_components_layer.cpp.
void set_display | ( | const bool & | new_display | ) |
Sets a new display value. If it is set to true messages from this class are to be displayed on the screen; if it is set to false messages from this class are not to be displayed on the screen.
new_display | Display value. |
Definition at line 525 of file principal_components_layer.cpp.
void set_explained_variance | ( | const Vector< double > & | new_explained_variance | ) |
Sets a new value to the explained variance member.
new_explained_variance | Object to be set. |
Definition at line 462 of file principal_components_layer.cpp.
|
virtual |
Sets a new value for the inputs number member.
new_inputs_number | New inputs number. |
Reimplemented from Layer.
Definition at line 405 of file principal_components_layer.cpp.
void set_means | ( | const size_t & | new_size, |
const double & | new_value | ||
) |
Sets a new size and a new value to the means.
new_size | New size of the vector means. |
new_value | New value of the vector means. |
Definition at line 451 of file principal_components_layer.cpp.
void set_means | ( | const Vector< double > & | new_means | ) |
Sets a new value of the means member.
new_means | Object to be set. |
Definition at line 439 of file principal_components_layer.cpp.
void set_principal_component | ( | const size_t & | index, |
const Vector< double > & | principal_component | ||
) |
Sets a new value of the principal components member.
index | Index of the principal component. |
principal_component | Object to be set. |
Definition at line 428 of file principal_components_layer.cpp.
void set_principal_components | ( | const Matrix< double > & | new_principal_components | ) |
Sets a new value of the principal components member.
new_principal_components | Object to be set. |
Definition at line 390 of file principal_components_layer.cpp.
void set_principal_components_method | ( | const PrincipalComponentsMethod & | new_method | ) |
Sets a new principal components method.
new_method | New principal components method. |
Definition at line 486 of file principal_components_layer.cpp.
void set_principal_components_method | ( | const string & | new_method_string | ) |
Sets a new principal components method.
new_method_string | New principal components method string. |
Definition at line 495 of file principal_components_layer.cpp.
void set_principal_components_number | ( | const size_t & | new_principal_components_number | ) |
Sets a new value for the principal components number member.
new_principal_components_number | New principal components number. |
Definition at line 416 of file principal_components_layer.cpp.
tinyxml2::XMLDocument * to_XML | ( | ) | const |
Serializes the principal components layer object into a XML document of the TinyXML library. See the OpenNN manual for more information about the format of this element.
Definition at line 536 of file principal_components_layer.cpp.
string write_principal_components_expression | ( | const Vector< string > & | inputs_names, |
const Vector< string > & | outputs_names | ||
) | const |
Returns a string with the expression of the principal components process when principal components anlysis is used.
inputs_names | Name of inputs to the principal components. |
outputs_names | Name of outputs from the principal components. |
Definition at line 288 of file principal_components_layer.cpp.
string write_principal_components_method_text | ( | ) | const |
Returns a string with the name of the method used for principal components layer, as paragaph text.
Definition at line 86 of file principal_components_layer.cpp.
void write_XML | ( | tinyxml2::XMLPrinter & | file_stream | ) | const |
Serializes the principal components layer object into a XML document of the TinyXML library without keep the DOM tree in memory. See the OpenNN manual for more information about the format of this document.
Definition at line 608 of file principal_components_layer.cpp.
|
protected |
Contains all the principal components getd in rows and sorted according to their relative explained variance.
Definition at line 161 of file principal_components_layer.h.