STK++ 0.9.13
STK::IClassification< YArray_, XArray_, Weights_ > Class Template Referenceabstract

Interface base class for Regression methods. More...

#include <STK_IClassification.h>

Inheritance diagram for STK::IClassification< YArray_, XArray_, Weights_ >:
Inheritance graph

Public Member Functions

virtual ~IClassification ()
 virtual destructor.
 
int nbClass () const
 
int nbFreeParameter () const
 
virtual bool run ()
 run the computations.
 
virtual bool run (Weights_ const &weights)
 run the weighted computations.
 
- Public Member Functions inherited from STK::IRunnerSupervised< YArray_, XArray_, Weights_ >
virtual void setX (XArray_ const &x)
 set the x data set (predictors).
 
virtual void setY (YArray_ const &y)
 set the data set.
 
virtual void setData (YArray_ const &y, XArray_ const &x)
 set the data set.
 
- Public Member Functions inherited from STK::IRunnerBase
String consterror () const
 get the last error message.
 

Protected Types

typedef IRunnerSupervised< YArray_, XArray_, Weights_Base
 

Protected Member Functions

 IClassification ()
 Default constructor.
 
 IClassification (YArray_ const *p_y, XArray_ const *p_x)
 Constructor.
 
 IClassification (YArray_ const &y, XArray_ const &x)
 Constructor.
 
virtual bool initializeStep ()
 perform any computation needed before the call of the classification method.
 
virtual bool predictionStep ()
 Compute the predicted outputs by the classification function and store the result in the p_predicted_ array.
 
virtual bool finalizeStep ()
 perform any computation needed after the call of the classification method.
 
- Protected Member Functions inherited from STK::IRunnerSupervised< YArray_, XArray_, Weights_ >
 IRunnerSupervised ()
 default constructor
 
 IRunnerSupervised (YArray_ const *const &p_y, XArray_ const *const &p_x)
 constructor
 
 IRunnerSupervised (YArray_ const &y, XArray_ const &x)
 default constructor
 
 IRunnerSupervised (IRunnerSupervised const &runner)
 copy constructor
 
 ~IRunnerSupervised ()
 destructor
 
virtual void updateY ()
 update the runner when y data set is set.
 
virtual void updateX ()
 update the runner when x data set is set.
 
virtual void update ()
 update the runner.
 
- Protected Member Functions inherited from STK::IRunnerBase
 IRunnerBase ()
 default constructor
 
 IRunnerBase (IRunnerBase const &runner)
 copy constructor
 
virtual ~IRunnerBase ()
 destructor
 

Protected Attributes

int nbClass_
 number of class
 
int nbFreeParameter_
 number of parameter of the classification method.
 
XArray_ constp_x_
 A pointer on the x data set.
 
YArray_ constp_y_
 A pointer on the y data set.
 
- Protected Attributes inherited from STK::IRunnerSupervised< YArray_, XArray_, Weights_ >
YArray_ constp_y_
 A pointer on the y data set.
 
XArray_ constp_x_
 A pointer on the x 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 bool estimationStep ()=0
 compute the classification function.
 
virtual bool estimationStep (Weights_ const &weights)=0
 compute the weighted classification function.
 
virtual int computeNbFreeParameter () const =0
 Compute the number of parameter of the classification function.
 

Detailed Description

template<class YArray_, class XArray_, class Weights_>
class STK::IClassification< YArray_, XArray_, Weights_ >

Interface base class for Regression methods.

In machine learning and statistics, classification is the problem of identifying to which of a set of categories (sub-populations) a new observation belongs, on the basis of a training set of data containing observations (or instances) whose category membership is known. An example would be assigning a given email into "spam" or "non-spam" classes or assigning a diagnosis to a given patient as described by observed characteristics of the patient (gender, blood pressure, presence or absence of certain symptoms, etc.). Classification is an example of pattern recognition.

In the terminology of machine learning, classification is considered an instance of supervised learning, i.e. learning where a training set of correctly identified observations is available. The corresponding unsupervised procedure is known as clustering, and involves grouping data into categories based on some measure of inherent similarity or distance.

Often, the individual observations are analyzed into a set of quantifiable properties, known variously as explanatory variables or features. These properties may variously be categorical (e.g. "A", "B", "AB" or "O", for blood type), ordinal (e.g. "large", "medium" or "small"), integer-valued (e.g. the number of occurrences of a particular word in an email) or real-valued (e.g. a measurement of blood pressure). Other classifiers work by comparing observations to previous observations by means of a similarity or distance function.

An algorithm that implements classification, especially in a concrete implementation, is known as a classifier. The term "classifier" sometimes also refers to the mathematical function, implemented by a classification algorithm, that maps input data to a category.

In this interface, the pure virtual function to implement are

