35#ifndef STK_STAT_FACTOR_H
36#define STK_STAT_FACTOR_H
60 typedef typename Array::Type
Type;
72 Factor( Array
const& data);
128template <
class Array>
130 , levels_(), counts_(), encoder_() {}
132template <
class Array>
134 , asInteger_(p_data_->range())
146template <
class Array>
163template <
class Array>
165 , firstLevel_(
f.firstLevel_), nbLevels_(
f.nbLevels_)
166 , levels_(
f.levels_), counts_(
f.counts_)
167 , encoder_(
f.encoder_)
168 , decoder_(
f.decoder_)
171template <
class Array>
177 asInteger_.resize(p_data_->rows());
187template <
class Array>
196 for (
int i=p_data_->begin();
i< p_data_->end(); ++
i)
199 Type idData = p_data_->elt(
i);
200 typename EncodingMap::const_iterator
it = encoder_.find(idData);
201 if (
it != encoder_.end())
202 { asInteger_[
i] =
it->second;
203 counts_[
it->second]++;
208 int lev = firstLevel_ + nbLevels_;
210 encoder_.insert(std::pair<Type, int>(idData,
lev));
211 decoder_.insert(std::pair<int, Type>(
lev, idData));
212 levels_.push_back(idData);
213 counts_.push_back(1);
220 this->msg_error_ +=
_T(
"Error in Factor::run():\nWhat: ");
221 this->msg_error_ += error.
error();
#define STKERROR_NO_ARG(Where, Error)
#define _T(x)
Let x unmodified.
This file include all the other header files of the project Sdk.
Sdk class for all library Exceptions.
virtual const String error() const
Returns a C-style character string describing the general cause of the current error.
Derived & resize(Range const &I, Range const &J)
resize the Array.
Abstract class for all running class based on a data set.
Array const * p_data_
A pointer on the original data set.
Array const * p_data() const
get the data set
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Computation of the Factors of a 1D Container.
virtual Factor * clone() const
clone pattern
std::map< Type, int > EncodingMap
virtual bool run()
run the estimation of the Factor statistics.
DecodingMap const & decoder() const
int const & firstLevel() const
EncodingMap const & encoder() const
void setFirstLevel(int firstLevel)
set the value of the first level
virtual void update()
udpating method in case we set a new data set
int nbLevels_
Number of levels of each variables.
CVectorXi asInteger_
vector with the levels in an integer format
Factor()
Default Constructor.
VectorXi counts_
Array with the counts of each factor.
VectorXi const & counts() const
DecodingMap decoder_
decoder of the levels
IRunnerWithData< Array > Base
EncodingMap encoder_
encoder of the levels
Array const * p_data_
A pointer on the original data set.
int const & nbLevels() const
CVectorXi const & asInteger() const
Array2DVector< Type > levels_
vector with the levels
Array2DVector< Type > const & levels() const
int firstLevel_
first level
hidden::Traits< Array >::Col ColVector
std::map< int, Type > DecodingMap
hidden::Traits< Array >::Row RowVector
virtual ~Factor()
virtual destructor.
const int baseIdx
base index of the containers created in STK++.
The namespace STK is the main domain space of the Statistical ToolKit project.