Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_label(all_eval_features, removed_features, label_mode):
eval_features = set(all_eval_features)
if label_mode == LabelMode.AddFeature:
add_features = eval_features - set(removed_features)
return "Features: {}".format(FactorUtils.factors_to_ranges_string(add_features))
else:
return "Ignore: {}".format(FactorUtils.factors_to_ranges_string(set(removed_features)))
def factors_to_ranges_string(factors_set):
if factors_set is None or len(factors_set) == 0:
return "None"
grouped_factors = FactorUtils.group_factors_by_range(factors_set)
return ';'.join([FactorUtils.single_range_to_string(min(x), max(x)) for x in grouped_factors])
def compress_string_factors(string_factors):
factors = FactorUtils.extract_factors(string_factors)
compressed_string_factors = FactorUtils.factors_to_string(factors)
return compressed_string_factors
def compress_string_factors(string_factors):
factors = FactorUtils.extract_factors(string_factors)
compressed_string_factors = FactorUtils.factors_to_string(factors)
return compressed_string_factors
def factors_to_ranges_string(factors_set):
if factors_set is None or len(factors_set) == 0:
return "None"
grouped_factors = FactorUtils.group_factors_by_range(factors_set)
return ';'.join([FactorUtils.single_range_to_string(min(x), max(x)) for x in grouped_factors])