Search in sources :

Example 1 with TrainingDatasetSplitDTO

use of io.hops.hopsworks.common.featurestore.trainingdatasets.split.TrainingDatasetSplitDTO in project hopsworks by logicalclocks.

the class TestTrainingDatasetInputValidation method setup.

@Before
public void setup() {
    splits = new ArrayList<>();
    splits.add(new TrainingDatasetSplitDTO("train", 0.8f));
    splits.add(new TrainingDatasetSplitDTO("test", 0.2f));
}
Also used : TrainingDatasetSplitDTO(io.hops.hopsworks.common.featurestore.trainingdatasets.split.TrainingDatasetSplitDTO) Before(org.junit.Before)

Example 2 with TrainingDatasetSplitDTO

use of io.hops.hopsworks.common.featurestore.trainingdatasets.split.TrainingDatasetSplitDTO in project hopsworks by logicalclocks.

the class TrainingDatasetInputValidation method validateSplits.

private void validateSplits(List<TrainingDatasetSplitDTO> trainingDatasetSplitDTOs) throws FeaturestoreException {
    if (trainingDatasetSplitDTOs != null && !trainingDatasetSplitDTOs.isEmpty()) {
        Pattern namePattern = FeaturestoreConstants.FEATURESTORE_REGEX;
        Set<String> splitNames = new HashSet<>();
        for (TrainingDatasetSplitDTO trainingDatasetSplitDTO : trainingDatasetSplitDTOs) {
            if (!namePattern.matcher(trainingDatasetSplitDTO.getName()).matches()) {
                throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.ILLEGAL_TRAINING_DATASET_SPLIT_NAME, Level.FINE, ", the provided training dataset split name " + trainingDatasetSplitDTO.getName() + " is " + "invalid. Split names can only contain lower case characters, numbers and underscores and cannot be " + "longer than " + FeaturestoreConstants.FEATURESTORE_ENTITY_NAME_MAX_LENGTH + " characters or empty.");
            }
            if (trainingDatasetSplitDTO.getPercentage() == null) {
                throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.ILLEGAL_TRAINING_DATASET_SPLIT_PERCENTAGE, Level.FINE, ", the provided training dataset split percentage is invalid. " + "Percentages can only be numeric. Weights will be normalized if they don’t sum up to 1.0.");
            }
            if (!splitNames.add(trainingDatasetSplitDTO.getName())) {
                throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.TRAINING_DATASET_DUPLICATE_SPLIT_NAMES, Level.FINE, " The split names must be unique");
            }
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) TrainingDatasetSplitDTO(io.hops.hopsworks.common.featurestore.trainingdatasets.split.TrainingDatasetSplitDTO) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) HashSet(java.util.HashSet)

Aggregations

TrainingDatasetSplitDTO (io.hops.hopsworks.common.featurestore.trainingdatasets.split.TrainingDatasetSplitDTO)2 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)1 HashSet (java.util.HashSet)1 Pattern (java.util.regex.Pattern)1 Before (org.junit.Before)1