Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
610ef010
Commit
610ef010
authored
6 years ago
by
Kim Albertsson
Committed by
Lorenzo Moneta
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[TMVA] CV modernise -- range based for-loops
parent
e53085a6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tmva/tmva/inc/TMVA/CrossValidation.h
+1
-1
1 addition, 1 deletion
tmva/tmva/inc/TMVA/CrossValidation.h
tmva/tmva/src/CrossValidation.cxx
+17
-21
17 additions, 21 deletions
tmva/tmva/src/CrossValidation.cxx
with
18 additions
and
22 deletions
tmva/tmva/inc/TMVA/CrossValidation.h
+
1
−
1
View file @
610ef010
...
...
@@ -140,7 +140,7 @@ public:
void
Evaluate
();
private
:
CrossValidationFoldResult
ProcessFold
(
UInt_t
iFold
,
UInt_t
iM
ethod
);
CrossValidationFoldResult
ProcessFold
(
UInt_t
iFold
,
const
OptionMap
&
m
ethod
Info
);
Types
::
EAnalysisType
fAnalysisType
;
TString
fAnalysisTypeStr
;
...
...
This diff is collapsed.
Click to expand it.
tmva/tmva/src/CrossValidation.cxx
+
17
−
21
View file @
610ef010
...
...
@@ -387,18 +387,14 @@ void TMVA::CrossValidation::SetSplitExpr(TString splitExpr)
/// @param iFold fold to evaluate
///
TMVA
::
CrossValidationFoldResult
TMVA
::
CrossValidation
::
ProcessFold
(
UInt_t
iFold
,
UInt_t
iM
ethod
)
TMVA
::
CrossValidationFoldResult
TMVA
::
CrossValidation
::
ProcessFold
(
UInt_t
iFold
,
const
OptionMap
&
m
ethod
Info
)
{
TString
methodName
=
fMethods
[
iMethod
].
GetValue
<
TString
>
(
"MethodName"
);
TString
methodTitle
=
fMethods
[
iMethod
].
GetValue
<
TString
>
(
"MethodTitle"
);
TString
methodOptions
=
fMethods
[
iMethod
].
GetValue
<
TString
>
(
"MethodOptions"
);
TString
methodTypeName
=
methodInfo
.
GetValue
<
TString
>
(
"MethodName"
);
TString
methodTitle
=
methodInfo
.
GetValue
<
TString
>
(
"MethodTitle"
);
TString
methodOptions
=
methodInfo
.
GetValue
<
TString
>
(
"MethodOptions"
);
TString
foldTitle
=
methodTitle
+
(
"_fold"
)
+
(
iFold
+
1
);
Log
()
<<
kDEBUG
<<
"Fold ("
<<
methodTitle
<<
"): "
<<
iFold
<<
Endl
;
// Get specific fold of dataset and setup method
TString
foldTitle
=
methodTitle
;
foldTitle
+=
"_fold"
;
foldTitle
+=
iFold
+
1
;
Log
()
<<
kDEBUG
<<
"Processing "
<<
methodTitle
<<
" fold "
<<
iFold
<<
Endl
;
// Only used if fFoldOutputFile == true
TFile
*
foldOutputFile
=
nullptr
;
...
...
@@ -411,7 +407,7 @@ TMVA::CrossValidationFoldResult TMVA::CrossValidation::ProcessFold(UInt_t iFold,
}
fDataLoader
->
PrepareFoldDataSet
(
*
fSplit
.
get
(),
iFold
,
TMVA
::
Types
::
kTraining
);
MethodBase
*
smethod
=
fFoldFactory
->
BookMethod
(
fDataLoader
.
get
(),
methodName
,
foldTitle
,
methodOptions
);
MethodBase
*
smethod
=
fFoldFactory
->
BookMethod
(
fDataLoader
.
get
(),
method
Type
Name
,
foldTitle
,
methodOptions
);
// Train method (train method and eval train set)
Event
::
SetIsTraining
(
kTRUE
);
...
...
@@ -481,11 +477,11 @@ void TMVA::CrossValidation::Evaluate()
}
fResults
.
reserve
(
fMethods
.
size
());
for
(
UInt_t
iMethod
=
0
;
iMethod
<
fMethods
.
size
();
iMethod
++
)
{
for
(
auto
&
methodInfo
:
fMethods
)
{
CrossValidationResult
result
{
fNumFolds
};
TString
methodTypeName
=
fM
ethod
s
[
iMethod
]
.
GetValue
<
TString
>
(
"MethodName"
);
TString
methodTitle
=
fM
ethod
s
[
iMethod
]
.
GetValue
<
TString
>
(
"MethodTitle"
);
TString
methodTypeName
=
m
ethod
Info
.
GetValue
<
TString
>
(
"MethodName"
);
TString
methodTitle
=
m
ethod
Info
.
GetValue
<
TString
>
(
"MethodTitle"
);
if
(
methodTypeName
==
""
)
{
Log
()
<<
kFATAL
<<
"No method booked for cross-validation"
<<
Endl
;
...
...
@@ -502,15 +498,15 @@ void TMVA::CrossValidation::Evaluate()
}
if
(
nWorkers
==
1
)
{
for
(
UInt_t
iFold
=
0
;
iFold
<
fNumFolds
;
++
iFold
)
{
auto
fold_result
=
ProcessFold
(
iFold
,
iM
ethod
);
auto
fold_result
=
ProcessFold
(
iFold
,
m
ethod
Info
);
result
.
Fill
(
fold_result
);
}
}
else
{
ROOT
::
TProcessExecutor
workers
(
nWorkers
);
std
::
vector
<
CrossValidationFoldResult
>
result_vector
;
auto
workItem
=
[
this
,
iM
ethod
](
UInt_t
iFold
)
{
return
ProcessFold
(
iFold
,
iM
ethod
);
auto
workItem
=
[
this
,
m
ethod
Info
](
UInt_t
iFold
)
{
return
ProcessFold
(
iFold
,
m
ethod
Info
);
};
result_vector
=
workers
.
Map
(
workItem
,
ROOT
::
TSeqI
(
fNumFolds
));
...
...
@@ -544,12 +540,12 @@ void TMVA::CrossValidation::Evaluate()
fDataLoader
->
RecombineKFoldDataSet
(
*
fSplit
.
get
());
// "Eval" on training set
for
(
UInt_t
iMethod
=
0
;
iMethod
<
fMethods
.
size
();
iMethod
++
)
{
TString
methodTypeName
=
fM
ethod
s
[
iMethod
]
.
GetValue
<
TString
>
(
"MethodName"
);
TString
methodTitle
=
fM
ethod
s
[
iMethod
]
.
GetValue
<
TString
>
(
"MethodTitle"
);
for
(
auto
&
methodInfo
:
fMethods
)
{
TString
methodTypeName
=
m
ethod
Info
.
GetValue
<
TString
>
(
"MethodName"
);
TString
methodTitle
=
m
ethod
Info
.
GetValue
<
TString
>
(
"MethodTitle"
);
IMethod
*
method_interface
=
fFactory
->
GetMethod
(
fDataLoader
.
get
()
->
GetName
(),
methodTitle
);
MethodCrossValidation
*
method
=
dynamic_cast
<
MethodCrossValidation
*>
(
method_interface
);
auto
method
=
dynamic_cast
<
MethodCrossValidation
*>
(
method_interface
);
if
(
fOutputFile
)
{
fFactory
->
WriteDataInformation
(
method
->
fDataSetInfo
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment