// Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . #ifndef NL_TREE_H_ #define NL_TREE_H_ #include #include #include "record.h" #include "node.h" #include "field.h" class CTree { private: //std::vector _Fields; int _Key; INode *_RootNode; public: struct greater : public std::binary_function , std::pair , bool> { bool operator()(std::pair x, std::pair y) const { return x.first > y.first; } }; public: CTree(); ~CTree(); void setKey(int); int getKey(); bool getOutput(CRecord *); int getNbRecords(std::vector &,int,IValue *); std::vector getRecords(std::vector &, int , bool); void splitRecords(std::vector &, int, int &, int &); void splitRecords(std::vector &, int, std::vector &, std::vector< std::vector > &); void splitRecords(std::vector &, int, IValue *, int &, int &); void splitRecords(std::vector &, int, IValue *, bool, int &, int &); float findNumKeyValue(std::vector &, int); double log2(double) const; double entropy(double, double) const; double entropy(std::vector &) const; double gain(std::vector &, int, CField *); std::vector > getSortedFields(std::vector &, std::vector &, std::vector &); int getBestAttrib( std::vector &, std::vector &, std::vector &); void rebuild(std::vector &, std::vector &); std::string getDebugString(std::vector &, std::vector &); // returns the root node of a decision tree built with the ID3 algorithm INode *ID3(std::vector &, std::vector &, std::vector &); }; #endif