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  : SVEvent                                                               *
0008  *                                             *
0009  *                                                                                *
0010  * Description:                                                                   *
0011  *      Event 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_SVEvent
0029 #define ROOT_TMVA_SVEvent
0030 
0031 #include <vector>
0032 #include <iostream>
0033 
0034 #include "Rtypes.h"
0035 
0036 namespace TMVA
0037 {
0038    class Event;
0039 
0040    class SVEvent {
0041 
0042    public:
0043 
0044       SVEvent();
0045       SVEvent( const Event*, Float_t, Bool_t isSignal = kFALSE );
0046       SVEvent( const std::vector<Float_t>*, Float_t alpha, Int_t typeFlag, UInt_t ns );
0047       SVEvent( const std::vector<Float_t>* svector, Float_t alpha, Float_t alpha_p, Int_t typeFlag);
0048 
0049       virtual ~SVEvent();
0050 
0051       void SetAlpha        ( Float_t  alpha )      { fAlpha = alpha; }
0052       void SetAlpha_p      ( Float_t  alpha )      { fAlpha_p = alpha; }
0053       void SetErrorCache   ( Float_t  err_cache )  { fErrorCache = err_cache; }
0054       void SetIsShrinked   ( Int_t    isshrinked ) { fIsShrinked = isshrinked; }
0055       void SetLine         ( Float_t* line )       { fLine = line; }
0056       void SetIdx          ( Int_t    idx )        { fIdx = idx; }
0057       void SetNs           ( UInt_t   ns )         { fNs = ns; }
0058       void UpdateErrorCache(Float_t upercache )    { fErrorCache += upercache; }
0059 
0060       std::vector<Float_t>* GetDataVector() { return &fDataVector; }
0061       Float_t  GetAlpha()         const { return fAlpha; }
0062       Float_t  GetAlpha_p()       const { return fAlpha_p; }
0063       Float_t  GetDeltaAlpha()    const { return fAlpha -  fAlpha_p; }
0064 
0065       Float_t  GetErrorCache()  const { return fErrorCache; }
0066       Int_t    GetTypeFlag()    const  { return fTypeFlag; }
0067       Int_t    GetNVar()        const  { return fNVar; }
0068       Int_t    GetIdx()         const  { return fIdx;}
0069       Float_t* GetLine()        const  { return fLine;}
0070       UInt_t   GetNs()          const  { return fNs;}
0071       Float_t  GetCweight()     const  { return fCweight;}
0072       Float_t  GetTarget()      const  { return fTarget;}
0073 
0074       Bool_t  IsInI0a() const { return (0.< fAlpha) && (fAlpha<fCweight); }
0075       Bool_t  IsInI0b() const { return (0.< fAlpha) && (fAlpha_p<fCweight); }
0076       Bool_t  IsInI0()  const { return (IsInI0a() || IsInI0b()); }
0077       Bool_t  IsInI1()  const { return (fAlpha == 0. && fAlpha_p == 0.); }
0078       Bool_t  IsInI2()  const { return (fAlpha == 0. && fAlpha_p == fCweight); }
0079       Bool_t  IsInI3()  const { return (fAlpha == fCweight && fAlpha_p == 0.); }
0080 
0081       void Print( std::ostream& os ) const;
0082       void PrintData();
0083 
0084    private:
0085 
0086       std::vector<Float_t> fDataVector;
0087       const Float_t        fCweight;     ///< svm cost weight
0088       Float_t              fAlpha;       ///< Lagrange multiplier
0089       Float_t              fAlpha_p;     ///< Lagrange multiplier
0090       Float_t              fErrorCache;  ///< optimization parameter
0091       UInt_t               fNVar;        ///< number of variables
0092       const Int_t          fTypeFlag;    ///< is sig or bkg - svm requieres 1 for sig and -1 for bkg
0093       Int_t                fIdx;         ///< index flag
0094       UInt_t               fNs;          ///< documentation
0095       Int_t                fIsShrinked;  ///< shrinking flag, see documentation
0096       Float_t*             fLine;        ///< pointer to column of kernel matrix
0097       const Float_t        fTarget;      ///< regression target
0098 
0099       ClassDef(SVEvent,0); // Event for SVM
0100    };
0101 }
0102 
0103 #endif //ROOT_TMVA_SVEvent