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
7743cc74
Commit
7743cc74
authored
6 years ago
by
Kim Albertsson
Committed by
Axel Naumann
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[TMVA] CV Stratified -- Fix whitespace issues
parent
b3c2ae93
Branches
Branches containing commit
Tags
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/CvSplit.h
+1
-1
1 addition, 1 deletion
tmva/tmva/inc/TMVA/CvSplit.h
tmva/tmva/src/CvSplit.cxx
+16
-15
16 additions, 15 deletions
tmva/tmva/src/CvSplit.cxx
with
17 additions
and
16 deletions
tmva/tmva/inc/TMVA/CvSplit.h
+
1
−
1
View file @
7743cc74
...
...
@@ -100,7 +100,7 @@ public:
private
:
std
::
vector
<
std
::
vector
<
Event
*>>
SplitSets
(
std
::
vector
<
TMVA
::
Event
*>
&
oldSet
,
UInt_t
numFolds
,
UInt_t
numClasses
);
std
::
vector
<
UInt_t
>
GetEventIndexToFoldMapping
(
UInt_t
nEntries
,
UInt_t
numFolds
,
UInt_t
seed
=
100
);
private
:
UInt_t
fSeed
;
TString
fSplitExprString
;
//! Expression used to split data into folds. Should output values between 0 and numFolds.
...
...
This diff is collapsed.
Click to expand it.
tmva/tmva/src/CvSplit.cxx
+
16
−
15
View file @
7743cc74
...
...
@@ -331,7 +331,6 @@ TMVA::CvSplitKFolds::SplitSets(std::vector<TMVA::Event *> &oldSet, UInt_t numFol
Bool_t
useSplitExpr
=
not
(
fSplitExpr
==
nullptr
or
fSplitExprString
==
""
);
if
(
useSplitExpr
)
{
// Deterministic split
for
(
ULong64_t
i
=
0
;
i
<
nEntries
;
i
++
)
{
TMVA
::
Event
*
ev
=
oldSet
[
i
];
...
...
@@ -339,51 +338,53 @@ TMVA::CvSplitKFolds::SplitSets(std::vector<TMVA::Event *> &oldSet, UInt_t numFol
tempSets
.
at
((
UInt_t
)
iFold
).
push_back
(
ev
);
}
}
else
{
std
::
vector
<
UInt_t
>
fOrigToFoldMapping
;
if
(
not
fStratified
){
// Random split
std
::
vector
<
UInt_t
>
fOrigToFoldMapping
;
fOrigToFoldMapping
=
GetEventIndexToFoldMapping
(
nEntries
,
numFolds
,
fSeed
);
if
(
fStratified
==
kFALSE
){
// Random split
fOrigToFoldMapping
=
GetEventIndexToFoldMapping
(
nEntries
,
numFolds
,
fSeed
);
for
(
UInt_t
iEvent
=
0
;
iEvent
<
nEntries
;
++
iEvent
)
{
UInt_t
iFold
=
fOrigToFoldMapping
[
iEvent
];
TMVA
::
Event
*
ev
=
oldSet
[
iEvent
];
tempSets
.
at
(
iFold
).
push_back
(
ev
);
fEventToFoldMapping
[
ev
]
=
iFold
;
}
}
else
{
}
}
else
{
// Stratified Split
std
::
vector
<
std
::
vector
<
TMVA
::
Event
*>>
oldSets
;
oldSets
.
reserve
(
numClasses
);
for
(
UInt_t
iClass
=
0
;
iClass
<
numClasses
;
iClass
++
){
oldSets
.
emplace_back
();
//find a way to get number of events in each class
oldSets
.
reserve
(
nEntries
);
oldSets
.
reserve
(
nEntries
);
}
for
(
UInt_t
iEvent
=
0
;
iEvent
<
nEntries
;
++
iEvent
){
// check the class of event and add to its vector of events
TMVA
::
Event
*
ev
=
oldSet
[
iEvent
];
UInt_t
iClass
=
ev
->
GetClass
();
oldSets
.
at
(
iClass
).
push_back
(
ev
);
}
for
(
UInt_t
i
=
0
;
i
<
numClasses
;
++
i
){
// Shuffle each vector individually
TMVA
::
RandomGenerator
<
TRandom3
>
rng
(
fSeed
);
std
::
shuffle
(
oldSets
.
at
(
i
).
begin
(),
oldSets
.
at
(
i
).
end
(),
rng
);
}
for
(
UInt_t
i
=
0
;
i
<
numClasses
;
++
i
){
fOrigToFoldMapping
=
GetEventIndexToFoldMapping
(
oldSets
.
at
(
i
).
size
(),
numFolds
,
fSeed
);
for
(
UInt_t
i
=
0
;
i
<
numClasses
;
++
i
)
{
std
::
vector
<
UInt_t
>
fOrigToFoldMapping
;
fOrigToFoldMapping
=
GetEventIndexToFoldMapping
(
oldSets
.
at
(
i
).
size
(),
numFolds
,
fSeed
);
for
(
UInt_t
iEvent
=
0
;
iEvent
<
oldSets
.
at
(
i
).
size
();
++
iEvent
)
{
UInt_t
iFold
=
fOrigToFoldMapping
[
iEvent
];
TMVA
::
Event
*
ev
=
oldSets
.
at
(
i
)[
iEvent
];
tempSets
.
at
(
iFold
).
push_back
(
ev
);
fEventToFoldMapping
[
ev
]
=
iFold
;
}
}
}
}
}
return
tempSets
;
...
...
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