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

R2 square. More...

#include <CosanMetric.h>

Inheritance diagram for Cosan::R2Score< NumericType >:
Cosan::CosanMetric< NumericType > Cosan::Evaluation Cosan::CosanBO

Public Member Functions

 R2Score ()
 
 R2Score (const CosanMatrix< NumericType > &yPredict, const CosanMatrix< NumericType > &yTrue)
 
NumericType GetError (const CosanMatrix< NumericType > &yPredict, const CosanMatrix< NumericType > &yTrue) override
 
- Public Member Functions inherited from Cosan::CosanMetric< NumericType >
 CosanMetric ()
 
 CosanMetric (const CosanMatrix< NumericType > &yPredict, const CosanMatrix< NumericType > &yTrue)
 
void setAttr (const CosanMatrix< NumericType > &yPredict, const CosanMatrix< NumericType > &yTrue)
 
- Public Member Functions inherited from Cosan::Evaluation
 Evaluation ()
 
- Public Member Functions inherited from Cosan::CosanBO
 CosanBO ()
 Default constructor. More...
 
virtual const std::string GetName () const
 Get the name of the objects. More...
 

Additional Inherited Members

- Public Attributes inherited from Cosan::CosanMetric< NumericType >
NumericType error
 

Detailed Description

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

R2 square.

https://scikit-learn.org/stable/modules/model_evaluation.html#r2-score-the-coefficient-of-determination

Definition at line 152 of file CosanMetric.h.

Constructor & Destructor Documentation

◆ R2Score() [1/2]

template<Numeric NumericType>
Cosan::R2Score< NumericType >::R2Score ( )
inline

Definition at line 154 of file CosanMetric.h.

154 : CosanMetric<NumericType>() {}

◆ R2Score() [2/2]

template<Numeric NumericType>
Cosan::R2Score< NumericType >::R2Score ( const CosanMatrix< NumericType > &  yPredict,
const CosanMatrix< NumericType > &  yTrue 
)
inline

Definition at line 156 of file CosanMetric.h.

157  : CosanMetric<NumericType>(yPredict, yTrue) {}

Member Function Documentation

◆ GetError()

template<Numeric NumericType>
NumericType Cosan::R2Score< NumericType >::GetError ( const CosanMatrix< NumericType > &  yPredict,
const CosanMatrix< NumericType > &  yTrue 
)
inlineoverridevirtual

Reimplemented from Cosan::CosanMetric< NumericType >.

Definition at line 160 of file CosanMetric.h.

160  {
161  // yTrueMean = Constant(yTrue.rows(), yTrue.cols(). yTrue.mean());
162  this->error = 1 - (yTrue - yPredict).squaredNorm() / (yTrue.array() - yTrue.mean()).matrix().squaredNorm();
163  return this->error;
164  }

The documentation for this class was generated from the following file:
Cosan::CosanMetric::error
NumericType error
Definition: CosanMetric.h:70