Coverage for sparkle/types/features.py: 99%
70 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-05 14:48 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-05 14:48 +0000
1"""Types definition for features to unify extractors across the Sparkle platform."""
2from __future__ import annotations
3from enum import Enum
6class FeatureGroup(str, Enum):
7 """Various feature groups."""
8 BASE = "base"
9 PRE = "pre"
10 DIAMETER = "dia"
11 LOBJOIS = "lobjois"
12 UNIT = "unit"
13 SP = "sp"
14 LS = "ls"
15 LP = "lp"
16 CL = "cl"
19class FeatureSubgroup(str, Enum):
20 """Various feature subgroups. Only used for embedding in with feature names."""
21 VCG = "Variable-Clause-Graph"
22 POSNEG = "Postive-Negative-Literals"
23 HORNY = "Horn-Formula"
24 VG = "Variable-Graph"
25 KLB = "Kevin-Leyton-Brown"
26 CG = "Clause-Graph"
27 BIAS = "bias"
28 UNCONSTRAINT = "unconstraint"
29 NUM = "num"
30 SIZE = "size"
33class FeatureType(str, Enum):
34 """Various feature types."""
35 MIN = "min"
36 MAX = "max"
37 MEAN = "mean"
38 ENTROPY = "entropy"
39 QUANTILE_10 = "q10"
40 QUANTILE_25 = "q25"
41 QUANTILE_50 = "q50"
42 QUANTILE_75 = "q75"
43 QUANTILE_90 = "q90"
44 COEFFICIENT_VARIATION = "coefficient_of_variation"
45 NUMBER_OF_VARS_ORIGINAL = "n_vars_original"
46 NUMBER_OF_CLAUSES_ORIGINAL = "n_clauses_original"
47 NUMBER_OF_VARS = "n_vars"
48 NUMBER_OF_CLAUSES = "n_clauses"
49 REDUCED_VARS = "reduced_vars"
50 REDUCED_CLAUSES = "reduced_clauses"
51 PRE_FEATURE_TIME = "pre_featuretime"
52 VARS_CLAUSES_RATIO = "vars_clauses_ratio"
53 CLAUSE_RATIO_MEAN = "clause_ratio_mean"
54 CLAUSE_RATIO_MINIMUM = "clause_ratio_minimum"
55 CLAUSE_RATIO_MAXIMUM = "clause_ratio_maximum"
56 CLAUSE_RATIO_ENTROPY = "clause_ratio_entropy"
57 CLAUSE_MEAN = "clause_mean"
58 CLAUSE_MIN = "clause_min"
59 CLAUSE_MAX = "clause_max"
60 CLAUSE_FRACTION = "clauses_fraction"
61 CLAUSE_ENTROPY = "clause_entropy"
62 CLAUSE_COEFFICIENT_VARIATION = "clause_coefficient_of_variation"
63 VAR_MEAN = "variable_mean"
64 VAR_MIN = "variable_min"
65 VAR_MAX = "variable_max"
66 VAR_STD = "variable_standard_deviation"
67 VAR_ENTROPY = "variable_entropy"
68 VAR_COEFFICIENT_VARIATION = "variable_coefficient_of_variation"
69 CLUSTER_COEFFICIENT_MEAN = "cluster_coefficient_mean"
70 CLUSTER_COEFFICIENT_VARIATION = "cluster_coefficient_of_variation"
71 CLUSTER_COEFFICIENT_MIN = "cluster_coefficient_min"
72 CLUSTER_COEFFICIENT_MAX = "cluster_coefficient_max"
73 CLUSTER_COEFFICIENT_ENTROPY = "cluster_coefficient_entropy"
74 UNARY = "unary"
75 BINARY = "binary"
76 TRINARY = "trinary"
77 FEATURE_TIME = "feature_time"
79 @staticmethod
80 def with_subgroup(subgroup: FeatureSubgroup, feature: FeatureType) -> str:
81 """Return a standardised string with a subgroup embedded."""
82 return f"{subgroup.value}_{feature.value}"