CNTCClassifier
Contextual Time-series Neural Classifier (CNTC), as described in [1].
Quickstart
from sktime.classification.deep_learning.cntc import CNTCClassifier
estimator = CNTCClassifier(n_epochs=2000, batch_size=16, filter_sizes=(16, 8), kernel_sizes=(1, 1), rnn_size=64, lstm_size=8, dense_size=64, dropout=(0.2, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1), callbacks=None, verbose=False, loss='categorical_crossentropy', metrics=None, random_state=0, activation='softmax', activation_attention='sigmoid', activation_hidden='relu')Parameters(17)
- activationstring or a tf callable, default=”softmax”
Activation function used in the output layer. List of available activation functions: https://keras.io/api/layers/activations/
- activation_attentionstring, default = “sigmoid”
Activation function inside the self attention module; List of available keras activation functions: https://keras.io/api/layers/activations/
- activation_hiddenstring or a tf callable, default=”relu”
Activation function used in the hidden layers. List of available activation functions: https://keras.io/api/layers/activations/
- n_epochsint, default = 2000
- the number of epochs to train the model
- batch_sizeint, default = 16
- the number of samples per gradient update.
- filter_sizestuple of shape (2), default = (16, 8)
- filter sizes for CNNs in CCNN arm.
- kernel_sizestwo-tuple, default = (1, 1)
- the length of the 1D convolution window for CNNs in CCNN arm.
- rnn_sizeint, default = 64
- number of rnn units in the CCNN arm.
- lstm_sizeint, default = 8
- number of lstm units in the CLSTM arm.
- dense_sizeint, default = 64
- dimension of dense layer in CNTC.
- dropoutfloat or tuple of floats, default = (0.2, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1)
dropout rate(s), in the range [0, 1). If a single float is provided, the same dropout rate is applied to all layers. If a tuple is provided, it should have 7 values corresponding to: (conv1_dropout, rnn1_dropout, conv2_dropout, lstm_dropout,
avg_dropout, att_dropout, mlp_dropout)
where mlp_dropout is applied to both MLP layers.
- random_stateint or None, default=None
- Seed for random number generation.
- verboseboolean, default = False
- whether to output extra information
- lossstring, default=”mean_squared_error”
- fit parameter for the keras model
- optimizerkeras.optimizer, default=keras.optimizers.Adam(),
- metricslist of strings, default=[“accuracy”],
- callbackslist of keras.callbacks, default = None,
Examples
>>> from sktime.classification.deep_learning.cntc import CNTCClassifier
>>> from sktime.datasets import load_unit_test
>>> X_train, y_train = load_unit_test (split = "train", return_X_y = True)
>>> X_test, y_test = load_unit_test (split = "test", return_X_y = True)
>>> cntc = CNTCClassifier ()
>>> cntc. fit (X_train, y_train) CNTCClassifier(
... )References
- [1 ] Network originally defined in: @article{FULLAHKAMARA202057, title = {Combining contextual neural networks for time series classification}, journal = {Neurocomputing}, volume = {384}, pages = {57-66}, year = {2020}, issn = {0925-2312}, doi = { https://doi.org/10.1016/j.neucom.2019.10.113 }, url = { https://www.sciencedirect.com/science/article/pii/S0925231219316364 }, author = {Amadu {Fullah Kamara} and Enhong Chen and Qi Liu and Zhen Pan}, keywords = {Time series classification, Contextual convolutional neural networks, Contextual long short-term memory, Attention, Multilayer perceptron}, }