STK++ 0.9.13
STK::ProjectedVariance< Array > Class Template Reference

A ProjectedVariance is an implementation of the abstract ILinearReduct interface. More...

#include <STK_ProjectedVariance.h>

Inheritance diagram for STK::ProjectedVariance< Array >:
Inheritance graph

Public Types

typedef ILinearReduct< Array, VectorXBase
 
- Public Types inherited from STK::ILinearReduct< Array, VectorX >
typedef IReducer< Array, VectorXBase
 

Public Member Functions

 ProjectedVariance ()
 default constructor
 
 ProjectedVariance (Array const *p_data)
 Constructor.
 
 ProjectedVariance (Array const &data)
 Constructor.
 
 ProjectedVariance (ProjectedVariance const &reducer)
 Copy constructor.
 
virtual ~ProjectedVariance ()
 Destructor.
 
virtual ProjectedVarianceclone () const
 clone pattern
 
- Public Member Functions inherited from STK::ILinearReduct< Array, VectorX >
 ILinearReduct ()
 Default Constructor.
 
 ILinearReduct (Array const *p_data)
 Constructor.
 
 ILinearReduct (Array const &data)
 Constructor.
 
 ILinearReduct (ILinearReduct const &reducer)
 copy Constructor.
 
virtual ~ILinearReduct ()
 virtual destructor

 
VectorX constcriteriaValues () const
 
Array constaxis () const
 
virtual bool run ()
 Compute the projection matrix axis_ by maximizing the criteria and project the data set in order to obtain p_projected_.
 
virtual bool run (VectorX const &weights)
 Compute the projection matrix set by maximizing the weighted criteria and project the data set in order to obtain p_projected_.
 
- Public Member Functions inherited from STK::IReducer< Array, Weights >
virtual ~IReducer ()
 virtual destructor.
 
int dim () const
 get the number of dimension.
 
Array * p_reduced () const
 get a pointer on the reduced data set
 
void setDimension (const int &dim)
 set the number of dimension.
 
void clear ()
 clear allocated memory
 
- Public Member Functions inherited from STK::IRunnerUnsupervised< Array, Weights >
Array constp_data () const
 get the data set
 
virtual void setData (Array const *p_data)
 Set the data set.
 
virtual void setData (Array const &data)
 Set the data set.
 
- Public Member Functions inherited from STK::IRunnerBase
String consterror () const
 get the last error message.
 

Protected Attributes

ArraySquareX covariance_
 the covariance Array
 
- Protected Attributes inherited from STK::ILinearReduct< Array, VectorX >
VectorX idx_values_
 The values of the index for each axis.
 
Array axis_
 The computed axis.
 
- Protected Attributes inherited from STK::IReducer< Array, Weights >
int dim_
 dimension of the reduced data set
 
Array * p_reduced_
 The reduced data set.
 
- Protected Attributes inherited from STK::IRunnerUnsupervised< Array, Weights >
Array constp_data_
 A pointer on the original data set.
 
- Protected Attributes inherited from STK::IRunnerBase
String msg_error_
 String with the last error message.
 
bool hasRun_
 true if run has been used, false otherwise
 

Private Member Functions

virtual void maximizeStep ()
 Find the axis by maximizing the Index.
 
virtual void maximizeStep (VectorX const &weights)
 Find the axis by maximizing the weighed Index.
 
void computeAxis ()
 compute axis and index.
 
virtual void update ()
 update the class if a new data set is set.
 

Additional Inherited Members

- Public Attributes inherited from STK::ILinearReduct< Array, VectorX >
Array * p_reduced_
 The reduced data set.
 
- Protected Types inherited from STK::IReducer< Array, Weights >
typedef IRunnerUnsupervised< Array, WeightsRunner
 
- Protected Member Functions inherited from STK::IReducer< Array, Weights >
 IReducer ()
 Default constructor.
 
 IReducer (Array const *p_data)
 Constructor with a pointer on the constant data set.
 
 IReducer (Array const &data)
 Constructor with a constant reference on the data set.
 
 IReducer (IReducer const &reducer)
 Copy constructor.
 
- Protected Member Functions inherited from STK::IRunnerUnsupervised< Array, Weights >
 IRunnerUnsupervised ()
 default constructor.
 
 IRunnerUnsupervised (Array const *const p_data)
 constructor with a pointer on the constant data set
 
 IRunnerUnsupervised (Array const &data)
 constructor with a constant reference on the data set
 
 IRunnerUnsupervised (IRunnerUnsupervised const &runner)
 copy constructor
 
 ~IRunnerUnsupervised ()
 destructor
 
- Protected Member Functions inherited from STK::IRunnerBase
 IRunnerBase ()
 default constructor
 
 IRunnerBase (IRunnerBase const &runner)
 copy constructor
 
virtual ~IRunnerBase ()
 destructor
 

Detailed Description

template<class Array>
class STK::ProjectedVariance< Array >

A ProjectedVariance is an implementation of the abstract ILinearReduct interface.

ProjectedVariance (PCA) reduce the dimension of data by maximizing the projected varaince on an affine subspace of dimension d.

Definition at line 50 of file STK_ProjectedVariance.h.

Member Typedef Documentation

◆ Base

template<class Array >
typedef ILinearReduct<Array, VectorX> STK::ProjectedVariance< Array >::Base

Definition at line 53 of file STK_ProjectedVariance.h.

Constructor & Destructor Documentation

