//------------------------------------------------------------------------------
// module prediction.h //
// //
// The class TPrediction predicts the unknown output value given the //
// input based on the model learned with the PNC cluster/learn algorithm. //
// The class TCluster encapsulates such a model. //
// See source or http://www.newty.de/pnc2/sdocu.html for more information. //
// //
// copyright (c) 2000-2003 by Lars Haendel //
// home: www.newty.de //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 2 of the License. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //
// //
//------------------------------------------------------------------------------
#ifndef PRD_MTHD_H
#define PRD_MTHD_H
//----------------------------------------------------------------------------------------------------------------------
#include "lossfunc.h" // due to TLossFunction
#include "data.h" // TData
#include "para.h" // TParameter
#include "cluster.h" // TCluster
//----------------------------------------------------------------------------------------------------------------------
// The class TPrediction predicts the unknown output value given the input based on the model learned with the PNC
// cluster/learn algorithm. The class TCluster encapsulates such a model.
class TPrediction
{
public:
// constructor/destructor
TPrediction(TCluster*const& _cls, const TParameter*const& _para=NULL);
~TPrediction() { delete[] d_ins; delete[] d_out; };
const int& Progress() const { return progress; };
// functions to predict unknown output value given the input for a) one tuple and b) all tuples in given data object
float Predict(const float*const x, float& nIns);
void Predict(const TData*const& data_T, TLossFunction*const& loss, ofstream* file=NULL,
const bool& f_IsWithOutput=true, const bool* stop=NULL); // b)
private:
TCluster* cls; // model learned by PNC algorithm
float beta; // kernel width for regression task
int progress; // progress indication counter
const TParameter* para; // parameters
float *d_ins, *d_out; // distances/membership of tuple to cuboids
// prediction mechanism A) standard inside-outside nearest cuboid prediction
float StandardPrediction(const float*const& x, float& nIns);
bool EvMax (const float*const& mu, double& y); // estimate maximal suggested output value (MoM)
bool EvMean(const float*const& mu, double& y); // calculate mean of suggested output values (COG)
// prediction meachanism B) weighted count prediction
float WeightedCountPrediction(const float*const& x, float& nIns);
float EvDistances(const float*const& d, float& nIns);
};
#endif