| 26 | |
| 27 | namespace NCB { |
| 28 | static void CheckOptions( |
| 29 | const TCatBoostOptions& catBoostOptions, |
| 30 | const TFeaturesSelectOptions& featuresSelectOptions, |
| 31 | const TDataProviders& pools |
| 32 | ) { |
| 33 | if (catBoostOptions.GetTaskType() == ETaskType::GPU) { |
| 34 | CB_ENSURE( |
| 35 | TTrainerFactory::Has(ETaskType::GPU), |
| 36 | "Can't load GPU learning library. " |
| 37 | "Module was not compiled or driver is incompatible with package. " |
| 38 | "Please install latest NVDIA driver and check again" |
| 39 | ); |
| 40 | } |
| 41 | |
| 42 | auto checkCountConsistency = [] ( |
| 43 | auto entriesForSelectSize, |
| 44 | const TOption<int>& numberOfEntriesToSelect, |
| 45 | TStringBuf entriesName |
| 46 | ) { |
| 47 | CB_ENSURE( |
| 48 | numberOfEntriesToSelect.IsSet(), |
| 49 | "You should specify the number of " << entriesName << " to select" |
| 50 | ); |
| 51 | CB_ENSURE( |
| 52 | numberOfEntriesToSelect.Get() > 0, |
| 53 | "Number of " << entriesName << " to select should be positive" |
| 54 | ); |
| 55 | CB_ENSURE(entriesForSelectSize > 0, "You should specify " << entriesName << " to select from"); |
| 56 | CB_ENSURE( |
| 57 | static_cast<int>(entriesForSelectSize) >= numberOfEntriesToSelect.Get(), |
| 58 | "It is impossible to select " << numberOfEntriesToSelect.Get() << ' ' << entriesName |
| 59 | << " from " << entriesForSelectSize << ' ' << entriesName |
| 60 | ); |
| 61 | }; |
| 62 | |
| 63 | |
| 64 | if (featuresSelectOptions.Grouping.Get() == EFeaturesSelectionGrouping::Individual) { |
| 65 | const auto& featuresForSelect = featuresSelectOptions.FeaturesForSelect.Get(); |
| 66 | |
| 67 | checkCountConsistency( |
| 68 | featuresForSelect.size(), |
| 69 | featuresSelectOptions.NumberOfFeaturesToSelect, |
| 70 | "features" |
| 71 | ); |
| 72 | |
| 73 | const ui32 featureCount = pools.Learn->MetaInfo.GetFeatureCount(); |
| 74 | for (const ui32 feature : featuresForSelect) { |
| 75 | CB_ENSURE( |
| 76 | feature < featureCount, |
| 77 | "Tested feature " << feature << " is not present; dataset contains only " << featureCount |
| 78 | << " features" |
| 79 | ); |
| 80 | } |
| 81 | } else { // ByTags |
| 82 | const auto& featuresTagsForSelect = featuresSelectOptions.FeaturesTagsForSelect.Get(); |
| 83 | |
| 84 | checkCountConsistency( |
| 85 | featuresTagsForSelect.size(), |
no test coverage detected