31 #ifndef GRT_KMEANS_HEADER 32 #define GRT_KMEANS_HEADER 34 #include "../../Util/GRTCommon.h" 35 #include "../../CoreModules/Clusterer.h" 36 #include "../../DataStructures/ClassificationData.h" 37 #include "../../DataStructures/UnlabelledData.h" 47 KMeans(
const UINT numClusters=10,
const UINT minNumEpochs=5,
const UINT maxNumEpochs=1000,
const Float minChange=1.0e-5,
const bool computeTheta=
true);
141 virtual bool saveModelToFile( std::fstream &file )
const;
150 virtual bool loadModelFromFile( std::fstream &file );
155 Float getTheta(){
return finalTheta; }
156 bool getModelTrained(){
return trained; }
158 const VectorFloat& getTrainingThetaLog()
const {
return thetaTracker; }
159 const MatrixFloat& getClusters()
const {
return clusters; }
160 const Vector< UINT >& getClassLabelsVector()
const {
return assign; }
161 const Vector< UINT >& getClassCountVector()
const {
return count; }
164 bool setComputeTheta(
const bool computeTheta);
176 using MLBase::saveModelToFile;
177 using MLBase::loadModelFromFile;
188 static std::string
getId();
194 inline Float SQR(
const Float a) {
return a*a;};
206 static const std::string id;
211 #endif //GRT_KMEANS_HEADER std::string getId() const
virtual bool predict(VectorFloat inputVector)
virtual bool reset() override
virtual bool predict_(VectorFloat &inputVector)
virtual bool clear() override
virtual bool train(ClassificationData trainingData)
virtual bool deepCopyFrom(const Clusterer *clusterer)
virtual bool train_(MatrixFloat &trainingData) override
UINT nchg
Number of values changes.
UINT numTrainingSamples
Number of training examples.
virtual bool train_(ClassificationData &trainingData)