Cosan  1.0
Data Analytics Library
Cosan::CosanPrincipalComponentRegression< NumericType > Class Template Reference

#include <CosanPrincipalComponentRegression.h>

Inheritance diagram for Cosan::CosanPrincipalComponentRegression< NumericType >:
Cosan::CosanLinearModel< NumericType > Cosan::CosanModel Cosan::CosanBO Cosan::CosanPCRRidge< NumericType >

Public Member Functions

 CosanPrincipalComponentRegression ()
 
 CosanPrincipalComponentRegression (NumericType ncomp, bool bias=false)
 
 CosanPrincipalComponentRegression (CosanRawData< NumericType > &RD, NumericType ncomp, bool bias=false)
 
 CosanPrincipalComponentRegression (CosanData< NumericType > &CD, NumericType ncomp, bool bias=false)
 
template<class T , std::enable_if_t< std::is_same_v< std::decay_t< T >, CosanMatrix< NumericType >>, bool > = true>
 CosanPrincipalComponentRegression (T &&X, const CosanMatrix< NumericType > &Y, NumericType ncomp, bool bias=false)
 
virtual EModelType GetModelType () override
 
virtual EProblemType GetProblemType ()
 
virtual const std::string GetName () const override
 Get the name of the objects. More...
 
template<class T , std::enable_if_t< std::is_same_v< std::decay_t< T >, CosanMatrix< NumericType >>, bool > = true>
void fit (T &&X, const CosanMatrix< NumericType > &Y)
 
virtual CosanMatrix< NumericTypepredict (const CosanMatrix< NumericType > &X) override
 
CosanMatrix< NumericType > & GetPC ()
 
void SetParams (NumericType ncomp)
 
NumericType GetParams ()
 
- Public Member Functions inherited from Cosan::CosanLinearModel< NumericType >
 CosanLinearModel ()=delete
 
 CosanLinearModel (bool Bias)
 
void SetBias (const bool NewBias)
 
virtual void SetBeta (CosanMatrix< NumericType > InitBeta)
 
const CosanMatrix< NumericType > & GetBeta () const
 
bool GetBias () const
 
- Public Member Functions inherited from Cosan::CosanModel
 CosanModel ()
 
virtual void SetMaxTrainTime (double t)
 
virtual double GetMaxTrainTime () const
 
virtual ESolverType GetSolverType () const
 
void SetSolverType (ESolverType sr)
 
- Public Member Functions inherited from Cosan::CosanBO
 CosanBO ()
 Default constructor. More...
 

Protected Attributes

NumericType __ncomp
 
CosanMatrix< NumericTypePC
 
CosanMatrix< NumericTypeDerivatedCovariate
 
- Protected Attributes inherited from Cosan::CosanLinearModel< NumericType >
CosanMatrix< NumericTypeMBeta
 
bool MBias
 
- Protected Attributes inherited from Cosan::CosanModel
double MaxTrainTime
 
ESolverType SolverType
 

Detailed Description

template<Numeric NumericType>
class Cosan::CosanPrincipalComponentRegression< NumericType >

Template Parameters
NumericTypehttps://en.wikipedia.org/wiki/Principal_component_regression

Definition at line 20 of file CosanPrincipalComponentRegression.h.

Constructor & Destructor Documentation

◆ CosanPrincipalComponentRegression() [1/5]

Definition at line 24 of file CosanPrincipalComponentRegression.h.

24  : CosanLinearModel<NumericType>(false){
25  __ncomp = 3;}

◆ CosanPrincipalComponentRegression() [2/5]

template<Numeric NumericType>
Cosan::CosanPrincipalComponentRegression< NumericType >::CosanPrincipalComponentRegression ( NumericType  ncomp,
bool  bias = false 
)
inline

Definition at line 26 of file CosanPrincipalComponentRegression.h.

26  : CosanLinearModel<NumericType>(false){
27  __ncomp = ncomp;}

◆ CosanPrincipalComponentRegression() [3/5]

template<Numeric NumericType>
Cosan::CosanPrincipalComponentRegression< NumericType >::CosanPrincipalComponentRegression ( CosanRawData< NumericType > &  RD,
NumericType  ncomp,
bool  bias = false 
)
inline

Definition at line 28 of file CosanPrincipalComponentRegression.h.

28  : CosanLinearModel<NumericType>(bias=false){
29  __ncomp = ncomp;
30  fit(RD.GetInput(),RD.GetTarget());
31  }

◆ CosanPrincipalComponentRegression() [4/5]

template<Numeric NumericType>
Cosan::CosanPrincipalComponentRegression< NumericType >::CosanPrincipalComponentRegression ( CosanData< NumericType > &  CD,
NumericType  ncomp,
bool  bias = false 
)
inline

Definition at line 32 of file CosanPrincipalComponentRegression.h.

32  : CosanLinearModel<NumericType>(bias=false){
33  __ncomp = ncomp;
34  fit(CD.GetInput(),CD.GetTarget());
35  }

◆ CosanPrincipalComponentRegression() [5/5]

template<Numeric NumericType>
template<class T , std::enable_if_t< std::is_same_v< std::decay_t< T >, CosanMatrix< NumericType >>, bool > = true>
Cosan::CosanPrincipalComponentRegression< NumericType >::CosanPrincipalComponentRegression ( T &&  X,
const CosanMatrix< NumericType > &  Y,
NumericType  ncomp,
bool  bias = false 
)
inline

Definition at line 39 of file CosanPrincipalComponentRegression.h.

