30 #ifndef GRT_GAUSSIAN_MIXTURE_MODELS_HEADER 31 #define GRT_GAUSSIAN_MIXTURE_MODELS_HEADER 33 #include "../../CoreModules/Clusterer.h" 43 GaussianMixtureModels(
const UINT numClusters=10,
const UINT minNumEpochs=5,
const UINT maxNumEpochs=1000,
const Float minChange=1.0e-5,
const UINT numRestarts=5);
123 virtual bool saveModelToFile( std::fstream &file )
const;
132 virtual bool loadModelFromFile( std::fstream &file );
167 static std::string
getId();
180 using MLBase::saveModelToFile;
181 using MLBase::loadModelFromFile;
187 bool computeInvAndDet();
188 inline void SWAP(UINT &a,UINT &b);
189 inline Float SQR(
const Float v){
return v*v; }
196 const UINT N = (UINT)x.size();
200 y = (1.0/pow(TWO_PI,N/2.0)) * (1.0/pow(det[clusterIndex],0.5));
205 temp[i] += (x[j]-mu[clusterIndex][j]) * invSigma[clusterIndex][j][i];
207 sum += (x[i]-mu[clusterIndex][i]) * temp[i];
210 return ( y*exp( -0.5*sum ) );
226 static const std::string id;
231 #endif //GRT_GAUSSIAN_MIXTURE_MODELS_HEADER std::string getId() const
virtual bool reset() override
virtual bool predict_(VectorFloat &inputVector)
bool setNumRestarts(const UINT numRestarts)
VectorDouble lndets
A vector holding the log detminants of SIGMA'k.
Float loglike
The current loglikelihood value of the models given the data.
virtual bool clear() override
virtual bool deepCopyFrom(const Clusterer *clusterer)
virtual bool train_(MatrixFloat &trainingData) override
MatrixFloat getMu() const
MatrixFloat mu
A matrix holding the estimated mean values of each Gaussian.
Vector< MatrixFloat > getSigma() const
VectorDouble frac
A vector holding the P(k)'s.
UINT numRestarts
The number of times the learning algorithm can reattempt to train a model.
MatrixFloat resp
The responsibility matrix.
UINT numTrainingSamples
The number of samples in the training data.