virtual bool estimationStep() =0;
virtual bool estimationStep( Weights_ const& weights) =0;
virtual bool predictionStep() =0;
virtual int computeNbFreeParameter() const =0;
virtual YArray_ extrapolate(XArray_ const& x) const =0;
virtual bool predictionStep()
Compute the predicted outputs by the classification function and store the result in the p_predicted_...
virtual int computeNbFreeParameter() const =0
Compute the number of parameter of the classification function.
virtual bool estimationStep()=0
compute the classification function.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...

The virtual function

virtual void initializeStep();
virtual bool initializeStep()
perform any computation needed before the call of the classification method.

can be overloaded.

The default behavior of the run methods is

if (!initializeStep()) { flag = false;}
if (!estimationStep()) { flag = false;}
if (!finalizeStep()) { flag = false;}
if (!predictionStep()) { flag = false;}
virtual bool finalizeStep()
perform any computation needed after the call of the classification method.
int nbFreeParameter_
number of parameter of the classification method.

and it can be overloaded in derived class.

Definition at line 103 of file STK_IClassification.h.

Member Typedef Documentation

◆ Base

Constructor & Destructor Documentation

◆ IClassification() [1/3]

STK::IClassification< YArray_, XArray_, Weights_ >::IClassification ( )
protected

Default constructor.

Initialize the data members.

Definition at line 214 of file STK_IClassification.h.

214: Base(), nbClass_(0), nbFreeParameter_(0) {}
IRunnerSupervised< YArray_, XArray_, Weights_ > Base
int nbClass_
number of class

◆ IClassification() [2/3]

STK::IClassification< YArray_, XArray_, Weights_ >::IClassification ( YArray_ const p_y,
XArray_ const p_x 
)
protected

Constructor.

Initialize the data members.

Parameters
p_y,p_xpointer array with the observed output and output

Definition at line 220 of file STK_IClassification.h.

221 : Base(p_y, p_x)
222 , nbClass_(0)
224{}

◆ IClassification() [3/3]

STK::IClassification< YArray_, XArray_, Weights_ >::IClassification ( YArray_ const y,
XArray_ const x 
)
protected

Constructor.

Initialize the data members.

Parameters
y,xarrays with the observed output and input

Definition at line 230 of file STK_IClassification.h.

231 : Base(y, x)
232 , nbClass_(0)
234{}

◆ ~IClassification()

virtual destructor.

Definition at line 122 of file STK_IClassification.h.

122{}

Member Function Documentation

◆ computeNbFreeParameter()

virtual int STK::IClassification< YArray_, XArray_, Weights_ >::computeNbFreeParameter ( ) const
privatepure virtual

Compute the number of parameter of the classification function.

Returns
the number of parameter of the classification function

Referenced by STK::IClassification< YArray_, XArray_, Weights_ >::run(), and STK::IClassification< YArray_, XArray_, Weights_ >::run().

◆ estimationStep() [1/2]

◆ estimationStep() [2/2]

virtual bool STK::IClassification< YArray_, XArray_, Weights_ >::estimationStep ( Weights_ const weights)
privatepure virtual

compute the weighted classification function.

Parameters
weightsthe weights of the samples

◆ finalizeStep()

virtual bool STK::IClassification< YArray_, XArray_, Weights_ >::finalizeStep ( )
inlineprotectedvirtual

perform any computation needed after the call of the classification method.

Default implementation is do nothing.

Definition at line 197 of file STK_IClassification.h.

197{return true;}

Referenced by STK::IClassification< YArray_, XArray_, Weights_ >::run(), and STK::IClassification< YArray_, XArray_, Weights_ >::run().

◆ initializeStep()

virtual bool STK::IClassification< YArray_, XArray_, Weights_ >::initializeStep ( )
inlineprotectedvirtual

perform any computation needed before the call of the classification method.

Default implementation is do nothing.

Definition at line 189 of file STK_IClassification.h.

189{return true;}

Referenced by STK::IClassification< YArray_, XArray_, Weights_ >::run(), and STK::IClassification< YArray_, XArray_, Weights_ >::run().

◆ nbClass()

int STK::IClassification< YArray_, XArray_, Weights_ >::nbClass ( ) const
inline
Returns
number of class

Definition at line 125 of file STK_IClassification.h.

125{ return nbClass_;}

References STK::IClassification< YArray_, XArray_, Weights_ >::nbClass_.

◆ nbFreeParameter()

int STK::IClassification< YArray_, XArray_, Weights_ >::nbFreeParameter ( ) const
inline
Returns
number of parameters of the classification function

Definition at line 127 of file STK_IClassification.h.

127{ return nbFreeParameter_;}

References STK::IClassification< YArray_, XArray_, Weights_ >::nbFreeParameter_.

◆ predictionStep()

virtual bool STK::IClassification< YArray_, XArray_, Weights_ >::predictionStep ( )
inlineprotectedvirtual

