quick_anomaly_detector.models.TrainAnomalyNN

class quick_anomaly_detector.models.TrainAnomalyNN(lr=0.001, num_epochs=1000, patience=10)

Class for training and using an anomaly detection neural network.

Attributes:

Parameters:
  • lr (float) – The learning rate for optimization (default: 0.001).

  • num_epochs (int) – The maximum number of training epochs (default: 1000).

  • patience (int) – The number of epochs to wait before early stopping if validation loss does not improve (default: 10).

  • model (AnomalyDetectionNN) – The trained anomaly detection neural network model.

  • optimizer (torch.optim.Optimizer) – The optimizer used for training.

  • criterion (torch.nn.Module) – The loss function used for training.

  • train_loss_arr (numpy.ndarray) – The training loss array.

  • valid_loss_arr (numpy.ndarray) – The validation loss array.

  • train_min_values (numpy.ndarray) – The minimum values of each feature in the training dataset.

  • train_max_values (numpy.ndarray) – The maximum values of each feature in the training dataset.

Example:

from quick_anomaly_detector.models import TrainAnomalyNN

train_model = TrainAnomalyNN(lr=0.001, num_epochs=1000, patience=10)
train_model.train(X_train, X_valid)
predict_result = train_model.predict(X_valid, threshold = 0.0002)
__init__(lr=0.001, num_epochs=1000, patience=10)

Initializes the TrainAnomalyNN class.

Args: - lr (float): The learning rate for optimization (default: 0.001). - num_epochs (int): The maximum number of training epochs (default: 1000). - patience (int): The number of epochs to wait before early stopping if validation loss does not improve (default: 10).

Methods

__init__([lr, num_epochs, patience])

Initializes the TrainAnomalyNN class.

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

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

predict(X[, threshold])

Predicts anomalies in the input data.

train(train_df, valid_df[, features])

Trains the anomaly detection neural network.