PandaRoot
PndStdKnnClassify.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /* ***************************************
14  * KNN based classifier. *
15  * Author: M.Babai@rug.nl *
16  * Edited: E.A.Dijck@student.rug.nl *
17  * Version: *
18  * license: *
19  * ***************************************
20  */
21 /*
22  * Based on the straight KNN algorithm
23  * Using a linear search data structure.
24  */
25 //#pragma once
26 #ifndef PND_STD_KNN_CLASSIFY_H
27 #define PND_STD_KNN_CLASSIFY_H
28 
29 // Local includes
30 #include "PndMvaClassifier.h"
31 
32 /*
33  * KNN based classification alg. implementation.
34  */
36  public:
44  explicit PndStdKnnClassify(std::string const &inputFile, std::vector<std::string> const &classNames, std::vector<std::string> const &varNames);
45 
47  virtual ~PndStdKnnClassify();
48 
56  void GetMvaValues(std::vector<float> eventData, std::map<std::string, float> &result);
62  std::string *Classify(std::vector<float> EvtData);
63 
67  inline void SetKNN(unsigned int const nNeighbours);
68 
72  inline unsigned int GetKnn() const;
73 
77  void Initialize();
78 
79  private:
82  PndStdKnnClassify &operator=(const PndStdKnnClassify &other);
83 
85  unsigned int m_Knn;
86 
88  std::vector<PndMvaDistObj> m_distances;
89 }; // End interface.
90 // ____________________________ Inlines ________________
91 inline unsigned int PndStdKnnClassify::GetKnn() const
92 {
93  return m_Knn;
94 };
95 
96 inline void PndStdKnnClassify::SetKNN(unsigned int const nNeighbours)
97 {
98  m_Knn = nNeighbours;
99 };
100 #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)