Compute the predicted outputs by the classification function and store the result in the p_predicted_ array.

Default implementation is do nothing.

Definition at line 193 of file STK_IClassification.h.

193{return true;};

Referenced by STK::IClassification< YArray_, XArray_, Weights_ >::run(), and STK::IClassification< YArray_, XArray_, Weights_ >::run().

◆ run() [1/2]

run the computations.

Default Implementation.

Implements STK::IRunnerSupervised< YArray_, XArray_, Weights_ >.

Definition at line 130 of file STK_IClassification.h.

131 {
132 if (!p_x_ || !p_y_)
133 { this->msg_error_ = STKERROR_NO_ARG(IClassification::run,missing data sets);
134 return false;
135 }
136 bool flag=true;
137 // perform any initialization step needed before the classification step
138 if (!initializeStep()) { flag = false;}
139 // compute the classification
140 if (!estimationStep()) { flag = false;}
141
142 // perform any post-operation needed after the classification step
143 if (!finalizeStep()) { flag = false;}
144 // Compute the number of parameter of the classification function.
146 // create array of the predicted value and compute prediction
147 if (!predictionStep()) { flag = false;}
148 // return the result of the computations
149 this->hasRun_ = true;
150 return flag;
151 }
#define STKERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:49
virtual bool run()
run the computations.
YArray_ const * p_y_
A pointer on the y data set.
XArray_ const * p_x_
A pointer on the x data set.
String msg_error_
String with the last error message.
Definition STK_IRunner.h:96
bool hasRun_
true if run has been used, false otherwise
Definition STK_IRunner.h:98

References STK::IClassification< YArray_, XArray_, Weights_ >::computeNbFreeParameter(), STK::IClassification< YArray_, XArray_, Weights_ >::estimationStep(), STK::IClassification< YArray_, XArray_, Weights_ >::finalizeStep(), STK::IRunnerBase::hasRun_, STK::IClassification< YArray_, XArray_, Weights_ >::initializeStep(), STK::IRunnerBase::msg_error_, STK::IClassification< YArray_, XArray_, Weights_ >::nbFreeParameter_, STK::IClassification< YArray_, XArray_, Weights_ >::p_x_, STK::IClassification< YArray_, XArray_, Weights_ >::p_y_, STK::IClassification< YArray_, XArray_, Weights_ >::predictionStep(), STK::IClassification< YArray_, XArray_, Weights_ >::run(), and STKERROR_NO_ARG.

Referenced by STK::IClassification< YArray_, XArray_, Weights_ >::run(), and STK::IClassification< YArray_, XArray_, Weights_ >::run().

◆ run() [2/2]

virtual bool STK::IClassification< YArray_, XArray_, Weights_ >::run ( Weights_ const weights)
inlinevirtual

run the weighted computations.

Parameters
weightsweights of the samples

Implements STK::IRunnerSupervised< YArray_, XArray_, Weights_ >.

Definition at line 155 of file STK_IClassification.h.

156 {
157
158 if (!p_x_ || !p_y_)
159 { this->msg_error_ = STKERROR_NO_ARG(IClassification::run,missing data sets);
160 return false;
161 }
162 bool flag=true;
163 // perform any pre-operation needed before the classification step
164 if (!initializeStep()) { flag = false;}
165 // compute weighted classification
166 if (!estimationStep(weights)) { flag = false;}
167
168 // perform any post-operation needed after the classification step
169 if (!finalizeStep()) { flag = false;}
170 // Compute the number of parameter of the classification function.
172 // create array of the predicted value and compute prediction
173 if (!predictionStep()) { flag = false;}
174
175 // return the result of the computations
176 this->hasRun_ = true;
177 return flag;
178 }

References STK::IClassification< YArray_, XArray_, Weights_ >::computeNbFreeParameter(), STK::IClassification< YArray_, XArray_, Weights_ >::estimationStep(), STK::IClassification< YArray_, XArray_, Weights_ >::finalizeStep(), STK::IRunnerBase::hasRun_, STK::IClassification< YArray_, XArray_, Weights_ >::initializeStep(), STK::IRunnerBase::msg_error_, STK::IClassification< YArray_, XArray_, Weights_ >::nbFreeParameter_, STK::IClassification< YArray_, XArray_, Weights_ >::p_x_, STK::IClassification< YArray_, XArray_, Weights_ >::p_y_, STK::IClassification< YArray_, XArray_, Weights_ >::predictionStep(), STK::IClassification< YArray_, XArray_, Weights_ >::run(), and STKERROR_NO_ARG.

Member Data Documentation

◆ nbClass_

number of class

Definition at line 182 of file STK_IClassification.h.

Referenced by STK::IClassification< YArray_, XArray_, Weights_ >::nbClass().

◆ nbFreeParameter_

◆ p_x_

◆ p_y_


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