Pipelines & Preprocessing¶
Composition¶
online_cp.pipeline.Transformer
¶
Bases: ABC
Base class for conformal-safe feature transformers.
Subclasses must implement :meth:transform (batch) and
:meth:transform_one (single vector) and set the mode attribute.
Stateful transformers should also override :meth:fit to compute
parameters from a batch of training examples.
The | operator composes a transformer with another transformer or a
conformal predictor into a :class:Pipeline. The + operator
composes two transformers into a :class:TransformerUnion.
Source code in src/online_cp/pipeline.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 | |
fit(X: NDArray) -> None
¶
Fit the transformer on a batch of training examples.
The default implementation marks the transformer as fitted and returns
(suitable for stateless mode="fixed" transformers). Stateful
transformers such as :class:~online_cp.preprocessing.StandardScaler
override this method to compute and store their parameters; they should
call super().fit(X) to keep the _fitted flag up to date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray of shape (n, d)
|
Training batch after preceding transformers have been applied. |
required |
Source code in src/online_cp/pipeline.py
transform(X: NDArray) -> NDArray
abstractmethod
¶
Apply the transformation to a batch of examples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray of shape (n, d)
|
Input matrix. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Transformed matrix, same number of rows as X. |
Source code in src/online_cp/pipeline.py
transform_one(x: NDArray) -> NDArray
abstractmethod
¶
Apply the transformation to a single example.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray of shape (d,)
|
Input vector. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Transformed vector. |
Source code in src/online_cp/pipeline.py
__or__(other: Any) -> Pipeline
¶
Build a :class:Pipeline via the | operator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Transformer or conformal predictor
|
The next step. If other is already a :class: |
required |
Returns:
| Type | Description |
|---|---|
Pipeline
|
|
Source code in src/online_cp/pipeline.py
__add__(other: Transformer) -> TransformerUnion
¶
Build a :class:TransformerUnion via the + operator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Transformer
|
The transformer whose output will be concatenated with this one. |
required |
Returns:
| Type | Description |
|---|---|
TransformerUnion
|
|
Source code in src/online_cp/pipeline.py
online_cp.pipeline.FuncTransformer
¶
Bases: Transformer
Apply a fixed, stateless callable to every example.
Because the function is data-independent, it is always conformally safe: exchangeability of the example sequence is preserved.
The :meth:fit method is a no-op (inherited from :class:Transformer).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
callable
|
A callable that accepts an ndarray and returns an ndarray of the same
or different shape. It must work on both a 2-D batch |
required |
Examples:
>>> import numpy as np
>>> from online_cp import FuncTransformer
>>> ft = FuncTransformer(np.log1p)
>>> ft.transform_one(np.array([0.0, 1.0, 2.0]))
array([0. , 0.69314718, 1.09861229])
Source code in src/online_cp/pipeline.py
online_cp.pipeline.TransformerUnion
¶
Bases: Transformer
Concatenate the outputs of several transformers along the feature axis.
Each constituent transformer is applied to the same input; their outputs
are column-stacked to produce a wider feature matrix. All constituent
transformers are fitted independently during
:meth:~Pipeline.learn_initial_training_set.
The union's mode is "fixed" when all constituents are fixed, and
"frozen" otherwise (most restrictive member wins).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*transformers
|
Transformer
|
Two or more transformers whose outputs will be concatenated. |
()
|
Examples:
>>> import numpy as np
>>> from online_cp import FuncTransformer, Select, TransformerUnion
>>> # Build polynomial-like features: [x, x**2]
>>> union = FuncTransformer(lambda x: x) + FuncTransformer(lambda x: x ** 2)
>>> X = np.arange(6, dtype=float).reshape(3, 2)
>>> union.fit(X)
>>> union.transform(X).shape
(3, 4)
Source code in src/online_cp/pipeline.py
online_cp.pipeline.Select
¶
Bases: Transformer
Keep a subset of input columns.
This is a stateless (mode="fixed"), always-safe transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
array-like of int
|
Column indices to retain, in the desired output order. |
required |
Examples:
>>> import numpy as np
>>> from online_cp import Select
>>> sel = Select([0, 2])
>>> X = np.arange(12, dtype=float).reshape(4, 3)
>>> sel.fit(X)
>>> sel.transform(X)
array([[ 0., 2.],
[ 3., 5.],
[ 6., 8.],
[ 9., 11.]])
Source code in src/online_cp/pipeline.py
online_cp.pipeline.Discard
¶
Bases: Transformer
Drop a subset of input columns, keeping all others.
This is a stateless (mode="fixed"), always-safe transform.
The remaining columns are returned in their original order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
array-like of int
|
Column indices to discard. |
required |
Examples:
>>> import numpy as np
>>> from online_cp import Discard
>>> drop = Discard([1])
>>> X = np.arange(12, dtype=float).reshape(4, 3)
>>> drop.fit(X)
>>> drop.transform(X)
array([[ 0., 2.],
[ 3., 5.],
[ 6., 8.],
[ 9., 11.]])
Source code in src/online_cp/pipeline.py
online_cp.pipeline.Pipeline
¶
A conformal-safe pipeline of transformers ending in a conformal predictor.
The pipeline re-exposes the full online-cp predictor API so that a
composed object is a drop-in replacement for any bare predictor in
:func:~online_cp.evaluate.progressive_val or
:func:~online_cp.evaluate.iter_progressive_val.
Validity guarantee. By default the pipeline only accepts transformers
whose mode is "fixed" or "frozen"; both regimes preserve
conformal validity (ALRW2 §4.5 / §4.7). Transformers with any other mode
(e.g. "incremental") break the exchangeability of the example sequence
and are rejected at construction time unless you explicitly pass
unsafe_incremental=True — which opts out of the finite-sample validity
guarantee.
Bare-callable auto-wrap. If a transformer step is a plain callable
(rather than a :class:Transformer instance), it is silently wrapped in a
:class:FuncTransformer. Non-callable, non-Transformer steps raise a
:exc:TypeError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*steps
|
Any
|
One or more transformer steps followed by exactly one conformal
predictor. At least two steps are required. Each transformer step
may be a :class: |
()
|
unsafe_incremental
|
bool
|
Set to |
False
|
Examples:
>>> import numpy as np
>>> from online_cp import Pipeline, FuncTransformer, ConformalRidgeRegressor
>>> pipe = Pipeline(FuncTransformer(np.log1p), ConformalRidgeRegressor(a=1.0))
>>> # Equivalent — bare callable is auto-wrapped:
>>> pipe2 = Pipeline(np.log1p, ConformalRidgeRegressor(a=1.0))
>>> # Operator sugar:
>>> pipe3 = FuncTransformer(np.log1p) | ConformalRidgeRegressor(a=1.0)
Source code in src/online_cp/pipeline.py
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 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 | |
learn_initial_training_set(X: NDArray, y: NDArray) -> None
¶
Fit all transformers then delegate to the estimator's initial fit.
For each transformer in order: fit(Xt) is called to let stateful
transformers (e.g. frozen scalers) compute their parameters, then
transform(Xt) is applied to produce the input for the next step.
The estimator receives the fully-transformed Xt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray of shape (n, d)
|
|
required |
y
|
ndarray of shape (n,)
|
|
required |
Source code in src/online_cp/pipeline.py
learn_one(x: NDArray, y: Any, precomputed: Any = None) -> None
¶
Transform x and delegate to the estimator's online update.
precomputed is always dropped at the pipeline boundary: the
transform changes the geometry so any cached intermediate is invalid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray of shape (d,)
|
|
required |
y
|
label / target value
|
|
required |
precomputed
|
ignored
|
Accepted for API compatibility; always discarded. |
None
|
Source code in src/online_cp/pipeline.py
predict(x: NDArray, **kwargs: Any) -> Any
¶
Transform x then call estimator.predict.
All keyword arguments (epsilon, return_p_values, bounds,
return_update, …) are forwarded unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray of shape (d,)
|
|
required |
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in src/online_cp/pipeline.py
predict_cpd(x: NDArray, **kwargs: Any) -> Any
¶
Transform x then call estimator.predict_cpd.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray of shape (d,)
|
|
required |
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in src/online_cp/pipeline.py
compute_p_value(x: NDArray, y: Any, **kwargs: Any) -> Any
¶
Transform x then call estimator.compute_p_value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray of shape (d,)
|
|
required |
y
|
label / target value
|
|
required |
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in src/online_cp/pipeline.py
summary() -> dict
¶
Return a human-readable summary of the pipeline structure.
Returns:
| Type | Description |
|---|---|
dict
|
A dict with the following keys:
|
Examples:
>>> import numpy as np
>>> from online_cp import Pipeline, FuncTransformer, ConformalRidgeRegressor
>>> pipe = Pipeline(FuncTransformer(np.abs), ConformalRidgeRegressor(a=1.0))
>>> pipe.summary()["n_steps"]
2
Source code in src/online_cp/pipeline.py
__or__(other: Any) -> Pipeline
¶
save(filepath: str | os.PathLike, *, compress: int = 3) -> None
¶
Save this pipeline to filepath.
All transformers and the estimator are serialised with joblib/pickle.
:class:FuncTransformer functions must be module-level named
functions (not lambdas); lambdas will raise
:class:~online_cp.SerializationError at pickle time.
.. warning:: Only load files from trusted sources.
Source code in src/online_cp/pipeline.py
load(filepath: str | os.PathLike) -> Pipeline
classmethod
¶
Load a pipeline from filepath.
.. warning:: Only load files from trusted sources.
Source code in src/online_cp/pipeline.py
Preprocessing¶
online_cp.preprocessing.StandardScaler
¶
Bases: Transformer
Standardise features to zero mean and unit variance.
Parameters are computed once from the initial training batch (via
:meth:fit) and held constant thereafter (mode="frozen"). This
preserves training-conditional conformal validity.
Zero-variance features are left unchanged (their scale is set to 1 to avoid division by zero).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
with_mean
|
bool
|
Subtract the training mean from each feature. |
True
|
with_std
|
bool
|
Divide each feature by its training standard deviation. |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
mean_ |
ndarray of shape (d,) or None
|
Per-feature training mean. |
scale_ |
ndarray of shape (d,) or None
|
Per-feature training standard deviation (with zero-variance guard).
|
Examples:
>>> import numpy as np
>>> from online_cp import StandardScaler, Pipeline, ConformalRidgeRegressor
>>> rng = np.random.default_rng(42)
>>> X = rng.normal(loc=5.0, scale=10.0, size=(50, 3))
>>> y = X[:, 0] + rng.normal(scale=0.5, size=50)
>>> pipe = StandardScaler() | ConformalRidgeRegressor(a=1.0, epsilon=0.1)
>>> pipe.learn_initial_training_set(X, y)
>>> interval = pipe.predict(X[0], epsilon=0.1)
Source code in src/online_cp/preprocessing.py
fit(X: NDArray) -> None
¶
Compute mean and standard deviation from X.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray of shape (n, d)
|
Training batch. |
required |
Source code in src/online_cp/preprocessing.py
online_cp.preprocessing.MinMaxScaler
¶
Bases: Transformer
Scale features to a fixed range [feature_range[0], feature_range[1]].
Parameters are computed once from the initial training batch (via
:meth:fit) and held constant thereafter (mode="frozen").
Features whose training range is zero (constant column) are mapped to the
lower bound of feature_range without raising an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feature_range
|
tuple of (float, float)
|
Target range for the scaled features. |
(0, 1)
|
Attributes:
| Name | Type | Description |
|---|---|---|
data_min_ |
ndarray of shape (d,) or None
|
Per-feature minimum over the training set. |
data_range_ |
ndarray of shape (d,) or None
|
Per-feature |
Examples:
>>> import numpy as np
>>> from online_cp import MinMaxScaler, Pipeline, ConformalRidgeRegressor
>>> rng = np.random.default_rng(0)
>>> X = rng.uniform(low=-100.0, high=100.0, size=(50, 2))
>>> y = X[:, 0] * 0.5 + rng.normal(scale=1.0, size=50)
>>> pipe = MinMaxScaler() | ConformalRidgeRegressor(a=1.0, epsilon=0.1)
>>> pipe.learn_initial_training_set(X, y)
>>> interval = pipe.predict(X[0], epsilon=0.1)
Source code in src/online_cp/preprocessing.py
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 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 | |
fit(X: NDArray) -> None
¶
Compute min and range from X.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray of shape (n, d)
|
Training batch. |
required |
Source code in src/online_cp/preprocessing.py
online_cp.preprocessing.PCA
¶
Bases: Transformer, SerializableMixin
Rotate features into their principal-component basis.
Parameters are computed once from the initial training batch (via
:meth:fit) and held constant thereafter (mode="frozen"), or
recomputed at each prediction from the augmented bag (mode="bag").
mode="frozen" preserves training-conditional conformal validity
(parameters are a fixed function of the training data). mode="bag"
recomputes the rotation from the label-free augmented bag [X_train,
x_test] at each prediction, preserving exact finite-sample conformal
validity at the cost of O(n·d²+d³) per predict.
The transformation is the standard PCA projection: subtract the training mean, then project onto the top-k eigenvectors of the (unbiased) sample covariance matrix. Eigenvectors are ordered by descending explained variance and given a deterministic sign (largest-magnitude element positive).
Intended use-case: axis-aligning features before
:class:~online_cp.mondrian.MondrianConformalRegressor /
:class:~online_cp.mondrian.MondrianConformalClassifier. Mondrian
methods partition the feature space by hyperplanes; after PCA rotation the
axes align with the directions of greatest variance, yielding tighter and
more balanced partitions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_components
|
int or None
|
Number of principal components to retain. |
None
|
mode
|
('frozen', 'bag')
|
See module docstring for the two operation modes. |
"frozen"
|
Attributes:
| Name | Type | Description |
|---|---|---|
n_ |
int or None
|
Number of samples seen during :meth: |
mean_ |
ndarray of shape (d,) or None
|
Per-feature training mean. |
components_ |
ndarray of shape (k, d) or None
|
Principal components as row vectors (sorted by descending variance). |
singular_values_ |
ndarray of shape (k,) or None
|
Square roots of the retained eigenvalues (≈ singular values of the
centred data matrix, up to the |
Examples:
>>> import numpy as np
>>> from online_cp import PCA, Pipeline, ConformalRidgeRegressor
>>> rng = np.random.default_rng(0)
>>> X = rng.normal(loc=[0.0, 0.0], scale=[10.0, 0.1], size=(60, 2))
>>> y = X[:, 0] * 0.5 + rng.normal(scale=0.1, size=60)
>>> pipe = PCA() | ConformalRidgeRegressor(a=1.0, epsilon=0.1)
>>> pipe.learn_initial_training_set(X, y)
>>> interval = pipe.predict(X[0], epsilon=0.1)
Source code in src/online_cp/preprocessing.py
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 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | |
fit(X: NDArray) -> None
¶
Compute principal components from X.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray of shape (n, d)
|
Training batch. Requires |
required |
Source code in src/online_cp/preprocessing.py
transform(X: NDArray) -> NDArray
¶
Project X onto the principal-component basis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray of shape (n, d)
|
|
required |
Returns:
| Type | Description |
|---|---|
ndarray of shape (n, k)
|
|
Source code in src/online_cp/preprocessing.py
transform_one(x: NDArray) -> NDArray
¶
Project a single feature vector x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray of shape (d,)
|
|
required |
Returns:
| Type | Description |
|---|---|
ndarray of shape (k,)
|
|
Source code in src/online_cp/preprocessing.py
online_cp.preprocessing.SVD
¶
Bases: Transformer, SerializableMixin
Project features onto the top-k right singular vectors of X.
Computes the eigen-decomposition of the (optionally centred) Gram matrix
X^T X and projects data onto the leading eigenvectors. This is
equivalent to truncated SVD on the data matrix and is the standard
approach for dimensionality reduction and multicollinearity removal before
ridge-based methods.
When center=True the Gram matrix is built from the mean-centred data
X - mean(X), making this identical to :class:PCA in the projected
subspace. Use center=False when the data is already mean-zero or when
you want the uncentred factorisation (e.g. for non-negative data).
Intended use-case: dimensionality reduction and multicollinearity
removal before :class:~online_cp.cps.RidgePredictionMachine and
:class:~online_cp.regressors.ConformalRidgeRegressor. Reducing d to
k < d speeds up the O(d³) matrix inversion and stabilises it when
features are near-collinear.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_components
|
int or None
|
Number of right singular vectors to retain. |
None
|
mode
|
('frozen', 'bag')
|
See module docstring for the two operation modes. |
"frozen"
|
center
|
bool
|
If |
True
|
Attributes:
| Name | Type | Description |
|---|---|---|
n_ |
int or None
|
Number of samples seen during :meth: |
mean_ |
ndarray of shape (d,) or None
|
Per-feature training mean. |
components_ |
ndarray of shape (k, d) or None
|
Right singular vectors as row vectors (sorted by descending singular value). |
singular_values_ |
ndarray of shape (k,) or None
|
Retained singular values (square roots of the retained eigenvalues of the Gram matrix). |
Examples:
>>> import numpy as np
>>> from online_cp import SVD, Pipeline, ConformalRidgeRegressor
>>> rng = np.random.default_rng(1)
>>> X = rng.normal(size=(50, 5))
>>> X[:, 2] = X[:, 0] + 0.01 * rng.normal(size=50) # near-collinear
>>> y = X[:, 0] - X[:, 1] + rng.normal(scale=0.1, size=50)
>>> pipe = SVD(n_components=3) | ConformalRidgeRegressor(a=1e-3, epsilon=0.1)
>>> pipe.learn_initial_training_set(X, y)
>>> interval = pipe.predict(X[0], epsilon=0.1)
Source code in src/online_cp/preprocessing.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | |
fit(X: NDArray) -> None
¶
Compute right singular vectors from X.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray of shape (n, d)
|
Training batch. Requires |
required |
Source code in src/online_cp/preprocessing.py
transform(X: NDArray) -> NDArray
¶
Project X onto the retained right singular vectors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray of shape (n, d)
|
|
required |
Returns:
| Type | Description |
|---|---|
ndarray of shape (n, k)
|
|
Source code in src/online_cp/preprocessing.py
transform_one(x: NDArray) -> NDArray
¶
Project a single feature vector x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray of shape (d,)
|
|
required |
Returns:
| Type | Description |
|---|---|
ndarray of shape (k,)
|
|