oversampleqa.reports¶
oversampleqa.reports
¶
One report object, and the metadata that makes it auditable.
Three surfaces had drifted apart: validate_oversampling returned a float or a
tuple, the inference layer returned its own dataclasses, and the fidelity suite
returned a third set. Every consumer -- CLI, reporting, plotting, benchmarks --
needed bespoke handling for each. :class:ValidationReport composes them, so a
consumer handles one shape.
Exported results outlive the code that produced them, so every export carries a
schema_version and the metadata needed to reproduce the run.
SCHEMA_VERSION = '1.0'
module-attribute
¶
Version of the exported JSON structure.
Bump the minor part for additive changes and the major part when a field is removed or changes meaning. Consumers should refuse a major version they do not recognise rather than guess.
RunMetadata
dataclass
¶
Everything needed to reproduce and audit a run.
A number without its provenance is not a result. This records the package and dependency versions, the sampler and its parameters, the seed, and a hash of the data -- so a report exported today can be checked against a rerun in a year, and a mismatch localised to whichever of those changed.
Source code in src/oversampleqa/reports.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
capture(X, y, oversampler, *, minority_label=None, metric='hassanat', hidden_ratio=0.1, reference='hidden_minority', random_state=None, n_repeats=1)
classmethod
¶
Collect metadata for a run about to happen, or just completed.
Source code in src/oversampleqa/reports.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
to_dict()
¶
JSON-safe mapping.
Source code in src/oversampleqa/reports.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
from_dict(payload)
classmethod
¶
Rebuild from :meth:to_dict output, ignoring unknown keys.
Source code in src/oversampleqa/reports.py
148 149 150 151 152 | |
ValidationReport
dataclass
¶
Everything known about one oversampler on one dataset.
calibration, inference and fidelity are optional because each
costs real time: the calibration fits nothing but resamples repeatedly, the
two-sample tests permute, and the fidelity suite can fit models. A report
with only error_rate and details is the cheap default.
Source code in src/oversampleqa/reports.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
to_dict()
¶
JSON-serialisable mapping of the whole report.
Non-finite floats become null; see :func:_json_safe.
Source code in src/oversampleqa/reports.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
from_dict(payload)
classmethod
¶
Rebuild from :meth:to_dict output.
Components come back as plain dicts rather than their original
dataclasses: the export is the interchange format, and rehydrating each
component type would couple this module to every one of them. Round
trips are therefore compared on to_dict(), which is what a consumer
actually reads.
Source code in src/oversampleqa/reports.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
to_json(indent=2)
¶
Serialise to JSON. allow_nan=False guarantees valid output.
Source code in src/oversampleqa/reports.py
224 225 226 | |
to_frame()
¶
Tidy one-row frame with every scalar flattened.
Source code in src/oversampleqa/reports.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
__rich__()
¶
Compact CLI rendering.
Source code in src/oversampleqa/reports.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
with_components(**components)
¶
Return a copy carrying additional components.
Source code in src/oversampleqa/reports.py
282 283 284 | |