MantisClassifier
MantisClassifier
- class MantisClassifier(checkpoint='paris-noah/MantisV2', model_version='v2', fine_tuning_type='full', seq_len=512, num_epochs=100, batch_size=64, predict_batch_size=256, base_learning_rate=0.0002, learning_rate_adjusting=True, device='auto', ignore_deps=False)[source]
Time series classifier using the Mantis foundation model.
Mantis [1] is a family of lightweight, calibrated foundation models designed for time series classification. This adapter wraps Mantis’s
MantisTrainerscikit-learn-like interface as an sktimeBaseClassifier.Two usage modes are supported:
Fine-tuning (default): the Mantis backbone and/or classification head are fine-tuned on the supplied training data.
Zero-shot (
fine_tuning_type="head"with very few epochs): only the linear classification head is trained on top of frozen Mantis embeddings.
- Parameters:
- checkpointstr or None, default=”paris-noah/MantisV2”
Hugging Face checkpoint to load via
network.from_pretrained. Supported checkpoints:"paris-noah/MantisV2"(MantisV2 backbone — recommended)"paris-noah/MantisPlus"(MantisV1+ backbone)"paris-noah/Mantis-8M"(MantisV1 backbone, smallest)
Pass
Noneto use a randomly initialized backbone (no pre-training).- model_version{“v2”, “v1”}, default=”v2”
Mantis architecture family.
"v2"— use with"paris-noah/MantisV2"."v1"— use with"paris-noah/Mantis-8M"or"paris-noah/MantisPlus".
- fine_tuning_type{“full”, “head”, “adapter_head”, “scratch”}, default=”full”
Which parameters to update during training:
"full"— fine-tune the entire network (best accuracy)."head"— train only the classification head on frozen embeddings (fastest, suitable as a zero-shot baseline)."adapter_head"— train a learnable adapter and the head."scratch"— train everything from random initialisation.
- seq_lenint, default=512
Sequence length passed to Mantis (must be a multiple of 32). Input time series that differ in length are resized to this value via linear interpolation.
- num_epochsint, default=100
Number of fine-tuning epochs.
- batch_sizeint, default=64
Batch size used during training.
- predict_batch_sizeint, default=256
Batch size used during inference.
- base_learning_ratefloat, default=2e-4
Initial learning rate for the AdamW optimizer.
- learning_rate_adjustingbool, default=True
Whether to use the cosine learning-rate schedule built into Mantis.
- devicestr, default=”auto”
Torch device.
"auto"resolves to"cuda"when a GPU is available, otherwise"cpu".- ignore_depsbool, default=False
Skip soft-dependency checks (useful for testing without
mantis-tsfminstalled).
- Attributes:
is_fittedWhether
fithas been called.
References
[1]Feofanov et al., “Mantis: Lightweight Calibrated Foundation Model for User-Friendly Time Series Classification”, 2025. https://arxiv.org/abs/2502.15637
Examples
>>> from sktime.classification.foundation_models.mantis import MantisClassifier >>> from sktime.datasets import load_unit_test >>> X_train, y_train = load_unit_test(split="train", return_type="numpy3d") >>> X_test, y_test = load_unit_test(split="test", return_type="numpy3d") >>> clf = MantisClassifier(num_epochs=5, batch_size=16) >>> clf.fit(X_train, y_train) MantisClassifier(...) >>> y_pred = clf.predict(X_test)
Methods
check_is_fitted([method_name])Check if the estimator has been fitted.
clone()Obtain a clone of the object with same hyper-parameters and config.
clone_tags(estimator[, tag_names])Clone tags from another object as dynamic override.
create_test_instance([parameter_set])Construct an instance of the class, using first test parameter set.
create_test_instances_and_names([parameter_set])Create list of all test instances and a list of names for them.
fit(X, y)Fit time series classifier to training data.
fit_predict(X, y[, cv, change_state])Fit and predict labels for sequences in X.
fit_predict_proba(X, y[, cv, change_state])Fit and predict labels probabilities for sequences in X.
get_class_tag(tag_name[, tag_value_default])Get class tag value from class, with tag level inheritance from parents.
get_class_tags()Get class tags from class, with tag level inheritance from parent classes.
get_config()Get config flags for self.
get_fitted_params([deep])Get fitted parameters.
get_param_defaults()Get object's parameter defaults.
get_param_names([sort])Get object's parameter names.
get_params([deep])Get a dict of parameters values for this object.
get_tag(tag_name[, tag_value_default, ...])Get tag value from instance, with tag level inheritance and overrides.
get_tags()Get tags from instance, with tag level inheritance and overrides.
get_test_params([parameter_set])Return testing parameter settings for the estimator.
is_composite()Check if the object is composed of other BaseObjects.
load_from_path(serial)Load object from file location.
load_from_serial(serial)Load object from serialized memory container.
predict(X)Predicts labels for sequences in X.
predict_proba(X)Predicts labels probabilities for sequences in X.
reset()Reset the object to a clean post-init state.
save([path, serialization_format])Save serialized self to bytes-like object or to (.zip) file.
score(X, y)Scores predicted labels against ground truth labels on X.
set_config(**config_dict)Set config flags to given values.
set_params(**params)Set the parameters of this object.
set_random_state([random_state, deep, ...])Set random_state pseudo-random seed parameters for self.
set_tags(**tag_dict)Set instance level tag overrides to given values.

