Models¶
DirichletModel¶
-
class
DirichletModel
(*args, **kwargs)[source]¶ Bases:
cardio.models.dirichlet_model.dirichlet_model.DirichletModelBase
Dirichlet model with overloaded train and predict methods.
train
method is identical toDirichletModelBase.train
, but also acceptsargs
andkwargs
.predict
method splits the resulting tensor forparameters
fetch usingsplit_indices
. It also splits and aggregates results forpredictions
fetch to get class probabilities.
-
predict
(fetches=None, feed_dict=None, split_indices=None)[source]¶ Get predictions on the data provided.
Parameters: - fetches (tf.Operation or tf.Tensor or array-like sequence of them) – Graph element to evaluate.
If
fetches
containsparameters
tensor, the corresponding output is split usingsplit_indices
. Iffetches
containspredictions
tensor, the corresponding output is split usingsplit_indices
and then aggregated to get class probabilities. - feed_dict (dict) – A dictionary that maps graph elements to values.
- split_indices (1-D ndarray) – Indices used to split
parameters
andpredictions
tensors.
Returns: output (same structure as
fetches
) – Calculated values for each element infetches
.- fetches (tf.Operation or tf.Tensor or array-like sequence of them) – Graph element to evaluate.
If
-
train
(fetches=None, feed_dict=None, use_lock=False, *args, **kwargs)[source]¶ Train the model with the data provided.
The only difference between
DirichletModel.train
andTFModel.train
is that the former also acceptsargs
andkwargs
.Parameters: Returns: output (same structure as
fetches
) – Calculated values for each element infetches
.
DirichletModelBase¶
-
class
DirichletModelBase
(*args, **kwargs)[source]¶ Bases:
cardio.dataset.dataset.models.tf.base.TFModel
Dirichlet model class.
The model predicts Dirichlet distribution parameters from which class probabilities are sampled.
Notes
Configuration
Model config must contain the following keys:
- input_shape : tuple
Input signals’s shape without the batch dimension.
- class_names : array_like
Class names.
- loss :
None
The model has a predefined loss, so you should leave it
None
.
- loss :
HMModel¶
-
class
HMModel
(*args, **kwargs)[source]¶ Bases:
cardio.dataset.dataset.models.base.BaseModel
Hidden Markov Model.
This implementation is based on
hmmlearn
API. It is supposed that estimators ofHMModel
are model classes ofhmmlearn
.-
train
(X, lengths=None, *args, **kwargs)[source]¶ Train the model using data provided.
Parameters: - X (array-like) – A matrix of observations. Should be of shape (n_samples, n_features).
- lengths (array-like of integers optional) – If present, should be of shape (n_sequences, ).
Lengths of the individual sequences in
X
. The sum of these should ben_samples
.
Notes
For more details and other parameters look at the documentation for the estimator used.
-
predict
(X, lengths=None, *args, **kwargs)[source]¶ Make prediction with the data provided.
Parameters: - X (array-like) – A matrix of observations. Should be of shape (n_samples, n_features).
- lengths (array-like of integers optional) – If present, should be of shape (n_sequences, ).
Lengths of the individual sequences in
X
. The sum of these should ben_samples
.
Returns: output (array) – Labels for each sample of X.
Notes
For more details and other parameters look at the documentation for the estimator used.
-