TimeSeriesSVC
TimeSeriesSVC
- class TimeSeriesSVC(kernel=None, kernel_params=None, kernel_mtype=None, C=1, shrinking=True, probability=False, tol=0.001, cache_size=200, class_weight=None, verbose=False, max_iter=-1, decision_function_shape='ovr', break_ties=False, random_state=None)[source]
Support Vector Classifier, for time series kernels.
An adapted version of the scikit-learn SVC for time series data.
Any sktime pairwise transformers are supported as kernels, including time series kernels and standard kernels on “flattened” time series.
Caveat: typically, SVC literature assumes kernels to be positive semi-definite. However, any pairwise transformer can be passed as kernel, including distances. This will still produce classification results, which may or may not be performant.
- Parameters:
- kernelpairwise panel transformer or callable, optional, default see below
pairwise panel transformer inheriting from
BasePairwiseTransformerPanel, or callable, must be of signature(X: Panel, X2: Panel) -> np.ndarrayoutput must be mxn array ifXis Panel of m Series,X``2 of n Series if ``distance_mtypeis not set, must be able to takeX,X2which arepd_multiindexandnumpy3Dmtype default = mean Euclidean kernel, same asAggrDist(RBF()), whereAggrDistis fromsktimeandRBFfromsklearn- kernel_paramsdict, optional. default = None.
dictionary for distance parameters, in case that distance is a callable
- kernel_mtypestr, or list of str optional. default = None.
mtype that
kernelexpects for X and X2, if a callable only set this ifkernelis notBasePairwiseTransformerPaneldescendant- Cfloat, default=1.0
Regularization parameter. The strength of the regularization is inversely proportional to C. Must be strictly positive. The penalty is a squared l2 penalty.
- shrinkingbool, default=True
Whether to use the shrinking heuristic.
- probabilitybool, default=False
Whether to enable probability estimates. This must be enabled prior to calling
fit, will slow down that method as it internally uses 5-fold cross-validation, andpredict_probamay be inconsistent withpredict.- tolfloat, default=1e-3
Tolerance for stopping criterion.
- cache_sizefloat, default=200
Specify the size of the kernel cache (in MB).
- class_weightdict or ‘balanced’, default=None
Set the parameter C of class i to class_weight[i]*C for SVC. If not given, all classes are supposed to have weight one. The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as
n_samples / (n_classes * np.bincount(y)).- verbosebool, default=False
Enable verbose output. Note that this setting takes advantage of a per-process runtime setting in libsvm that, if enabled, may not work properly in a multithreaded context.
- max_iterint, default=-1
Hard limit on iterations within solver, or -1 for no limit.
- decision_function_shape
{'ovo', 'ovr'}, default=’ovr’ Whether to return a one-vs-rest (‘ovr’) decision function of shape (n_samples, n_classes) as all other classifiers, or the original one-vs-one (‘ovo’) decision function of libsvm which has shape (n_samples, n_classes * (n_classes - 1) / 2). However, one-vs-one (‘ovo’) is always used as multi-class strategy. The parameter is ignored for binary classification.
- break_tiesbool, default=False
If true,
decision_function_shape='ovr', and number of classes > 2, predict will break ties according to the confidence values of decision_function; otherwise the first class among the tied classes is returned. Please note that breaking ties comes at a relatively high computational cost compared to a simple predict.- random_stateint, RandomState instance or None, default=None
Controls the pseudo random number generation for shuffling the data for probability estimates. Ignored when
probabilityis False. Pass an int for reproducible output across multiple function calls.
- Attributes:
is_fittedWhether
fithas been called.
Examples
>>> from sktime.classification.kernel_based import TimeSeriesSVC >>> from sklearn.gaussian_process.kernels import RBF >>> from sktime.dists_kernels import AggrDist >>> from sktime.datasets import load_unit_test >>> X_train, y_train = load_unit_test(return_X_y=True, split="train") >>> X_test, y_test = load_unit_test(return_X_y=True, split="test") >>> >>> mean_gaussian_tskernel = AggrDist(RBF()) >>> classifier = TimeSeriesSVC(kernel=mean_gaussian_tskernel) >>> classifier.fit(X_train, y_train) TimeSeriesSVC(...) >>> y_pred = classifier.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.

