File tree Expand file tree Collapse file tree
bindings/pyroot/pythonizations/python/ROOT/_pythonization Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -175,19 +175,6 @@ def __init__(
175175 given value is { validation_split } "
176176 )
177177
178- if load_eager :
179- # TODO: overhead, check if we can improve the following lines
180- if sampling_type == "undersampling" and not replacement :
181- rdf_0 = rdataframes [0 ].Count ().GetValue ()
182- rdf_1 = rdataframes [1 ].Count ().GetValue ()
183- rdf_minor = min (rdf_0 , rdf_1 )
184- rdf_major = max (rdf_0 , rdf_1 )
185- if rdf_major < rdf_minor / sampling_ratio :
186- raise ValueError (
187- f"The sampling_ratio is too low: not enough entries in the majority class to sample from. \n \
188- Choose sampling_ratio > { round (rdf_minor / rdf_major , 3 )} or set replacement to False."
189- )
190-
191178 if not hasattr (rdataframes , "__iter__" ):
192179 rdataframes = [rdataframes ]
193180 self .noded_rdfs = [RDF .AsRNode (rdf ) for rdf in rdataframes ]
Original file line number Diff line number Diff line change @@ -103,6 +103,14 @@ public:
103103 fNumMajor = fDatasets [fMajor ].GetRows ();
104104 fNumMinor = fDatasets [fMinor ].GetRows ();
105105 fNumResampledMajor = static_cast <std::size_t >(fNumMinor / fSampleRatio );
106+ if (!fReplacement && fNumResampledMajor > fNumMajor ) {
107+ auto minRatio = std::to_string (std::round (double (fNumMinor ) / double (fNumMajor ) * 100.0 ) / 100.0 );
108+ minRatio.erase (minRatio.find (' .' ) + 3 );
109+ throw std::invalid_argument (
110+ " The sampling_ratio is too low: not enough entries in the majority class to sample from.\n "
111+ " Choose sampling_ratio > " +
112+ minRatio + " or set replacement to True." );
113+ }
106114 fNumEntries = fNumMinor + fNumResampledMajor ;
107115 }
108116
You can’t perform that action at this time.
0 commit comments