39  : CosanLinearModel<NumericType>(false){
40  __ncomp = ncomp;
41  PC = PrincipalComponentAnalysis(X,(gsl::index) ncomp).GetPC();
43  this->MBeta = (DerivatedCovariate.transpose()*DerivatedCovariate).ldlt().solve(DerivatedCovariate.transpose()*Y);
44  }

Member Function Documentation

◆ fit()

template<Numeric NumericType>
template<class T , std::enable_if_t< std::is_same_v< std::decay_t< T >, CosanMatrix< NumericType >>, bool > = true>
void Cosan::CosanPrincipalComponentRegression< NumericType >::fit ( T &&  X,
const CosanMatrix< NumericType > &  Y 
)
inline

Definition at line 57 of file CosanPrincipalComponentRegression.h.

57  {
58  PC = PrincipalComponentAnalysis(X,__ncomp).GetPC();
60  this->MBeta = (DerivatedCovariate.transpose()*DerivatedCovariate).ldlt().solve(DerivatedCovariate.transpose()*Y);
61  }

◆ GetModelType()

template<Numeric NumericType>
virtual EModelType Cosan::CosanPrincipalComponentRegression< NumericType >::GetModelType ( )
inlineoverridevirtual

Reimplemented from Cosan::CosanModel.

Reimplemented in Cosan::CosanPCRRidge< NumericType >.

Definition at line 46 of file CosanPrincipalComponentRegression.h.

46  {
48  };

◆ GetName()

template<Numeric NumericType>
virtual const std::string Cosan::CosanPrincipalComponentRegression< NumericType >::GetName ( ) const
inlineoverridevirtual

Get the name of the objects.

Description: Get the name of the object. It should return "Abstract Object"

Reimplemented from Cosan::CosanLinearModel< NumericType >.

Reimplemented in Cosan::CosanPCRRidge< NumericType >.

Definition at line 52 of file CosanPrincipalComponentRegression.h.

52  {
53  return "Principal Component Regression with least square";}

◆ GetParams()

template<Numeric NumericType>
NumericType Cosan::CosanPrincipalComponentRegression< NumericType >::GetParams ( )
inline

Definition at line 69 of file CosanPrincipalComponentRegression.h.

69 {return __ncomp;}

◆ GetPC()

template<Numeric NumericType>
CosanMatrix<NumericType>& Cosan::CosanPrincipalComponentRegression< NumericType >::GetPC ( )
inline

Definition at line 66 of file CosanPrincipalComponentRegression.h.

66 {return PC;}

◆ GetProblemType()

template<Numeric NumericType>
virtual EProblemType Cosan::CosanPrincipalComponentRegression< NumericType >::GetProblemType ( )
inlinevirtual

Reimplemented from Cosan::CosanModel.

Reimplemented in Cosan::CosanPCRRidge< NumericType >.

Definition at line 50 of file CosanPrincipalComponentRegression.h.

50  {
51  return PdUnivariateRegression;}

◆ predict()

template<Numeric NumericType>
virtual CosanMatrix<NumericType> Cosan::CosanPrincipalComponentRegression< NumericType >::predict ( const CosanMatrix< NumericType > &  X)
inlineoverridevirtual

Implements Cosan::CosanLinearModel< NumericType >.

Definition at line 63 of file CosanPrincipalComponentRegression.h.

63  {
64  return X*PC*(this->MBeta);
65  }

◆ SetParams()

template<Numeric NumericType>
void Cosan::CosanPrincipalComponentRegression< NumericType >::SetParams ( NumericType  ncomp)
inline

Definition at line 68 of file CosanPrincipalComponentRegression.h.

68 {__ncomp = ncomp; };

Member Data Documentation

◆ __ncomp

template<Numeric NumericType>
NumericType Cosan::CosanPrincipalComponentRegression< NumericType >::__ncomp
protected

Definition at line 72 of file CosanPrincipalComponentRegression.h.

◆ DerivatedCovariate

template<Numeric NumericType>
CosanMatrix<NumericType> Cosan::CosanPrincipalComponentRegression< NumericType >::DerivatedCovariate
protected

Definition at line 74 of file CosanPrincipalComponentRegression.h.

◆ PC

template<Numeric NumericType>
CosanMatrix<NumericType> Cosan::CosanPrincipalComponentRegression< NumericType >::PC
protected

Definition at line 73 of file CosanPrincipalComponentRegression.h.


The documentation for this class was generated from the following file:
Cosan::CosanLinearModel::MBeta
CosanMatrix< NumericType > MBeta
Definition: CosanLinearModel.h:56
Cosan::CosanPrincipalComponentRegression::__ncomp
NumericType __ncomp
Definition: CosanPrincipalComponentRegression.h:72
Cosan::CosanPrincipalComponentRegression::PC
CosanMatrix< NumericType > PC
Definition: CosanPrincipalComponentRegression.h:73
Cosan::CosanPrincipalComponentRegression::fit
void fit(T &&X, const CosanMatrix< NumericType > &Y)
Definition: CosanPrincipalComponentRegression.h:57
Cosan::PdUnivariateRegression
@ PdUnivariateRegression
Definition: CosanModel.h:16
Cosan::CosanPrincipalComponentRegression::DerivatedCovariate
CosanMatrix< NumericType > DerivatedCovariate
Definition: CosanPrincipalComponentRegression.h:74
Cosan::MdPrincipalComponentRegression
@ MdPrincipalComponentRegression
Definition: CosanModel.h:25