pytranskit.classification package

cdt_ns

class pytranskit.classification.cdt_ns.CDT_NS(num_classes, rm_edge=False)[source]

Bases: object

add_trans_samples(cdt_features)[source]
cdt_parallel(X)[source]
fit(Xtrain, Ytrain, no_deform_model=False)[source]

Fit linear model. :param Xtrain: 1D data for training. :type Xtrain: array-like, shape (n_samples, n_columns) :param Ytrain: Labels of the training samples. :type Ytrain: ndarray of shape (n_samples,) :param no_deform_model: default = False. :type no_deform_model: boolean flag; IF TRUE, no deformation model will be added

fun_cdt_batch(data)[source]
fun_cdt_single(sig1)[source]
predict(Xtest, use_gpu=False)[source]

Predict using the linear model :param Xtest: 1D data for testing. :type Xtest: array-like, shape (n_samples, n_columns) :param use_gpu: default = False. :type use_gpu: boolean flag; IF TRUE, use gpu for calculations

Returns:

Predicted target values per sample in Xtest.

Return type:

ndarray of shape (n_samples,)

rcdt_ns

class pytranskit.classification.rcdt_ns.RCDT_NS(num_classes, thetas=array([0.0, 4.0, 8.0, 12.0, 16.0, 20.0, 24.0, 28.0, 32.0, 36.0, 40.0, 44.0, 48.0, 52.0, 56.0, 60.0, 64.0, 68.0, 72.0, 76.0, 80.0, 84.0, 88.0, 92.0, 96.0, 100.0, 104.0, 108.0, 112.0, 116.0, 120.0, 124.0, 128.0, 132.0, 136.0, 140.0, 144.0, 148.0, 152.0, 156.0, 160.0, 164.0, 168.0, 172.0, 176.0]), rm_edge=False)[source]

Bases: object

add_trans_samples(rcdt_features)[source]
fit(Xtrain, Ytrain, no_deform_model=False)[source]

Fit linear model.

Parameters:
  • Xtrain (array-like, shape (n_samples, n_rows, n_columns)) – Image data for training.

  • Ytrain (ndarray of shape (n_samples,)) – Labels of the training images.

  • no_deform_model (boolean flag; IF TRUE, no deformation model will be added) – default = False.

fun_rcdt_batch(data)[source]
fun_rcdt_single(I)[source]
predict(Xtest, use_gpu=False)[source]

Predict using the linear model

Let \(B^k\) be the basis vectors of class \(k\), and \(x\) be the RCDT sapce feature vector of an input, the NS method performs classification by

\[arg\min_k \| B^k (B^k)^T x - x\|^2\]
Parameters:
  • Xtest (array-like, shape (n_samples, n_rows, n_columns)) – Image data for testing.

  • use_gpu (boolean flag; IF TRUE, use gpu for calculations) – default = False.

Returns:

Predicted target values per element in Xtest.

Return type:

ndarray of shape (n_samples,)

rcdt_parallel(X)[source]

rcdt_ns_3d

class pytranskit.classification.rcdt_ns_3d.RCDT_NS_3D(num_classes, Npoints=500, use_gpu=False, rm_edge=False)[source]

Bases: object

add_trans_samples(rcdt_features)[source]
fit(Xtrain, Ytrain, no_deform_model=False)[source]

Fit linear model. :param Xtrain: Image data for training. :type Xtrain: array-like, shape (n_samples, n_rows, n_columns, n_width) :param Ytrain: Labels of the training images. :type Ytrain: ndarray of shape (n_samples,) :param no_deform_model: default = False. :type no_deform_model: boolean flag; IF TRUE, no deformation model will be added

fun_rcdt_batch(data)[source]
fun_rcdt_single(I)[source]
predict(Xtest, use_gpu=False)[source]

Predict using the linear model :param Xtest: Image data for testing. :type Xtest: array-like, shape (n_samples, n_rows, n_columns, n_width) :param use_gpu: default = False. :type use_gpu: boolean flag; IF TRUE, use gpu for calculations

Returns:

Predicted target values per element in Xtest.

Return type:

ndarray of shape (n_samples,)

rcdt_parallel(X)[source]

scdt_nls

class pytranskit.classification.scdt_nls.SCDT_NLS(num_classes, rm_edge=False)[source]

Bases: object

calc_scdt(sig1, t1, s0, t0)[source]
enrichment(scdt_features, k)[source]
find_kN(X, y, k_range, n_range)[source]
fit(X, Y, Ttrain=None, no_local_enrichment=True)[source]

Fit SCDT-NLS. :param X: 1D data for training. :type X: array-like, shape (n_samples, n_columns) :param Y: Labels of the training samples. :type Y: ndarray of shape (n_samples,) :param Ttrain: domain for corresponding training signals. :type Ttrain: [optional] array-like, shape (n_samples, n_columns) :param no_local_enrichment: IF FALSE, apply deformation while searching k samples :type no_local_enrichment: [optional] boolean, default TRUE

predict(Xtest, Ttest=None, k=None, N=None)[source]

Predict using SCDT-NLS :param Xtest: 1D data for testing. :type Xtest: array-like, shape (n_samples, n_columns) :param Ttest: domain for corresponding test signals. :type Ttest: [optional] array-like, shape (n_samples, n_columns) :param k: :type k: [pre-tuned parameter] number of closest points to test sample :param N: :type N: [pre-tuned parameter] number of sinusoidal bases used for subspace enrrichment

Returns:

Predicted target values per sample in Xtest.

Return type:

ndarray of shape (n_samples,)

score(X, y)[source]

scdt_ns

class pytranskit.classification.scdt_ns.SCDT_NS(num_classes, rm_edge=False)[source]

Bases: object

add_trans_samples(scdt_features)[source]
calc_scdt(sig1, t1, s0, t0)[source]
fit(Xtrain, Ytrain, Ttrain=None, no_deform_model=True)[source]

Fit SCDT-NS. :param Xtrain: 1D data for training. :type Xtrain: array-like, shape (n_samples, n_columns) :param Ytrain: Labels of the training samples. :type Ytrain: ndarray of shape (n_samples,) :param Ttrain: domain for corresponding training signals. :type Ttrain: [optional] array-like, shape (n_samples, n_columns) :param no_deform_model: default = True. :type no_deform_model: [optional] boolean flag; IF TRUE, no deformation model will be added

predict(Xtest, Ttest=None, use_gpu=False)[source]

Predict using SCDT-NS :param Xtest: 1D data for testing. :type Xtest: array-like, shape (n_samples, n_columns) :param Ttest: domain for corresponding test signals. :type Ttest: [optional] array-like, shape (n_samples, n_columns) :param use_gpu: default = False. :type use_gpu: [optional] boolean flag; IF TRUE, use gpu for calculations

Returns:

Predicted target values per sample in Xtest.

Return type:

ndarray of shape (n_samples,)

utils

pytranskit.classification.utils.dataset_config(dataset)[source]
pytranskit.classification.utils.load_data(dataset, num_classes, datadir='data')[source]
pytranskit.classification.utils.load_data_1D(dataset, num_classes, datadir='data')[source]
pytranskit.classification.utils.load_data_3D(dataset, num_classes, datadir='data')[source]
pytranskit.classification.utils.new_index_matrix(max_index, n_samples_perclass, num_classes, repeat, y_train)[source]
pytranskit.classification.utils.take_samples(data, labels, index, num_classes)[source]
pytranskit.classification.utils.take_train_samples(x_train, y_train, n_samples_perclass, num_classes, repeat)[source]
pytranskit.classification.utils.take_train_val_samples(x_train, y_train, n_samples_perclass, num_classes, repeat)[source]