26#ifndef ROOT_TMVA_ModulekNN
27#define ROOT_TMVA_ModulekNN
57 typedef std::vector<VarType> VarVec;
86 void Print(std::ostream& os)
const;
97 typedef std::vector<TMVA::kNN::Event> EventVec;
98 typedef std::pair<const Node<Event> *, VarType> Elem;
99 typedef std::list<Elem> List;
107 typedef std::map<int, std::vector<Double_t> >
VarMap;
130 const std::map<Int_t, Double_t>&
GetMetric()
const;
133 void Print(std::ostream &os)
const;
172 const VarType var2 =
GetVar(ivar);
173 return (var1 - var2) * (var1 - var2);
ostringstream derivative to redirect and format output
VarType GetDist(VarType var, UInt_t ivar) const
VarType GetTgt(UInt_t i) const
void SetTargets(const VarVec &tvec)
const VarVec & GetTargets() const
Double_t GetWeight() const
Event()
default constructor
VarType GetVar(UInt_t i) const
const VarVec & GetVars() const
std::map< Int_t, Double_t > fVarScale
Bool_t Fill(const UShort_t odepth, UInt_t ifrac, const std::string &option="")
fill the tree
const VarMap & GetVarMap() const
Node< Event > * Optimize(UInt_t optimize_depth)
Optimize() balances binary tree for first odepth levels for each depth we split sorted depth % dimens...
const EventVec & GetEventVec() const
static TRandom3 & GetRndmThreadLocal()
std::map< int, std::vector< Double_t > > VarMap
ModulekNN()
default constructor
Bool_t Find(Event event, UInt_t nfind=100, const std::string &option="count") const
find in tree if tree has been filled then search for nfind closest events if metic (fVarScale map) is...
const Event Scale(const Event &event) const
scale each event variable so that rms of variables is approximately 1.0 this allows comparisons of va...
void ComputeMetric(UInt_t ifrac)
compute scale factor for each variable (dimension) so that distance is computed uniformly along each ...
const Event & GetkNNEvent() const
const std::map< Int_t, Double_t > & GetMetric() const
std::map< Short_t, UInt_t > fCount
void Add(const Event &event)
add an event to tree
const List & GetkNNList() const
This file contains binary tree and global function template that searches tree for k-nearest neigbors...
Random number generator class based on M.
std::ostream & operator<<(std::ostream &os, const Event &event)
Abstract ClassifierFactory template that handles arbitrary types.