21 #define GRT_DLL_EXPORTS
27 UINT Regressifier::numRegressifierInstances = 0;
31 StringRegressifierMap::iterator iter = getMap()->find( regressifierType );
32 if( iter == getMap()->end() ){
35 return iter->second();
46 if( newInstance == NULL )
return NULL;
56 baseType = MLBase::REGRESSIFIER;
57 regressifierType =
"NOT_SET";
58 numOutputDimensions = 0;
59 numRegressifierInstances++;
63 if( --numRegressifierInstances == 0 ){
64 delete stringRegressifierMap;
65 stringRegressifierMap = NULL;
71 if( regressifier == NULL ){
72 errorLog <<
"copyBaseVariables(Regressifier *regressifier) - regressifier pointer is NULL!" << std::endl;
80 this->regressifierType = regressifier->regressifierType;
81 this->regressionData = regressifier->regressionData;
82 this->inputVectorRanges = regressifier->inputVectorRanges;
83 this->targetVectorRanges = regressifier->targetVectorRanges;
93 rootMeanSquaredTrainingError = 0;
94 totalSquaredTrainingError = 0;
104 rootMeanSquaredTrainingError = 0;
105 totalSquaredTrainingError = 0;
106 regressionData.clear();
107 inputVectorRanges.clear();
108 targetVectorRanges.clear();
114 return regressifierType;
119 return regressionData;
125 return inputVectorRanges;
129 return targetVectorRanges;
138 if( !file.is_open() ){
139 errorLog <<
"saveBaseSettingsToFile(fstream &file) - The file is not open!" << std::endl;
147 file <<
"InputVectorRanges: \n";
148 for(UINT j=0; j<numInputDimensions; j++){
149 file << inputVectorRanges[j].minValue <<
"\t" << inputVectorRanges[j].maxValue << std::endl;
152 file <<
"OutputVectorRanges: \n";
153 for(UINT j=0; j<numOutputDimensions; j++){
154 file << targetVectorRanges[j].minValue <<
"\t" << targetVectorRanges[j].maxValue << std::endl;
163 if( !file.is_open() ){
164 errorLog <<
"loadBaseSettingsFromFile(fstream &file) - The file is not open!" << std::endl;
178 if( word !=
"InputVectorRanges:" ){
179 errorLog <<
"loadBaseSettingsFromFile(fstream &file) - Failed to read InputVectorRanges header!" << std::endl;
182 inputVectorRanges.
resize(numInputDimensions);
183 for(UINT j=0; j<numInputDimensions; j++){
184 file >> inputVectorRanges[j].minValue;
185 file >> inputVectorRanges[j].maxValue;
189 if( word !=
"OutputVectorRanges:" ){
190 errorLog <<
"loadBaseSettingsFromFile(fstream &file) - Failed to read OutputVectorRanges header!" << std::endl;
193 targetVectorRanges.
resize(numOutputDimensions);
194 for(UINT j=0; j<numOutputDimensions; j++){
195 file >> targetVectorRanges[j].minValue;
196 file >> targetVectorRanges[j].maxValue;
202 regressionData.clear();
203 regressionData.
resize(numOutputDimensions,0);
Vector< MinMax > getOutputRanges() const
bool saveBaseSettingsToFile(std::fstream &file) const
std::map< std::string, Regressifier *(*)() > StringRegressifierMap
virtual bool resize(const unsigned int size)
Regressifier * createNewInstance() const
static Regressifier * createInstanceFromString(const std::string ®ressifierType)
bool copyBaseVariables(const Regressifier *regressifier)
virtual bool deepCopyFrom(const Regressifier *regressifier)
bool saveBaseSettingsToFile(std::fstream &file) const
std::string getRegressifierType() const
bool copyMLBaseVariables(const MLBase *mlBase)
bool loadBaseSettingsFromFile(std::fstream &file)
Vector< MinMax > getInputRanges() const
Regressifier * deepCopy() const
bool loadBaseSettingsFromFile(std::fstream &file)
virtual ~Regressifier(void)
const Regressifier & getBaseRegressifier() const
VectorFloat getRegressionData() const
This is the main base class that all GRT Regression algorithms should inherit from.