FairRoot/PandaRoot
PndStdKnnClassify.h
Go to the documentation of this file.
1 /* ***************************************
2  * KNN based classifier. *
3  * Author: M.Babai@rug.nl *
4  * Edited: E.A.Dijck@student.rug.nl *
5  * Version: *
6  * license: *
7  * ***************************************
8  */
9 /*
10  * Based on the straight KNN algorithm
11  * Using a linear search data structure.
12  */
13 //#pragma once
14 #ifndef PND_STD_KNN_CLASSIFY_H
15 #define PND_STD_KNN_CLASSIFY_H
16 
17 // Local includes
18 #include "PndMvaClassifier.h"
19 
20 /*
21  * KNN based classification alg. implementation.
22  */
24 {
25  public:
33  explicit PndStdKnnClassify(std::string const& inputFile,
34  std::vector<std::string> const& classNames,
35  std::vector<std::string> const& varNames);
36 
38  virtual ~PndStdKnnClassify();
39 
47  void GetMvaValues(std::vector<float> eventData,
48  std::map<std::string,float>& result);
54  std::string* Classify(std::vector<float> EvtData);
55 
59  inline void SetKNN( unsigned int const nNeighbours );
60 
64  inline unsigned int GetKnn() const;
65 
69  void Initialize();
70 
71  private:
75 
77  unsigned int m_Knn;
78 
80  std::vector<PndMvaDistObj> m_distances;
81 };//End interface.
82 // ____________________________ Inlines ________________
83 inline unsigned int PndStdKnnClassify::GetKnn() const
84 {
85  return m_Knn;
86 };
87 
88 inline void PndStdKnnClassify::SetKNN( unsigned int const nNeighbours )
89 {
90  m_Knn = nNeighbours;
91 };
92 #endif
PndStdKnnClassify & operator=(const PndStdKnnClassify &other)
std::vector< PndMvaDistObj > m_distances
Container to hold the distances to current pattern.
std::string * Classify(std::vector< float > EvtData)
void GetMvaValues(std::vector< float > eventData, std::map< std::string, float > &result)
unsigned int GetKnn() const
void SetKNN(unsigned int const nNeighbours)
virtual ~PndStdKnnClassify()
Destructor.
unsigned int m_Knn
Number of Neighbours.
PndStdKnnClassify(std::string const &inputFile, std::vector< std::string > const &classNames, std::vector< std::string > const &varNames)