// 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 . /* Copyright, 2000 Nevrax Ltd. * * This file is part of NEVRAX NEL. * NEVRAX NEL 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; either version 2, or (at your option) * any later version. * NEVRAX NEL 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 NEVRAX NEL; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ #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