PandaRoot
PndPrzWindowClassify.h
Go to the documentation of this file.
1 /* ***************************************
2  * Parzen Window based classifier. *
3  * Author: M.Babai@rug.nl *
4  * Version: *
5  * license: *
6  * ***************************************
7  */
8 /*
9  * Based on the straight parzen window algorithm Using a linear search
10  * data structure.
11  */
12 //#pragma once
13 #ifndef PND_PRZ_WINDOW_CLASSIFY_H
14 #define PND_PRZ_WINDOW_CLASSIFY_H
15 
16 // Local includes
17 #include "PndMvaClassifier.h"
18 
19 /*
20  * Parzen Window based classification alg. implementation.
21  */
23  public:
24  /*
25  * @param inputFile: The name of the file that holds the weights
26  * @param classNames: The names of classes to which an event might be
27  * assigned to.
28  * @param varNames: Variable names from which the feature vector is
29  * built.
30  */
31  explicit PndPrzWindowClassify(std::string const &inputFile, std::vector<std::string> const &classNames, std::vector<std::string> const &varNames);
32 
34  virtual ~PndPrzWindowClassify();
35 
44  void GetMvaValues(std::vector<float> eventData, std::map<std::string, float> &result);
50  std::string *Classify(std::vector<float> EvtData);
51 
56  void setWindowSize(float wsize);
57 
62  inline void setWindowSize(std::map<std::string, float> const &wsize);
63 
67  inline float GetHyperCubeVolume() const;
68 
72  inline std::map<std::string, float> const &GetWindowSize() const;
73 
74  private:
75  // To avoid mistakes.
77  PndPrzWindowClassify &operator=(PndPrzWindowClassify const &other);
78 
79  /*
80  * A very simple implementation of a kernel function. It can be
81  * considerd as a multi-dimensional histogram with constant bin size
82  * in each dimension.
83  *@param evtDat Vector containing event data.
84  *@return 1 if the current test sample inside the window, else 0;
85  */
86  float histKernel(std::vector<float> const &evtDat, std::vector<float> const &trSample);
87 
88  // Compute the hypercube volume
89  float CompHyperCubeVolume();
90 
91  // Hypercube volume
92  float m_volumeN;
93 
94  // Window size in each dimension
95  std::map<std::string, float> m_Wsize;
96 };
97 
98 // ================================================================
99 inline void PndPrzWindowClassify::setWindowSize(std::map<std::string, float> const &wsize)
100 {
101  m_Wsize = std::map<std::string, float>(wsize);
102  // Set hypercube volume.
103  m_volumeN = CompHyperCubeVolume();
104 };
105 
107 {
108  return m_volumeN;
109 };
110 
111 inline std::map<std::string, float> const &PndPrzWindowClassify::GetWindowSize() const
112 {
113  return m_Wsize;
114 };
115 #endif // End of PndPrzWindowClassify interface.
void GetMvaValues(std::vector< float > eventData, std::map< std::string, float > &result)
PndPrzWindowClassify(std::string const &inputFile, std::vector< std::string > const &classNames, std::vector< std::string > const &varNames)
void setWindowSize(float wsize)
std::map< std::string, float > const & GetWindowSize() const
float GetHyperCubeVolume() const
std::string * Classify(std::vector< float > EvtData)
virtual ~PndPrzWindowClassify()
Destructor.