pysad.models.integrations.OneFitModel¶
- class pysad.models.integrations.OneFitModel(model_cls, initial_X, initial_y=None, **kwargs)[source]¶
The wrapper model fits the model_cls to the initial instnaces. Then it scores all incoming instances, with this fitted model.
- Parameters:
model_cls (class) – The model class to be instantiated.
initial_X (np.float64 array of shape (num_initial_instances, num_features)) – Initial instances to fit.
initial_y (np.int32 array of shape (num_initial_instances,) – Initial window’s ground truth labels. Used if not None. Needs to be None for the unsupervised model_cls models. (Default=None).
**kwargs (Keyword arguments) – Keyword arguments that are passed to the model_cls.
Methods
__init__
(model_cls, initial_X[, initial_y])Abstract base class for PYOD models.
fit
(X[, y])Fits the model to all instances in order.
fit_partial
(X[, y])This method is ignored.
fit_score
(X[, y])This helper method applies fit_score_partial to all instances in order.
fit_score_partial
(X[, y])Applies fit_partial and score_partial to the next instance, respectively.
Removes the old model from the memory and instantiates a new one.
score
(X)Scores all instaces via score_partial iteratively.
Scores the anomalousness of the next instance.
- fit(X, y=None)¶
Fits the model to all instances in order.
- fit_partial(X, y=None)[source]¶
This method is ignored. Added for convenience.
- Parameters:
X – any
y – any
- Returns:
Returns the self.
- Return type:
- fit_score(X, y=None)¶
This helper method applies fit_score_partial to all instances in order.
- Parameters:
X (np.float64 array of shape (num_instances, num_features)) – The instances in order to fit.
y (np.int32 array of shape (num_instances, )) – The labels of the instances in order to fit (Optional for unsupervised models, default=None).
- Returns:
The anomalousness scores of the instances in order.
- Return type:
np.float64 array of shape (num_instances,)
- fit_score_partial(X, y=None)¶
Applies fit_partial and score_partial to the next instance, respectively.
- reset_model()¶
Removes the old model from the memory and instantiates a new one.
- score(X)¶
Scores all instaces via score_partial iteratively.
- Parameters:
X (np.float64 array of shape (num_instances, num_features)) – The instances in order to score.
- Returns:
The anomalousness scores of the instances in order.
- Return type:
np.float64 array of shape (num_instances,)
- score_partial(X)[source]¶
Scores the anomalousness of the next instance.
- Parameters:
X (np.float64 array of shape (num_features,)) – The instance to score. Higher scores represent more anomalous instances whereas lower scores correspond to more normal instances.
- Returns:
The anomalousness score of the input instance.
- Return type: