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  public:
32  explicit PndStdKnnClassify(std::string const &inputFile, std::vector<std::string> const &classNames, std::vector<std::string> const &varNames);
33 
35  virtual ~PndStdKnnClassify();
36 
44  void GetMvaValues(std::vector<float> eventData, std::map<std::string, float> &result);
50  std::string *Classify(std::vector<float> EvtData);
51 
55  inline void SetKNN(unsigned int const nNeighbours);
56 
60  inline unsigned int GetKnn() const;
61 
65  void Initialize();
66 
67  private:
70  PndStdKnnClassify &operator=(const PndStdKnnClassify &other);
71 
73  unsigned int m_Knn;
74 
76  std::vector<PndMvaDistObj> m_distances;
77 }; // End interface.
78 // ____________________________ Inlines ________________
79 inline unsigned int PndStdKnnClassify::GetKnn() const
80 {
81  return m_Knn;
82 };
83 
84 inline void PndStdKnnClassify::SetKNN(unsigned int const nNeighbours)
85 {
86  m_Knn = nNeighbours;
87 };
88 #endif
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.
PndStdKnnClassify(std::string const &inputFile, std::vector< std::string > const &classNames, std::vector< std::string > const &varNames)