pyrregular.models.ncde
NCDE. Neural CDE for time series classification.
Module Attributes
This pipeline applies NeuralCDE. |
Classes
|
A minimal scikit-learn API wrapper for a Neural CDE multiclass classifier. |
- class pyrregular.models.ncde.NeuralCDEClassifier(hidden_size=8, width_size=32, depth=1, max_iter=50, lr=0.001, seed=0, print_step=10, validate=True, patience_lr=10, patience_es=20, lr_reduce_factor=0.5, solver=Euler(), max_steps=4096, reset_loss_after_lr_reduction=False)[source]
Bases:
BaseEstimator
,ClassifierMixin
A minimal scikit-learn API wrapper for a Neural CDE multiclass classifier.
- X.shape = (n_instances, n_signals, n_timesteps)
X[:, :-1, :] => data channels
X[:, -1, :] => the time array for each instance
y.shape = (n_instances,) with integer labels in {0, 1, …, n_classes-1}.
- Parameters:
hidden_size (int) – Number of hidden units in the Neural CDE.
width_size (int) – Width of the hidden layers.
depth (int) – Number of layers in the Neural CDE.
max_iter (int) – Maximum number of training iterations.
lr (float) – Learning rate for the optimizer.
seed (int) – Random seed for reproducibility.
print_step (int) – Frequency of printing training progress.
validate (bool) – Whether to use validation during training.
patience_lr (int) – Number of iterations to wait before reducing the learning rate if no improvement.
patience_es (int) – Number of iterations to wait before early stopping if no improvement.
lr_reduce_factor (float) – Factor by which to reduce the learning rate.
solver (diffrax.AbstractSolver) – Numerical solver for the ODE.
max_steps (int) – Maximum number of steps for the ODE solver.
reset_loss_after_lr_reduction (bool) – Whether to reset loss tracking after learning rate reduction.
- predict(X)[source]
Predict the most likely class for each instance in X. Return shape: (n_instances,).
- predict_proba(X)[source]
Predict class probabilities for each instance in X. Return shape: (n_instances, n_classes).
- score(X, y, sample_weight=None)[source]
Return the mean accuracy on the given test data and labels.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') NeuralCDEClassifier
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline
. Otherwise it has no effect.- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weight
parameter inscore
.- Returns:
self – The updated object.
- Return type:
object
- pyrregular.models.ncde.ncde_pipeline = NeuralCDEClassifier(lr=0.01, max_iter=1000, max_steps=100, patience_es=200, patience_lr=50)
This pipeline applies NeuralCDE.