numeric_clipping¶
Train-fitted numeric model-input clipping; never a feature-generation rule.
NumericClipReport
¶
Bases: TypedDict
Model-input clipping diagnostics excluding numerical bound values.
Source code in featcopilot/utils/numeric_clipping.py
NumericQuantileClipper
¶
Bases: TransformerMixin, BaseEstimator
Clip model-input numeric columns using frozen training quantiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quantiles
|
tuple[float, float]
|
Finite pair 0 <= low < high <= 1. The default uses training min/max in native units, not MinMaxScaler. Experiments should pass their declared pair explicitly. Constructor parameters retain their identity for sklearn cloning; validated float quantiles are stored at fit time. |
(0.0, 1.0)
|
Attributes:
| Name | Type | Description |
|---|---|---|
bounds_ |
dict[str, tuple[float, float] or None]
|
Frozen bounds for fit-time numeric, non-boolean columns. None explicitly marks columns with no finite training values. |
numeric_columns_ |
tuple[str, ...]
|
Columns selected by dtype during fit; booleans are excluded. |
all_missing_columns_ |
tuple[str, ...]
|
Columns with no finite training observations after the finite guard. |
constant_columns_ |
tuple[str, ...]
|
Columns constant on their finite guarded training observations. |
quantiles_ |
tuple[float, float]
|
Canonical fitted quantile pair. |
Notes
At both fit and transform, nonfinite numeric inputs become NaN and finite numeric values are guarded at +/-1e30 BEFORE quantile fitting/application. Quantiles are fitted only on finite training observations. NaNs remain for a downstream imputer or native missing-value learner. All-missing training columns have guard-only behavior at inference, not invented quantile bounds. With (0, 1), finite float64 training values within the guard are unchanged bitwise, including signed zeros: only values strictly outside fitted bounds are assigned a boundary value. Values beyond +/-1e30 are still changed by the shared guard, independently of the quantile policy.
Input must be a DataFrame with unique string columns. Transform requires the fitted column names/order, but permits new categorical levels/dtypes. It returns a copy with the same index/schema and untouched nonnumeric and fit-time boolean columns. Numeric dtypes may become float. This transformer belongs after candidate generation and before model imputation/scaling; it does not mutate raw user data or generated feature definitions.
Source code in featcopilot/utils/numeric_clipping.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 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 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
fit(X, y=None)
¶
Fit bounds using only the supplied training rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
DataFrame
|
Nonempty training frame; no target information is used. |
required |
y
|
object
|
Ignored, for sklearn pipeline compatibility. |
None
|
Returns:
| Type | Description |
|---|---|
NumericQuantileClipper
|
This fitted transformer. Failed refits leave it unfitted. |
Source code in featcopilot/utils/numeric_clipping.py
get_clip_report()
¶
Return fitted policy/schema diagnostics without numerical bound values.
Source code in featcopilot/utils/numeric_clipping.py
get_feature_names_out(input_features=None)
¶
Return unchanged fitted feature names, validating any supplied schema.
Source code in featcopilot/utils/numeric_clipping.py
transform(X)
¶
Apply the frozen guard/bounds without fitting on this batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
DataFrame
|
Input rows in the fitted column order; empty batches are supported. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A new frame with unchanged index, column names/order and passthrough categorical/boolean values. Numeric NaNs remain NaN. |
Source code in featcopilot/utils/numeric_clipping.py
finite_quantile_bounds(values, quantiles)
¶
Estimate finite-data quantile bounds using overflow-resistant scaling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
ndarray
|
One-dimensional real numeric training values. This kernel deliberately
does NOT impose the model-input guard, preserving fitted-rule clip
semantics. Call |
required |
quantiles
|
tuple[float, float]
|
Ordered quantiles in [0, 1]. Equal bounds remain supported here for existing fitted-rule clips, unlike the model-input policy validator. Endpoints zero/one use exact finite min/max; when both are endpoints, no quantile interpolation or magnitude normalization is performed. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float] or None
|
Finite lower/upper bounds, or None when no finite training values exist. No fabricated zero statistics are returned. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If values or quantiles are invalid. |
Source code in featcopilot/utils/numeric_clipping.py
guard_numeric_values(values)
¶
Apply the existing finite-value guard without learning statistics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
ndarray
|
Real numeric values. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
A new array: nonfinite values become NaN and finite values are clipped to +/-1e30. Missingness is not imputed. |
Source code in featcopilot/utils/numeric_clipping.py
validate_clip_quantiles(value)
¶
Validate an optional, canonical numeric model-input clipping policy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
object
|
None disables the policy. Otherwise supply a two-element tuple or list of finite real quantiles with 0 <= low < high <= 1. Booleans and strings are rejected rather than coerced. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float] or None
|
Canonical quantiles, without modifying the supplied object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the policy is not a valid quantile pair. |