Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:10

0001 // @(#)root/tmva $Id$
0002 // Author: Andrzej Zemla
0003 
0004 /**********************************************************************************
0005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
0006  * Package: TMVA                                                                  *
0007  * Class  : SVWorkingSet                                                          *
0008  *                                             *
0009  *                                                                                *
0010  * Description:                                                                   *
0011  *      Working class for Support Vector Machine                                  *
0012  *                                                                                *
0013  * Authors (alphabetical):                                                        *
0014  *      Marcin Wolter  <Marcin.Wolter@cern.ch> - IFJ PAN, Krakow, Poland          *
0015  *      Andrzej Zemla  <azemla@cern.ch>        - IFJ PAN, Krakow, Poland          *
0016  *      (IFJ PAN: Henryk Niewodniczanski Inst. Nucl. Physics, Krakow, Poland)     *
0017  *                                                                                *
0018  * Copyright (c) 2005:                                                            *
0019  *      CERN, Switzerland                                                         *
0020  *      MPI-K Heidelberg, Germany                                                 *
0021  *      PAN, Krakow, Poland                                                       *
0022  *                                                                                *
0023  * Redistribution and use in source and binary forms, with or without             *
0024  * modification, are permitted according to the terms listed in LICENSE           *
0025  * (see tmva/doc/LICENSE)                                          *
0026  **********************************************************************************/
0027 
0028 #ifndef ROOT_TMVA_SVWorkingSet
0029 #define ROOT_TMVA_SVWorkingSet
0030 
0031 #include <vector>
0032 
0033 #include "RtypesCore.h"
0034 
0035 namespace TMVA {
0036 
0037    class SVEvent;
0038    class SVKernelMatrix;
0039    class SVKernelFunction;
0040    class MsgLogger;
0041 
0042    class SVWorkingSet {
0043 
0044    public:
0045 
0046       SVWorkingSet();
0047       SVWorkingSet( std::vector<TMVA::SVEvent*>*, SVKernelFunction*, Float_t , Bool_t);
0048       ~SVWorkingSet();
0049 
0050       Bool_t  ExamineExample( SVEvent*);
0051       Bool_t  TakeStep      ( SVEvent*, SVEvent*);
0052       Bool_t  Terminated();
0053       void    Train(UInt_t nIter=1000);
0054       std::vector<TMVA::SVEvent*>* GetSupportVectors();
0055       Float_t GetBpar() {return 0.5*(fB_low + fB_up);}
0056 
0057       //for regression
0058       Bool_t ExamineExampleReg(SVEvent*);
0059       Bool_t TakeStepReg(SVEvent*, SVEvent*);
0060       Bool_t IsDiffSignificant(Float_t, Float_t, Float_t);
0061       void   TrainReg();
0062 
0063       //setting up helper variables for JsMVA
0064       void SetIPythonInteractive(bool* ExitFromTraining, UInt_t *fIPyCurrentIter_){
0065         fExitFromTraining = ExitFromTraining;
0066         fIPyCurrentIter = fIPyCurrentIter_;
0067       }
0068 
0069 
0070    private:
0071 
0072       Bool_t fdoRegression;                     ///< TODO temporary, find nicer solution
0073       std::vector<TMVA::SVEvent*> *fInputData;  ///< input events
0074       std::vector<TMVA::SVEvent*> *fSupVec;     ///< output events - support vectors
0075       SVKernelFunction            *fKFunction;  ///< kernel function
0076       SVKernelMatrix              *fKMatrix;    ///< kernel matrix
0077 
0078       SVEvent                     *fTEventUp;   ///< last optimized event
0079       SVEvent                     *fTEventLow;  ///< last optimized event
0080 
0081       Float_t                     fB_low;       ///< documentation
0082       Float_t                     fB_up;        ///< documentation
0083       Float_t                     fTolerance;   ///< documentation
0084 
0085       mutable MsgLogger*          fLogger;      ///<! message logger
0086 
0087       // variables for JsMVA
0088       UInt_t *fIPyCurrentIter = nullptr;
0089       bool * fExitFromTraining = nullptr;
0090 
0091       void SetIndex( TMVA::SVEvent* );
0092    };
0093 }
0094 
0095 #endif //ROOT_TMVA_SVWorkingSet