pysad.models.PerfectModel

class pysad.models.PerfectModel[source]

This model directly outputs the ground truth labels. This method is added for testing and pipelining purposes.

Methods

__init__()

fit(X[, y])

Fits the model to all instances in order.

fit_partial(X, y)

Fits the model to the ground truth label.

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.

score(X)

Scores all instaces via score_partial iteratively.

score_partial(X)

Pops the score from the self.label queue.

fit(X, y=None)

Fits the model to all instances in order.

Parameters:
  • X (np.float64 array of shape (num_instances, num_features)) – The instances in order to fit.

  • y (int) – The labels of the instances in order to fit (Optional for unsupervised models, default=None).

Returns:

Fitted model.

Return type:

object

fit_partial(X, y)[source]

Fits the model to the ground truth label. Adds the label to the self.label queue.

Parameters:
  • X – any (Ignored)

  • y (int) – The true label.

Returns:

Returns the self.

Return type:

object

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.

Parameters:
  • X (np.float64 array of shape (num_features,)) – The instance to fit and score.

  • y (int) – The label of the instance (Optional for unsupervised models, default=None).

Returns:

The anomalousness score of the input instance.

Return type:

float

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]

Pops the score from the self.label queue.

Parameters:

X – any (Ignored)

Returns:

The true label.

Return type:

float