TimeSeriesSVC
Support Vector Classifier, for time series kernels.
Quickstart
from sktime.classification.kernel_based import TimeSeriesSVC
estimator = 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)Parameters(14)
- 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.
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)