English Français

Documentation / Manuel développeur

Modules disponibles

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Modeler: TkNN.h Source File
Uranie / Modeler v4.9.0
/* @license-end */
TkNN.h
Go to the documentation of this file.
1
2// Copyright (C) 2013-2024 CEA/DES
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Lesser General Public License as published
6// by the Free Software Foundation, either version 3 of the License, or any
7// later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
18// $Id$
19// $Author$
20// $Date$
21// $Revision$
22// $State$
24
41#ifndef TKNN_H
42#define TKNN_H
43
44
45// Uranie
46#include "TModeler.h"
47
48
49namespace URANIE {
50 namespace Modeler {
52 class TkNN : public TModeler {
53 public:
54 Double_t _dr2a;
55 Int_t _nK;
57 TString _sDraw;
58 URANIE::DataServer::TDataServer *_tdsQuery;
59
60 // Operations
61 public:
62 //---------------------------------------------
66
67 TkNN(URANIE::DataServer::TDataServer *tds, TString architecture, Option_t *option ="");
69 /*
70 \param tds (URANIE::DataServer::TDataServer *) the dataserver
71 \param varexpinput(const char*)[""] The list of input attributes to pass to the function separated by the caracter ":"
72 \param varexpoutput (const char *)[""] The list of output attributes separated by the caracter ":"
73 \param
74 */
75 TkNN (URANIE::DataServer::TDataServer *tds, const char *varexpinput, const char *varexpoutput, Int_t nkernel, Option_t * option="");
77 virtual ~TkNN();
79
80 //---------------------------------------------
84
88 void setK( Int_t k) { _nK = k;}
90 Int_t getK() { return _nK;}
92
95 void setQueryPoints(URANIE::DataServer::TDataServer *tds);
96
98
99 //---------------------------------------------
103
104 void draw(const char * vars, Option_t * option = "");
106#ifdef WITH_GPUANN
107 void estimate(Option_t * option = "", Bool_t useGPU = true);
108#else
109 void estimate(Option_t * option = "", Bool_t useGPU = false);
110#endif
112
113 //---------------------------------------------
117
122 void exportModelCplusplus(std::ofstream * sourcefile) const;
124
128 void exportModelFortran(std::ofstream * sourcefile) const;
129
131 void exportModelPMML(const char* file = "",
132 const char* name = "",Option_t *option = "") const
133 {
134 TString soption = option;
135 soption.ToLower();
136 UNUSED(file,name);
137 std::cerr
138 << " --- Method TkNN::exportModelPMML(ofstream * sourcefile) not yet implemented"
139 << endl;
140 throw URANIE::Exceptions::UWarningExceptions(__FILE__, __LINE__,
141 "TkNN::exportFunction\n The PMML language is not yet implemented.");
142 };
144 void exportModelPython(std::ofstream * sourcefile) const
145 {
146 UNUSED(sourcefile);
147 std::cerr
148 << " --- Method TkNN::exportModelPython(ofstream * sourcefile) not yet implemented"
149 << endl;
150 throw URANIE::Exceptions::UWarningExceptions(__FILE__, __LINE__,
151 "TkNN::exportFunction\n The Python language is not yet implemented.");
152 };
154
155
156
157 //---------------------------------------------
161 virtual void printLog(Option_t *option ="");
163
164 private:
165 void estimate_cpu(Option_t * option = "");
166
167 void LSort(int n, double* array, int* index, Int_t nbthreads);
168
169 void beginLoop(Int_t iq, Int_t nsq);
170 void endLoop(Int_t iq, int nsr, double* vecDistance, int* vecIndex, Float_t *vecReferenceOutput, Double_t *tabValue, TBranch *tby, Int_t nbthreads);
171
172#ifdef WITH_GPUANN
173 void estimate_GPU(Option_t * option = "");
174#endif
175
176
177 ClassDef(URANIE::Modeler::TkNN, ID_MODELER) //Classe de
178 };
179
180 } // Fin du namespace Modeler
181} // Fin du namespace URANIE
182#endif
Interface of the class URANIE::Optimize::TModeler.
Definition TModeler.h:63
k Nearsest Neighbor algorithm
Definition TkNN.h:52
void exportModelPMML(const char *file="", const char *name="", Option_t *option="") const
Export the model as a PMML function (not implemented)
Definition TkNN.h:131
TkNN(URANIE::DataServer::TDataServer *tds, const char *varexpinput, const char *varexpoutput, Int_t nkernel, Option_t *option="")
Default constructor with input and output attributes.
virtual void printLog(Option_t *option="")
TString _sDraw
! The distance normalized for input and output
Definition TkNN.h:57
URANIE::DataServer::TDataServer * _tdsQuery
the TDS contins the query points
Definition TkNN.h:58
void exportModelPython(std::ofstream *sourcefile) const
Export the model as a Python function (not implemented)
Definition TkNN.h:144
void setK(Int_t k)
Set the number of neighbor (\it k)
Definition TkNN.h:88
Double_t _dr2a
The Adjusted R2 quality.
Definition TkNN.h:54
Int_t getK()
Get the number of neighbor (\it k)
Definition TkNN.h:90
EDistance _nDistance
Definition TkNN.h:56
void draw(const char *vars, Option_t *option="")
draw
void estimate_cpu(Option_t *option="")
Int_t _nK
the number of neighboor to take into account
Definition TkNN.h:55
void LSort(int n, double *array, int *index, Int_t nbthreads)
virtual ~TkNN()
Default destructor.
void beginLoop(Int_t iq, Int_t nsq)
TkNN(URANIE::DataServer::TDataServer *tds, TString architecture, Option_t *option="")
Default constructor with the TDataServer.
void estimate(Option_t *option="", Bool_t useGPU=false)
make the learning
void exportModelFortran(std::ofstream *sourcefile) const
Export the model in Fortran langage in a file.
void exportModelCplusplus(std::ofstream *sourcefile) const
Export the model in C++ langage in a file.
void endLoop(Int_t iq, int nsr, double *vecDistance, int *vecIndex, Float_t *vecReferenceOutput, Double_t *tabValue, TBranch *tby, Int_t nbthreads)
void setQueryPoints(URANIE::DataServer::TDataServer *tds)
Set the set of query points from a dataserver.
EDistance
Definition TkNN.h:51
@ kL1
Definition TkNN.h:51
@ kChebyshev
Definition TkNN.h:51
@ kManhattan
Definition TkNN.h:51
@ kMahalanobis
Definition TkNN.h:51
@ kEuclidean
Definition TkNN.h:51
ROOT.
Definition TAnisp.h:164