sssm.sssm_core.model#

Classes#

Config

Context_Cont_configs

Model

Mixin class for all classifiers in scikit-learn.

TC

augmentations

base_Model

Base class for all neural network modules.

Module Contents#

class sssm.sssm_core.model.Config[source]#

Bases: object

class sssm.sssm_core.model.Context_Cont_configs[source]#

Bases: object

class sssm.sssm_core.model.Model(device='cuda', model_name='model.pt', model_path=None)[source]#

Bases: sklearn.base.ClassifierMixin, sklearn.base.BaseEstimator

Mixin class for all classifiers in scikit-learn.

This mixin defines the following functionality:

  • _estimator_type class attribute defaulting to “classifier”;

  • score method that default to accuracy_score().

  • enforce that fit requires y to be passed through the requires_y tag.

Read more in the User Guide.

Examples

>>> import numpy as np
>>> from sklearn.base import BaseEstimator, ClassifierMixin
>>> # Mixin classes should always be on the left-hand side for a correct MRO
>>> class MyEstimator(ClassifierMixin, BaseEstimator):
...     def __init__(self, *, param=1):
...         self.param = param
...     def fit(self, X, y=None):
...         self.is_fitted_ = True
...         return self
...     def predict(self, X):
...         return np.full(shape=X.shape[0], fill_value=self.param)
>>> estimator = MyEstimator(param=1)
>>> X = np.array([[1, 2], [2, 3], [3, 4]])
>>> y = np.array([1, 0, 1])
>>> estimator.fit(X, y).predict(X)
array([1, 1, 1])
>>> estimator.score(X, y)
0.66...
__load_model(model_path=None, model_name='model.pt')[source]#
__predict(data)[source]#
__rearrange_output(proba, fea, n_epoch)[source]#
__sliding_window_sample(X=None, step=50)[source]#
plot_predictions(epoch_ind=0)[source]#
predict(X=None, step=50)[source]#

input data, predict sleep event for each time step :param X: (n_epoch, n_time) :param step: 300 >= step >= 1 :return: predict_proba, pred, filtered pred, feature

predict_proba(X=None, step=50)[source]#

input data, predict sleep event for each time step :param X: (n_epoch, n_time) :param step: 300 >= step >= 1 :return: predict_proba, pred, filtered pred, feature

to_json()[source]#
to_pandas(overall_threshold=0.5, describe=False, event_threshold=None)[source]#
class sssm.sssm_core.model.TC[source]#

Bases: object

class sssm.sssm_core.model.augmentations[source]#

Bases: object

class sssm.sssm_core.model.base_Model(configs)[source]#

Bases: torch.nn.Module

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables:

training (bool) – Boolean represents whether this module is in training or evaluation mode.

forward(x_in)[source]#