STK++ 0.9.13
STK::ILinearReduct< Array, Weights > Class Template Referenceabstract

A ILinearReduct is an interface base class for reduction method using linear reduction. More...

#include <STK_ILinearReduct.h>

Inheritance diagram for STK::ILinearReduct< Array, Weights >:
Inheritance graph

Public Types

typedef IReducer< Array, WeightsBase
 

Public Member Functions

 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 (Weights 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.
 

Public Attributes

Array * p_reduced_
 The reduced data set.
 

Protected Attributes

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 ()=0
 Find the axis by maximizing the Index.
 
virtual void maximizeStep (Weights const &weights)=0
 Find the axis by maximizing the weighted Index.
 
void projectionStep ()
 Compute the projection of the data set on the Axis.
 

Additional Inherited Members

- 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
 
virtual void update ()
 update the runner.
 

Detailed Description

template<class Array, class Weights>
class STK::ILinearReduct< Array, Weights >

A ILinearReduct is an interface base class for reduction method using linear reduction.

In order to find the linear reduction, the derived classes maximize an index.

The class computes the optimal axis (stored in the axis_ ) attribute and the projected data set (stored in the p_reduct_ attribute of the base class IReducer) when user uses the virtual method run() (for not weighted observations) or run(weights) (for weighted observations).

The Array axis_ is computed by maximizing some criteria defined in derived classes. It is constructed using the pure virtual functions:

virtual void maximizeStep() =0;
virtual void maximizeStep(weights) =0;
virtual void maximizeStep()=0
Find the axis by maximizing the Index.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...

Definition at line 63 of file STK_ILinearReduct.h.

Member Typedef Documentation

◆ Base

template<class Array , class Weights >
typedef IReducer<Array, Weights> STK::ILinearReduct< Array, Weights >::Base

Definition at line 66 of file STK_ILinearReduct.h.

Constructor & Destructor Documentation

◆ ILinearReduct() [1/4]

template<class Array , class Weights >
STK::ILinearReduct< Array, Weights >::ILinearReduct ( )

Default Constructor.

Definition at line 121 of file STK_ILinearReduct.h.

121: Base() {}
IReducer< Array, Weights > Base

◆ ILinearReduct() [2/4]

template<class Array , class Weights >
STK::ILinearReduct< Array, Weights >::ILinearReduct ( Array const p_data)

Constructor.

Parameters
p_dataa pointer on the constant data set to reduce.

Definition at line 128 of file STK_ILinearReduct.h.

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

◆ ILinearReduct() [3/4]

template<class Array , class Weights >
STK::ILinearReduct< Array, Weights >::ILinearReduct ( Array const data)

Constructor.

Parameters
dataa constant reference on the data set to reduce.

Definition at line 134 of file STK_ILinearReduct.h.

134: Base(data) {}

◆ ILinearReduct() [4/4]

template<class Array , class Weights >
STK::ILinearReduct< Array, Weights >::ILinearReduct ( ILinearReduct< Array, Weights > const reducer)

copy Constructor.

Parameters
reducerthe reducer to copy.

Definition at line 139 of file STK_ILinearReduct.h.

140 : Base(reducer)
141 , idx_values_(reducer.idx_values_)
142 , axis_(reducer.axis_)
143{}
Array axis_
The computed axis.
VectorX idx_values_
The values of the index for each axis.

◆ ~ILinearReduct()

template<class Array , class Weights >
STK::ILinearReduct< Array, Weights >::~ILinearReduct ( )
virtual

virtual destructor

Definition at line 146 of file STK_ILinearReduct.h.

146{}

Member Function Documentation

◆ axis()

template<class Array , class Weights >
Array const & STK::ILinearReduct< Array, Weights >::axis ( ) const
inline
Returns
a constant reference Array of the axis

Definition at line 88 of file STK_ILinearReduct.h.

88{ return axis_; }

References STK::ILinearReduct< Array, Weights >::axis_.

◆ criteriaValues()

template<class Array , class Weights >
VectorX const & STK::ILinearReduct< Array, Weights >::criteriaValues ( ) const
inline
Returns
a constant reference Vector of the value of the Index

Definition at line 86 of file STK_ILinearReduct.h.

86{ return idx_values_; }

References STK::ILinearReduct< Array, Weights >::idx_values_.

◆ maximizeStep() [1/2]

template<class Array , class Weights >
virtual void STK::ILinearReduct< Array, Weights >::maximizeStep ( )
privatepure virtual

Find the axis by maximizing the Index.

Implemented in STK::LocalVariance< Array >, and STK::ProjectedVariance< Array >.

◆ maximizeStep() [2/2]

template<class Array , class Weights >
virtual void STK::ILinearReduct< Array, Weights >::maximizeStep ( Weights const weights)
privatepure virtual

Find the axis by maximizing the weighted Index.

Parameters
weightsthe weights to used

Implemented in STK::LocalVariance< Array >, and STK::ProjectedVariance< Array >.

◆ projectionStep()

template<class Array , class Weights >
void STK::ILinearReduct< Array, Weights >::projectionStep ( )
private

Compute the projection of the data set on the Axis.

Definition at line 202 of file STK_ILinearReduct.h.

203{
204 // check if p_reduced exists
205 if (!p_reduced_) p_reduced_ = new Array;
206 // compute matrix multiplication
207 *p_reduced_ = (*p_data_) * axis_;
208}
Array * p_reduced_
The reduced data set.

◆ run() [1/2]

template<class Array , class Weights >
bool STK::ILinearReduct< Array, Weights >::run ( )
virtual

Compute the projection matrix axis_ by maximizing the criteria and project the data set in order to obtain p_projected_.

Implements STK::IRunnerUnsupervised< Array, Weights >.

Definition at line 152 of file STK_ILinearReduct.h.

153{
154 if (!this->p_data_)
155 { this->msg_error_ = STKERROR_NO_ARG(MultivariateArray::run(),data is not set);
156 return false;
157 }
158 try
159 {
160 // maximize the Index and compute the axis
161 maximizeStep();
162 // project data
164
165 } catch (Exception const& e)
166 {
167 this->msg_error_ = e.error();
168 return false;
169 }
170 return true;
171}
#define STKERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:49
void projectionStep()
Compute the projection of the data set on the Axis.
String msg_error_
String with the last error message.
Definition STK_IRunner.h:96
Array const * p_data_
A pointer on the original data set.

References STK::Exception::error(), STK::IRunnerBase::msg_error_, and STKERROR_NO_ARG.

◆ run() [2/2]

template<class Array , class Weights >
bool STK::ILinearReduct< Array, Weights >::run ( Weights const weights)
virtual

Compute the projection matrix set by maximizing the weighted criteria and project the data set in order to obtain p_projected_.

Parameters
weightsthe weights to used in the index.

Implements STK::IRunnerUnsupervised< Array, Weights >.

Definition at line 179 of file STK_ILinearReduct.h.

180{
181 if (!this->p_data_)
182 { this->msg_error_ = STKERROR_NO_ARG(MultivariateArray::run(),data is not set);
183 return false;
184 }
185 try
186 {
187 // maximize the Index and compute the axis
188 maximizeStep(weights);
189 // project data
191
192 } catch (Exception const& e)
193 {
194 this->msg_error_ = e.error();
195 return false;
196 }
197 return true;
198}

References STK::Exception::error(), STK::IRunnerBase::msg_error_, and STKERROR_NO_ARG.

Member Data Documentation

◆ axis_

template<class Array , class Weights >
Array STK::ILinearReduct< Array, Weights >::axis_
protected

The computed axis.

Definition at line 103 of file STK_ILinearReduct.h.

Referenced by STK::ILinearReduct< Array, Weights >::axis().

◆ idx_values_

template<class Array , class Weights >
VectorX STK::ILinearReduct< Array, Weights >::idx_values_
protected

The values of the index for each axis.

Definition at line 101 of file STK_ILinearReduct.h.

Referenced by STK::ILinearReduct< Array, Weights >::criteriaValues().

◆ p_reduced_

template<class Array , class Weights >
Array* STK::IReducer< Array, Weights >::p_reduced_

The reduced data set.

Definition at line 101 of file STK_IReducer.h.


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