Models

AnomalyDetectionModel

Anomaly Detection 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.

train(X_train, X_val, y_val)

Train the model.

Parameters:
  • X_train (ndarray) – Training data matrix.

  • X_val (ndarray) – Validation data matrix.

  • y_val (ndarray) – Ground truth labels for validation data.

predict(X)

Predict anomalies in the input data.

Parameters:

X (ndarray) – Data matrix for prediction.

Create an instance of the AnomalyDetectionModel and train it using a training dataset. Then, predict anomalies in a validation dataset.

from df_csv_excel.models import AnomalyDetectionModel  # Replace 'your_module' with the actual module name

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

# Create an instance of AnomalyDetectionModel
model = AnomalyDetectionModel()

# 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.