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