◆ ProjectedVariance() [1/4]

template<class Array >
STK::ProjectedVariance< Array >::ProjectedVariance ( )

default constructor

Definition at line 100 of file STK_ProjectedVariance.h.

100: Base() {}
ILinearReduct< Array, VectorX > Base

Referenced by STK::ProjectedVariance< Array >::clone().

◆ ProjectedVariance() [2/4]

template<class Array >
STK::ProjectedVariance< Array >::ProjectedVariance ( Array const p_data)

Constructor.

Parameters
p_dataa pointer on the constant data set to reduce.

Definition at line 105 of file STK_ProjectedVariance.h.

106 : Base(p_data)
107{}
Array const * p_data() const
get the data set

◆ ProjectedVariance() [3/4]

template<class Array >
STK::ProjectedVariance< Array >::ProjectedVariance ( Array const data)

Constructor.

Parameters
dataa constant reference on the data set to reduce.

Definition at line 112 of file STK_ProjectedVariance.h.

113 : Base(data)
114{}

◆ ProjectedVariance() [4/4]

template<class Array >
STK::ProjectedVariance< Array >::ProjectedVariance ( ProjectedVariance< Array > const reducer)

Copy constructor.

Parameters
reducerthe reducer to copy

Definition at line 119 of file STK_ProjectedVariance.h.

120 : Base(reducer)
121{}

◆ ~ProjectedVariance()

template<class Array >
STK::ProjectedVariance< Array >::~ProjectedVariance ( )
virtual

Destructor.

Definition at line 125 of file STK_ProjectedVariance.h.

126{}

Member Function Documentation

◆ clone()

template<class Array >
virtual ProjectedVariance * STK::ProjectedVariance< Array >::clone ( ) const
inlinevirtual

clone pattern

Returns
a pointer on the clone of this

Definition at line 77 of file STK_ProjectedVariance.h.

78 { return new ProjectedVariance(*this);}
ProjectedVariance()
default constructor

References STK::ProjectedVariance< Array >::ProjectedVariance().

◆ computeAxis()

template<class Array >
void STK::ProjectedVariance< Array >::computeAxis ( )
private

compute axis and index.

Definition at line 156 of file STK_ProjectedVariance.h.

157{
158 SymEigen<ArraySquareX> eigen(covariance_);
159 eigen.run();
160
161 // compute the range of the axis
162 Range range(p_data_->beginCols(), std::min(this->dim_, p_data_->sizeCols()));
163 // copy axis and index values
164 axis_.resize(p_data_->cols(), range);
165 idx_values_.resize(range);
166 axis_ = eigen.rotation().col(range);
167 idx_values_ = eigen.eigenValues().sub(range);
168}
SubVector sub(Range const &J) const
Derived & resize(Range const &I, Range const &J)
resize the array.
VectorX idx_values_
The values of the index for each axis.
Array const * p_data_
A pointer on the original data set.
ArraySquareX covariance_
the covariance Array
TRange< UnknownSize > Range
Definition STK_Range.h:59

References STK::IRegression< YArray, XArray, Weights >::run().

◆ maximizeStep() [1/2]

template<class Array >
void STK::ProjectedVariance< Array >::maximizeStep ( )
privatevirtual

Find the axis by maximizing the Index.

Implements STK::ILinearReduct< Array, VectorX >.

Definition at line 130 of file STK_ProjectedVariance.h.

131{
132#ifdef STK_REDUCT_DEBUG
133 if (!p_data_)
135#endif
137 computeAxis();
138}
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:138
Derived & move(Derived const &T)
move T to this.
void computeAxis()
compute axis and index.
virtual void maximizeStep()
Find the axis by maximizing the Index.
Real covariance(ExprBase< XArray > const &X, ExprBase< YArray > const &Y, bool unbiased=false)
Compute the covariance of the variables X and Y.

References STK::Stat::covariance(), STK::ProjectedVariance< Array >::maximizeStep(), and STKRUNTIME_ERROR_NO_ARG.

Referenced by STK::ProjectedVariance< Array >::maximizeStep(), and STK::ProjectedVariance< Array >::maximizeStep().

◆ maximizeStep() [2/2]

template<class Array >
void STK::ProjectedVariance< Array >::maximizeStep ( VectorX const weights)
privatevirtual

Find the axis by maximizing the weighed Index.

Parameters
weightsthe weights of the samples.

Implements STK::ILinearReduct< Array, VectorX >.

Definition at line 144 of file STK_ProjectedVariance.h.

145{
146#ifdef STK_REDUCT_DEBUG
147 if (!p_data_)
149#endif
150 covariance_.move(Stat::covariance(*p_data_, weights, true));
151 computeAxis();
152}

References STK::Stat::covariance(), STK::ProjectedVariance< Array >::maximizeStep(), and STKRUNTIME_ERROR_NO_ARG.

◆ update()

template<class Array >
void STK::ProjectedVariance< Array >::update ( )
privatevirtual

update the class if a new data set is set.

Reimplemented from STK::IRunnerBase.

Definition at line 172 of file STK_ProjectedVariance.h.

173{
175}
void clear()
clear the object.

Member Data Documentation

◆ covariance_

template<class Array >
ArraySquareX STK::ProjectedVariance< Array >::covariance_
protected

the covariance Array

Definition at line 82 of file STK_ProjectedVariance.h.


The documentation for this class was generated from the following file: