quick_anomaly_detector.models.AnomalyGaussianModel

class quick_anomaly_detector.models.AnomalyGaussianModel(features=None, label=None)

Anomaly Gaussian Model using Gaussian Distribution.

This class provides a simple implementation of an anomaly detection model based on the Gaussian distribution. It includes methods for estimating Gaussian parameters, calculating p-values, selecting the threshold, and making predictions.

Attributes:
  • mu_train (ndarray): Mean vector of the training data.

  • var_train (ndarray): Variance vector of the training data.

  • p_values_train (ndarray): P-values for training data.

  • p_values_val (ndarray): P-values for validation data.

  • epsilon (float): Chosen threshold for anomaly detection.

  • f1 (float): F1 score corresponding to the chosen threshold.

Example:

from quick_anomaly_detector.models import AnomalyGaussianModel

# Load your datasets (X_train, X_val, y_val)
# ...

# Create an instance of AnomalyGaussianModel
model = AnomalyGaussianModel()

# Train the model
model.train(X_train, X_val, y_val)

# Predict anomalies in the validation dataset
anomalies = model.predict(X_val)

print(anomalies)

Note

The anomaly detection model assumes that the input data follows a Gaussian distribution.

Warning

This class is designed for educational purposes and may not be suitable for all types of data.

__init__(features=None, label=None)

Initialize the AnomalyDetectionModel.

Methods

__init__([features, label])

Initialize the AnomalyDetectionModel.

calculate_p_value(X, mu, var)

estimate_gaussian(X)

log_model(model_uri[, experiment_id, ...])

If you need credential, make sure you have them in your environment:

predict(X)

Predict outliers in the input data.

select_threshold(y_val, p_val)

train(train_df, valid_df[, features, label])

Train the AnomalyDetectionModel.